use of org.jmock.Mockery in project pentaho-platform by pentaho.
the class MetadataImportHandlerIT method setUp.
@Before
public void setUp() throws Exception {
// mock logger to prevent npe
importLogger = new Log4JRepositoryImportLogger();
context = new Mockery();
metadataImporter = context.mock(IPentahoMetadataDomainRepositoryImporter.class);
MicroPlatform microPlatform = new MicroPlatform();
NameBaseMimeResolver nameResolver = new NameBaseMimeResolver();
microPlatform.defineInstance(IPlatformMimeResolver.class, nameResolver);
List<IMimeType> mimeList = new ArrayList<IMimeType>();
mimeList.add(new MimeType("text/xmi+xml", "xmi"));
metadataHandler = new MetadataImportHandler(mimeList, metadataImporter);
handlers.add(metadataHandler);
importer = new PentahoPlatformImporter(handlers, new DefaultRepositoryContentConverterHandler(new HashMap<String, Converter>()));
importer.setRepositoryImportLogger(importLogger);
}
use of org.jmock.Mockery in project atlasdb by palantir.
the class SnapshotTransactionTest method testPutCleanup.
@Ignore("Until we know what we want to do with GC this will be ignored.")
// This tests that uncommitted values are deleted and cleaned up
@SuppressWarnings("unchecked")
@Test
public void testPutCleanup() throws Exception {
byte[] rowName = PtBytes.toBytes("1");
Mockery m = new Mockery();
final KeyValueService kvMock = m.mock(KeyValueService.class);
KeyValueService kv = MultiDelegateProxy.newProxyInstance(KeyValueService.class, keyValueService, kvMock);
final Cell cell = Cell.create(rowName, rowName);
timestampService.getFreshTimestamp();
final long startTs = timestampService.getFreshTimestamp();
final long transactionTs = timestampService.getFreshTimestamp();
keyValueService.put(TABLE, ImmutableMap.of(cell, PtBytes.EMPTY_BYTE_ARRAY), startTs);
final Sequence seq = m.sequence("seq");
m.checking(new Expectations() {
{
oneOf(kvMock).getLatestTimestamps(TABLE, ImmutableMap.of(cell, Long.MAX_VALUE));
inSequence(seq);
oneOf(kvMock).get(with(TransactionConstants.TRANSACTION_TABLE), with(any(Map.class)));
inSequence(seq);
oneOf(kvMock).putUnlessExists(with(TransactionConstants.TRANSACTION_TABLE), with(any(Map.class)));
inSequence(seq);
oneOf(kvMock).delete(TABLE, Multimaps.forMap(ImmutableMap.of(cell, startTs)));
inSequence(seq);
oneOf(kvMock).getLatestTimestamps(TABLE, ImmutableMap.of(cell, startTs));
inSequence(seq);
oneOf(kvMock).multiPut(with(any(Map.class)), with(transactionTs));
inSequence(seq);
oneOf(kvMock).putUnlessExists(with(TransactionConstants.TRANSACTION_TABLE), with(any(Map.class)));
inSequence(seq);
}
});
SnapshotTransaction snapshot = new SnapshotTransaction(kv, new LegacyTimelockService(timestampService, lockService, lockClient), transactionService, NoOpCleaner.INSTANCE, transactionTs, TestConflictDetectionManagers.createWithStaticConflictDetection(ImmutableMap.of(TABLE, ConflictHandler.RETRY_ON_WRITE_WRITE)), AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING, TransactionReadSentinelBehavior.THROW_EXCEPTION, timestampCache, getRangesExecutor, defaultGetRangesConcurrency, sweepQueue);
snapshot.put(TABLE, ImmutableMap.of(cell, PtBytes.EMPTY_BYTE_ARRAY));
snapshot.commit();
m.assertIsSatisfied();
}
use of org.jmock.Mockery in project atlasdb by palantir.
the class SchemasTest method setup.
@Before
public void setup() {
mockery = new Mockery();
kvs = mockery.mock(KeyValueService.class);
}
use of org.jmock.Mockery in project teamcity-torrent-plugin by JetBrains.
the class ServerTorrentsSeederTest method announceBuildArtifactsTest.
public void announceBuildArtifactsTest() {
Path path = Paths.get("tmp");
Mockery m = new Mockery();
BuildArtifacts buildArtifacts = m.mock(BuildArtifacts.class);
ArtifactsCollector artifactsCollector = m.mock(ArtifactsCollector.class);
ArtifactProcessor artifactProcessor = m.mock(ArtifactProcessor.class);
UnusedTorrentFilesRemover unusedTorrentFilesRemover = m.mock(UnusedTorrentFilesRemover.class);
List<BuildArtifact> artifactsCollectorResult = Collections.emptyList();
m.checking(new Expectations() {
{
one(artifactProcessor).processArtifacts(with(artifactsCollectorResult));
one(artifactsCollector).collectArtifacts(with(buildArtifacts));
will(returnValue(artifactsCollectorResult));
one(unusedTorrentFilesRemover).removeUnusedTorrents(with(artifactsCollectorResult), with(path));
}
});
myTorrentsSeeder.announceBuildArtifacts(path, buildArtifacts, artifactsCollector, artifactProcessor, unusedTorrentFilesRemover);
m.assertIsSatisfied();
}
use of org.jmock.Mockery in project teamcity-torrent-plugin by JetBrains.
the class TorrentTrackerConfiguratorTest method setUp.
@BeforeMethod
@Override
protected void setUp() throws Exception {
super.setUp();
Mockery m = new Mockery();
final AddressChecker addressChecker = m.mock(AddressChecker.class);
m.checking(new Expectations() {
{
allowing(addressChecker).isBadAddress(with(any(String.class)));
will(returnValue(false));
}
});
myTrackerManager = new TorrentTrackerManager(myConfigurator, new ExecutorServices() {
@NotNull
public ScheduledExecutorService getNormalExecutorService() {
return ExecutorsFactory.newFixedScheduledExecutor("aaa", 1);
}
@NotNull
public ExecutorService getLowPriorityExecutorService() {
return null;
}
}, myDispatcher, addressChecker);
myDispatcher.getMulticaster().serverStartup();
new WaitFor(5 * 1000) {
@Override
protected boolean condition() {
return !myTorrentsSeeder.getTorrentsSeeder().isStopped();
}
};
assertFalse(myTorrentsSeeder.getTorrentsSeeder().isStopped());
}
Aggregations