Search in sources :

Example 56 with Mockery

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);
}
Also used : ArrayList(java.util.ArrayList) Mockery(org.jmock.Mockery) IMimeType(org.pentaho.platform.api.mimetype.IMimeType) MimeType(org.pentaho.platform.core.mimetype.MimeType) IPentahoMetadataDomainRepositoryImporter(org.pentaho.platform.plugin.services.metadata.IPentahoMetadataDomainRepositoryImporter) IMimeType(org.pentaho.platform.api.mimetype.IMimeType) Log4JRepositoryImportLogger(org.pentaho.platform.plugin.services.importexport.Log4JRepositoryImportLogger) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Converter(org.pentaho.platform.api.repository2.unified.Converter) Before(org.junit.Before)

Example 57 with Mockery

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();
}
Also used : Expectations(org.jmock.Expectations) LegacyTimelockService(com.palantir.lock.impl.LegacyTimelockService) TrackingKeyValueService(com.palantir.atlasdb.keyvalue.impl.TrackingKeyValueService) ForwardingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ForwardingKeyValueService) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) Sequence(org.jmock.Sequence) Mockery(org.jmock.Mockery) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Map(java.util.Map) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) ImmutableMap(com.google.common.collect.ImmutableMap) SortedMap(java.util.SortedMap) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 58 with Mockery

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);
}
Also used : KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 59 with Mockery

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();
}
Also used : Path(java.nio.file.Path) Expectations(org.jmock.Expectations) BuildArtifact(jetbrains.buildServer.serverSide.artifacts.BuildArtifact) BuildArtifacts(jetbrains.buildServer.serverSide.artifacts.BuildArtifacts) Mockery(org.jmock.Mockery)

Example 60 with Mockery

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());
}
Also used : Expectations(org.jmock.Expectations) AddressChecker(com.turn.ttorrent.tracker.AddressChecker) WaitFor(jetbrains.buildServer.util.WaitFor) ExecutorServices(jetbrains.buildServer.serverSide.executors.ExecutorServices) Mockery(org.jmock.Mockery) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Mockery (org.jmock.Mockery)148 Expectations (org.jmock.Expectations)118 Test (org.junit.Test)77 Before (org.junit.Before)28 ArrayList (java.util.ArrayList)24 Date (java.util.Date)21 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)17 File (java.io.File)15 BeforeMethod (org.testng.annotations.BeforeMethod)15 Synchroniser (org.jmock.lib.concurrent.Synchroniser)14 List (java.util.List)11 ActorDTO (com.management.dto.ActorDTO)7 FanZoneDTO (com.management.dto.FanZoneDTO)6 PropsDTO (com.management.dto.PropsDTO)6 ActorPerformancesRepository (com.management.repositories.ActorPerformancesRepository)6 ActorRepository (com.management.repositories.ActorRepository)6 CinemaTheatreRepository (com.management.repositories.CinemaTheatreRepository)6 EventRepository (com.management.repositories.EventRepository)6 FriendsListRepository (com.management.repositories.FriendsListRepository)6 PerformanceRepository (com.management.repositories.PerformanceRepository)6