Effectively final.

This commit is contained in:
akwizgran
2017-11-17 15:40:54 +00:00
committed by Torsten Grote
parent a5b321a93b
commit d7383a3361
153 changed files with 1337 additions and 1396 deletions

View File

@@ -26,10 +26,10 @@ public class PollingRemovableDriveMonitorTest extends BrambleTestCase {
@Test
public void testOneCallbackPerFile() throws Exception {
// Create a finder that returns no files the first time, then two files
final File file1 = new File("foo");
final File file2 = new File("bar");
File file1 = new File("foo");
File file2 = new File("bar");
@NotNullByDefault
final RemovableDriveFinder finder = new RemovableDriveFinder() {
RemovableDriveFinder finder = new RemovableDriveFinder() {
private AtomicBoolean firstCall = new AtomicBoolean(true);
@@ -40,8 +40,8 @@ public class PollingRemovableDriveMonitorTest extends BrambleTestCase {
}
};
// Create a callback that waits for two files
final CountDownLatch latch = new CountDownLatch(2);
final List<File> detected = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(2);
List<File> detected = new ArrayList<>();
@NotNullByDefault
Callback callback = new Callback() {
@@ -57,7 +57,7 @@ public class PollingRemovableDriveMonitorTest extends BrambleTestCase {
}
};
// Create the monitor and start it
final RemovableDriveMonitor monitor = new PollingRemovableDriveMonitor(
RemovableDriveMonitor monitor = new PollingRemovableDriveMonitor(
Executors.newCachedThreadPool(), finder, 1);
monitor.start(callback);
// Wait for the monitor to detect the files
@@ -72,7 +72,7 @@ public class PollingRemovableDriveMonitorTest extends BrambleTestCase {
@Test
public void testExceptionCallback() throws Exception {
// Create a finder that throws an exception the second time it's polled
final RemovableDriveFinder finder = new RemovableDriveFinder() {
RemovableDriveFinder finder = new RemovableDriveFinder() {
private AtomicBoolean firstCall = new AtomicBoolean(true);
@@ -83,7 +83,7 @@ public class PollingRemovableDriveMonitorTest extends BrambleTestCase {
}
};
// Create a callback that waits for an exception
final CountDownLatch latch = new CountDownLatch(1);
CountDownLatch latch = new CountDownLatch(1);
@NotNullByDefault
Callback callback = new Callback() {
@@ -98,7 +98,7 @@ public class PollingRemovableDriveMonitorTest extends BrambleTestCase {
}
};
// Create the monitor and start it
final RemovableDriveMonitor monitor = new PollingRemovableDriveMonitor(
RemovableDriveMonitor monitor = new PollingRemovableDriveMonitor(
Executors.newCachedThreadPool(), finder, 1);
monitor.start(callback);
assertTrue(latch.await(10, SECONDS));

View File

@@ -41,17 +41,17 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
@Test
public void testWriterIsNullIfNoDrivesAreFound() throws Exception {
final List<File> drives = Collections.emptyList();
List<File> drives = Collections.emptyList();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
Executor executor = context.mock(Executor.class);
SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
@@ -71,21 +71,21 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
@Test
public void testWriterIsNullIfNoDriveIsChosen() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
File drive1 = new File(testDir, "1");
File drive2 = new File(testDir, "2");
List<File> drives = new ArrayList<>();
drives.add(drive1);
drives.add(drive2);
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
Executor executor = context.mock(Executor.class);
SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
@@ -110,21 +110,21 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
@Test
public void testWriterIsNullIfOutputDirDoesNotExist() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
File drive1 = new File(testDir, "1");
File drive2 = new File(testDir, "2");
List<File> drives = new ArrayList<>();
drives.add(drive1);
drives.add(drive2);
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
Executor executor = context.mock(Executor.class);
SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
@@ -149,9 +149,9 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
@Test
public void testWriterIsNullIfOutputDirIsAFile() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
File drive1 = new File(testDir, "1");
File drive2 = new File(testDir, "2");
List<File> drives = new ArrayList<>();
drives.add(drive1);
drives.add(drive2);
// Create drive1 as a file rather than a directory
@@ -160,12 +160,12 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
Executor executor = context.mock(Executor.class);
SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
@@ -190,9 +190,9 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
@Test
public void testWriterIsNotNullIfOutputDirIsADir() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
File drive1 = new File(testDir, "1");
File drive2 = new File(testDir, "2");
List<File> drives = new ArrayList<>();
drives.add(drive1);
drives.add(drive2);
// Create drive1 as a directory
@@ -201,12 +201,12 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
Executor executor = context.mock(Executor.class);
SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
@@ -234,9 +234,9 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
@Test
public void testWritingToWriter() throws Exception {
final File drive1 = new File(testDir, "1");
final File drive2 = new File(testDir, "2");
final List<File> drives = new ArrayList<>();
File drive1 = new File(testDir, "1");
File drive2 = new File(testDir, "2");
List<File> drives = new ArrayList<>();
drives.add(drive1);
drives.add(drive2);
// Create drive1 as a directory
@@ -245,12 +245,12 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
Executor executor = context.mock(Executor.class);
SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
@@ -292,12 +292,12 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
Executor executor = context.mock(Executor.class);
SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
@@ -318,12 +318,12 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
Executor executor = context.mock(Executor.class);
SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
@@ -344,11 +344,11 @@ public class RemovableDrivePluginTest extends BrambleTestCase {
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final SimplexPluginCallback callback =
SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{

View File

@@ -61,10 +61,10 @@ public class UnixRemovableDriveMonitorTest extends BrambleTestCase {
return;
}
// Create a callback that will wait for two files before stopping
final List<File> detected = new ArrayList<>();
final CountDownLatch latch = new CountDownLatch(2);
List<File> detected = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(2);
@NotNullByDefault
final Callback callback = new Callback() {
Callback callback = new Callback() {
@Override
public void driveInserted(File f) {
@@ -99,7 +99,7 @@ public class UnixRemovableDriveMonitorTest extends BrambleTestCase {
TestUtils.deleteTestDirectory(testDir);
}
private RemovableDriveMonitor createMonitor(final File dir) {
private RemovableDriveMonitor createMonitor(File dir) {
@NotNullByDefault
RemovableDriveMonitor monitor = new UnixRemovableDriveMonitor() {
@Override

View File

@@ -21,12 +21,12 @@ public class ModemPluginTest extends BrambleTestCase {
@Test
public void testModemCreation() throws Exception {
Mockery context = new Mockery();
final ModemFactory modemFactory = context.mock(ModemFactory.class);
final SerialPortList serialPortList =
ModemFactory modemFactory = context.mock(ModemFactory.class);
SerialPortList serialPortList =
context.mock(SerialPortList.class);
final ModemPlugin plugin = new ModemPlugin(modemFactory,
ModemPlugin plugin = new ModemPlugin(modemFactory,
serialPortList, null, 0);
final Modem modem = context.mock(Modem.class);
Modem modem = context.mock(Modem.class);
context.checking(new Expectations() {{
oneOf(serialPortList).getPortNames();
will(returnValue(new String[] { "foo", "bar", "baz" }));
@@ -53,20 +53,20 @@ public class ModemPluginTest extends BrambleTestCase {
@Test
public void testCreateConnection() throws Exception {
Mockery context = new Mockery();
final ModemFactory modemFactory = context.mock(ModemFactory.class);
final SerialPortList serialPortList =
ModemFactory modemFactory = context.mock(ModemFactory.class);
SerialPortList serialPortList =
context.mock(SerialPortList.class);
final DuplexPluginCallback callback =
DuplexPluginCallback callback =
context.mock(DuplexPluginCallback.class);
final ModemPlugin plugin = new ModemPlugin(modemFactory,
ModemPlugin plugin = new ModemPlugin(modemFactory,
serialPortList, callback, 0);
final Modem modem = context.mock(Modem.class);
final TransportProperties local = new TransportProperties();
Modem modem = context.mock(Modem.class);
TransportProperties local = new TransportProperties();
local.put("iso3166", ISO_1336);
final TransportProperties remote = new TransportProperties();
TransportProperties remote = new TransportProperties();
remote.put("iso3166", ISO_1336);
remote.put("number", NUMBER);
final ContactId contactId = new ContactId(234);
ContactId contactId = new ContactId(234);
context.checking(new Expectations() {{
// start()
oneOf(serialPortList).getPortNames();
@@ -92,20 +92,20 @@ public class ModemPluginTest extends BrambleTestCase {
@Test
public void testCreateConnectionWhenDialReturnsFalse() throws Exception {
Mockery context = new Mockery();
final ModemFactory modemFactory = context.mock(ModemFactory.class);
final SerialPortList serialPortList =
ModemFactory modemFactory = context.mock(ModemFactory.class);
SerialPortList serialPortList =
context.mock(SerialPortList.class);
final DuplexPluginCallback callback =
DuplexPluginCallback callback =
context.mock(DuplexPluginCallback.class);
final ModemPlugin plugin = new ModemPlugin(modemFactory,
ModemPlugin plugin = new ModemPlugin(modemFactory,
serialPortList, callback, 0);
final Modem modem = context.mock(Modem.class);
final TransportProperties local = new TransportProperties();
Modem modem = context.mock(Modem.class);
TransportProperties local = new TransportProperties();
local.put("iso3166", ISO_1336);
final TransportProperties remote = new TransportProperties();
TransportProperties remote = new TransportProperties();
remote.put("iso3166", ISO_1336);
remote.put("number", NUMBER);
final ContactId contactId = new ContactId(234);
ContactId contactId = new ContactId(234);
context.checking(new Expectations() {{
// start()
oneOf(serialPortList).getPortNames();
@@ -131,20 +131,20 @@ public class ModemPluginTest extends BrambleTestCase {
@Test
public void testCreateConnectionWhenDialThrowsException() throws Exception {
Mockery context = new Mockery();
final ModemFactory modemFactory = context.mock(ModemFactory.class);
final SerialPortList serialPortList =
ModemFactory modemFactory = context.mock(ModemFactory.class);
SerialPortList serialPortList =
context.mock(SerialPortList.class);
final DuplexPluginCallback callback =
DuplexPluginCallback callback =
context.mock(DuplexPluginCallback.class);
final ModemPlugin plugin = new ModemPlugin(modemFactory,
ModemPlugin plugin = new ModemPlugin(modemFactory,
serialPortList, callback, 0);
final Modem modem = context.mock(Modem.class);
final TransportProperties local = new TransportProperties();
Modem modem = context.mock(Modem.class);
TransportProperties local = new TransportProperties();
local.put("iso3166", ISO_1336);
final TransportProperties remote = new TransportProperties();
TransportProperties remote = new TransportProperties();
remote.put("iso3166", ISO_1336);
remote.put("number", NUMBER);
final ContactId contactId = new ContactId(234);
ContactId contactId = new ContactId(234);
context.checking(new Expectations() {{
// start()
oneOf(serialPortList).getPortNames();