Callback should not be null.

This commit is contained in:
akwizgran
2012-01-11 16:17:14 +00:00
parent 3e61adb623
commit 1499e061c1
3 changed files with 13 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ JNotifyListener {
} }
synchronized(this) { synchronized(this) {
assert !started; assert !started;
assert callback == null; assert this.callback == null;
started = true; started = true;
this.callback = callback; this.callback = callback;
this.watches.addAll(watches); this.watches.addAll(watches);

View File

@@ -76,7 +76,11 @@ public class PollingRemovableDriveMonitorTest extends BriarTestCase {
// Create the monitor, start it, and give it some time to run // Create the monitor, start it, and give it some time to run
final RemovableDriveMonitor monitor = new PollingRemovableDriveMonitor( final RemovableDriveMonitor monitor = new PollingRemovableDriveMonitor(
Executors.newCachedThreadPool(), finder, 10); Executors.newCachedThreadPool(), finder, 10);
monitor.start(null); monitor.start(new Callback() {
public void driveInserted(File root) {
fail();
}
});
Thread.sleep(50); Thread.sleep(50);
// The monitor should rethrow the exception when it stops // The monitor should rethrow the exception when it stops
try { try {

View File

@@ -26,19 +26,23 @@ public class UnixRemovableDriveMonitorTest extends BriarTestCase {
@Test @Test
public void testNonexistentDir() throws Exception { public void testNonexistentDir() throws Exception {
if(!OsUtils.isLinux() || OsUtils.isMacLeopardOrNewer()) { if(!(OsUtils.isLinux() || OsUtils.isMacLeopardOrNewer())) {
System.err.println("Warning: Skipping test"); System.err.println("Warning: Skipping test");
return; return;
} }
File doesNotExist = new File(testDir, "doesNotExist"); File doesNotExist = new File(testDir, "doesNotExist");
RemovableDriveMonitor monitor = createMonitor(doesNotExist); RemovableDriveMonitor monitor = createMonitor(doesNotExist);
monitor.start(null); monitor.start(new Callback() {
public void driveInserted(File root) {
fail();
}
});
monitor.stop(); monitor.stop();
} }
@Test @Test
public void testOneCallbackPerFile() throws Exception { public void testOneCallbackPerFile() throws Exception {
if(!OsUtils.isLinux() || OsUtils.isMacLeopardOrNewer()) { if(!(OsUtils.isLinux() || OsUtils.isMacLeopardOrNewer())) {
System.err.println("Warning: Skipping test"); System.err.println("Warning: Skipping test");
return; return;
} }