Updated tests for jMock 2.8.1.

This commit is contained in:
akwizgran
2016-01-18 12:46:42 +00:00
parent b956c761bf
commit ec096e6750
2 changed files with 38 additions and 16 deletions

View File

@@ -19,6 +19,7 @@ import org.briarproject.api.ui.UiCallback;
import org.briarproject.system.SystemClock;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.concurrent.Synchroniser;
import org.junit.Test;
import java.util.Arrays;
@@ -32,7 +33,9 @@ public class PluginManagerImplTest extends BriarTestCase {
@Test
public void testStartAndStop() throws Exception {
Clock clock = new SystemClock();
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor ioExecutor = Executors.newCachedThreadPool();
final EventBus eventBus = context.mock(EventBus.class);
final SimplexPluginConfig simplexPluginConfig =

View File

@@ -9,6 +9,7 @@ import org.briarproject.plugins.ImmediateExecutor;
import org.briarproject.plugins.file.RemovableDriveMonitor.Callback;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.concurrent.Synchroniser;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -42,7 +43,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
public void testWriterIsNullIfNoDrivesAreFound() throws Exception {
final List<File> drives = Collections.emptyList();
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
@@ -74,7 +77,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
drives.add(drive1);
drives.add(drive2);
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
@@ -88,7 +93,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String.class)));
with(any(String[].class)));
will(returnValue(-1)); // The user cancelled the choice
}});
@@ -111,7 +116,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
drives.add(drive1);
drives.add(drive2);
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
@@ -125,7 +132,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String.class)));
with(any(String[].class)));
will(returnValue(0)); // The user chose drive1 but it doesn't exist
}});
@@ -150,7 +157,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
// Create drive1 as a file rather than a directory
assertTrue(drive1.createNewFile());
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
@@ -164,7 +173,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String.class)));
with(any(String[].class)));
will(returnValue(0)); // The user chose drive1 but it's not a dir
}});
@@ -189,7 +198,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
// Create drive1 as a directory
assertTrue(drive1.mkdir());
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
@@ -203,7 +214,7 @@ public class RemovableDrivePluginTest extends BriarTestCase {
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String.class)));
with(any(String[].class)));
will(returnValue(0)); // The user chose drive1
}});
@@ -231,7 +242,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
// Create drive1 as a directory
assertTrue(drive1.mkdir());
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
@@ -245,9 +258,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String.class)));
with(any(String[].class)));
will(returnValue(0)); // The user chose drive1
oneOf(callback).showMessage(with(any(String.class)));
oneOf(callback).showMessage(with(any(String[].class)));
}});
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
@@ -276,7 +289,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
@Test
public void testEmptyDriveIsIgnored() throws Exception {
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
@@ -300,7 +315,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
@Test
public void testFilenames() {
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
@@ -324,7 +341,9 @@ public class RemovableDrivePluginTest extends BriarTestCase {
@Test
public void testReaderIsCreated() throws Exception {
Mockery context = new Mockery();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =