本文整理汇总了Java中org.jmock.lib.concurrent.Synchroniser类的典型用法代码示例。如果您正苦于以下问题:Java Synchroniser类的具体用法?Java Synchroniser怎么用?Java Synchroniser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Synchroniser类属于org.jmock.lib.concurrent包,在下文中一共展示了Synchroniser类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testEmptyDriveIsIgnored
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@Test
public void testEmptyDriveIsIgnored() throws Exception {
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
oneOf(monitor).start(with(any(Callback.class)));
}});
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
callback, finder, monitor, 0);
plugin.start();
plugin.driveInserted(testDir);
context.assertIsSatisfied();
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:26,代码来源:RemovableDrivePluginTest.java
示例2: testFilenames
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@Test
public void testFilenames() {
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
callback, finder, monitor, 0);
assertFalse(plugin.isPossibleConnectionFilename("abcdefg.dat"));
assertFalse(plugin.isPossibleConnectionFilename("abcdefghi.dat"));
assertFalse(plugin.isPossibleConnectionFilename("abcdefgh_dat"));
assertFalse(plugin.isPossibleConnectionFilename("abcdefgh.rat"));
assertTrue(plugin.isPossibleConnectionFilename("abcdefgh.dat"));
assertTrue(plugin.isPossibleConnectionFilename("ABCDEFGH.DAT"));
context.assertIsSatisfied();
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:26,代码来源:RemovableDrivePluginTest.java
示例3: before
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@Before
public void before() throws Exception {
_mock = new JUnit4Mockery() {
{
setThreadingPolicy(new Synchroniser());
setImposteriser(ClassImposteriser.INSTANCE);
}
};
_searchService = _mock.mock(SearchService.class);
_repository = _mock.mock(Repository.class);
_nodeService = _mock.mock(NodeService.class);
_clusterProbeUtils = new ClusterProbeUtils();
_clusterProbeUtils.setSearchService(_searchService);
_clusterProbeUtils.setRepository(_repository);
_clusterProbeUtils.setNodeService(_nodeService);
}
开发者ID:Redpill-Linpro,项目名称:alfresco-cluster-probe,代码行数:19,代码来源:ClusterProbeUtilsTest.java
示例4: testWriterIsNullIfNoDrivesAreFound
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@Test
public void testWriterIsNullIfNoDrivesAreFound() throws Exception {
final List<File> drives = Collections.emptyList();
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
oneOf(monitor).start(with(any(Callback.class)));
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
}});
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
callback, finder, monitor, 0);
plugin.start();
assertNull(plugin.createWriter(contactId));
context.assertIsSatisfied();
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:30,代码来源:RemovableDrivePluginTest.java
示例5: testWriterIsNullIfNoDriveIsChosen
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@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<>();
drives.add(drive1);
drives.add(drive2);
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
oneOf(monitor).start(with(any(Callback.class)));
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String[].class)));
will(returnValue(-1)); // The user cancelled the choice
}});
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
callback, finder, monitor, 0);
plugin.start();
assertNull(plugin.createWriter(contactId));
File[] files = drive1.listFiles();
assertTrue(files == null || files.length == 0);
context.assertIsSatisfied();
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:39,代码来源:RemovableDrivePluginTest.java
示例6: testWriterIsNullIfOutputDirDoesNotExist
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@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<>();
drives.add(drive1);
drives.add(drive2);
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
oneOf(monitor).start(with(any(Callback.class)));
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String[].class)));
will(returnValue(0)); // The user chose drive1 but it doesn't exist
}});
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
callback, finder, monitor, 0);
plugin.start();
assertNull(plugin.createWriter(contactId));
File[] files = drive1.listFiles();
assertTrue(files == null || files.length == 0);
context.assertIsSatisfied();
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:39,代码来源:RemovableDrivePluginTest.java
示例7: testWriterIsNullIfOutputDirIsAFile
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@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<>();
drives.add(drive1);
drives.add(drive2);
// Create drive1 as a file rather than a directory
assertTrue(drive1.createNewFile());
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
oneOf(monitor).start(with(any(Callback.class)));
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String[].class)));
will(returnValue(0)); // The user chose drive1 but it's not a dir
}});
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
callback, finder, monitor, 0);
plugin.start();
assertNull(plugin.createWriter(contactId));
File[] files = drive1.listFiles();
assertTrue(files == null || files.length == 0);
context.assertIsSatisfied();
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:41,代码来源:RemovableDrivePluginTest.java
示例8: testReaderIsCreated
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@Test
public void testReaderIsCreated() throws Exception {
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
oneOf(monitor).start(with(any(Callback.class)));
oneOf(callback).readerCreated(with(any(FileTransportReader.class)));
}});
RemovableDrivePlugin plugin = new RemovableDrivePlugin(
new ImmediateExecutor(), callback, finder, monitor, 0);
plugin.start();
File f = new File(testDir, "abcdefgh.dat");
OutputStream out = new FileOutputStream(f);
out.write(new byte[MIN_STREAM_LENGTH]);
out.flush();
out.close();
assertEquals(MIN_STREAM_LENGTH, f.length());
plugin.driveInserted(testDir);
context.assertIsSatisfied();
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:32,代码来源:RemovableDrivePluginTest.java
示例9: setUp
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@Before
public void setUp() {
mockContext = new Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
setThreadingPolicy(new Synchroniser());
}
};
}
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:ThreadUtilsJUnitTest.java
示例10: setup
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@Before
public void setup() {
mockContext = new Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
setThreadingPolicy(new Synchroniser());
}
};
}
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:ServerLauncherTest.java
示例11: testWriterIsNotNullIfOutputDirIsADir
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@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<>();
drives.add(drive1);
drives.add(drive2);
// Create drive1 as a directory
assertTrue(drive1.mkdir());
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
oneOf(monitor).start(with(any(Callback.class)));
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String[].class)));
will(returnValue(0)); // The user chose drive1
}});
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
callback, finder, monitor, 0);
plugin.start();
assertNotNull(plugin.createWriter(contactId));
// The output file should exist and should be empty
File[] files = drive1.listFiles();
assertNotNull(files);
assertEquals(1, files.length);
assertEquals(0, files[0].length());
context.assertIsSatisfied();
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:44,代码来源:RemovableDrivePluginTest.java
示例12: testWritingToWriter
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
@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<>();
drives.add(drive1);
drives.add(drive2);
// Create drive1 as a directory
assertTrue(drive1.mkdir());
Mockery context = new Mockery() {{
setThreadingPolicy(new Synchroniser());
}};
final Executor executor = context.mock(Executor.class);
final SimplexPluginCallback callback =
context.mock(SimplexPluginCallback.class);
final RemovableDriveFinder finder =
context.mock(RemovableDriveFinder.class);
final RemovableDriveMonitor monitor =
context.mock(RemovableDriveMonitor.class);
context.checking(new Expectations() {{
oneOf(monitor).start(with(any(Callback.class)));
oneOf(finder).findRemovableDrives();
will(returnValue(drives));
oneOf(callback).showChoice(with(any(String[].class)),
with(any(String[].class)));
will(returnValue(0)); // The user chose drive1
oneOf(callback).showMessage(with(any(String[].class)));
}});
RemovableDrivePlugin plugin = new RemovableDrivePlugin(executor,
callback, finder, monitor, 0);
plugin.start();
TransportConnectionWriter writer = plugin.createWriter(contactId);
assertNotNull(writer);
// The output file should exist and should be empty
File[] files = drive1.listFiles();
assertNotNull(files);
assertEquals(1, files.length);
assertEquals(0, files[0].length());
// Writing to the output stream should increase the size of the file
OutputStream out = writer.getOutputStream();
out.write(new byte[1234]);
out.flush();
out.close();
// Disposing of the writer should not delete the file
writer.dispose(false);
assertTrue(files[0].exists());
assertEquals(1234, files[0].length());
context.assertIsSatisfied();
}
开发者ID:rafjordao,项目名称:Nird2,代码行数:55,代码来源:RemovableDrivePluginTest.java
示例13: checkRunningOnTestThread
import org.jmock.lib.concurrent.Synchroniser; //导入依赖的package包/类
private void checkRunningOnTestThread() {
if (Thread.currentThread() != testThread) {
reportError("the Mockery is not thread-safe: use a " +
Synchroniser.class.getSimpleName() + " to ensure thread safety");
}
}
开发者ID:Shared-Business-Service,项目名称:jMock-Demo,代码行数:7,代码来源:SingleThreadedPolicy.java
注:本文中的org.jmock.lib.concurrent.Synchroniser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论