Search in sources :

Example 61 with Mockery

use of org.jmock.Mockery in project teamcity-torrent-plugin by JetBrains.

the class TorrentTrackerManagerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Mockery m = new Mockery();
    final XmlRpcHandlerManager rpcHandlerManager = m.mock(XmlRpcHandlerManager.class);
    final ExecutorServices executorServices = m.mock(ExecutorServices.class);
    myExecutorService = Executors.newScheduledThreadPool(4);
    final RootUrlHolder rootUrlHolder = m.mock(RootUrlHolder.class);
    m.checking(new Expectations() {

        {
            allowing(rpcHandlerManager).addHandler(with(any(String.class)), with(any(Object.class)));
            allowing(executorServices).getNormalExecutorService();
            will(returnValue(myExecutorService));
            allowing(rootUrlHolder).getRootUrl();
            will(returnValue("http://localhost:8111"));
        }
    });
    myTorrentTrackerManager = new TorrentTrackerManager(new TorrentConfigurator(new ServerPaths(createTempDir().getAbsolutePath()), rootUrlHolder, rpcHandlerManager), executorServices, new EventDispatcher<BuildServerListener>(BuildServerListener.class) {
    }, m.mock(AddressChecker.class));
}
Also used : XmlRpcHandlerManager(jetbrains.buildServer.XmlRpcHandlerManager) Expectations(org.jmock.Expectations) RootUrlHolder(jetbrains.buildServer.RootUrlHolder) EventDispatcher(jetbrains.buildServer.util.EventDispatcher) ExecutorServices(jetbrains.buildServer.serverSide.executors.ExecutorServices) Mockery(org.jmock.Mockery) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 62 with Mockery

use of org.jmock.Mockery in project teamcity-torrent-plugin by JetBrains.

the class AgentTorrentsManagerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    super.setUp();
    EventDispatcher<AgentLifeCycleListener> dispatcher = EventDispatcher.create(AgentLifeCycleListener.class);
    BuildAgentConfiguration agentConfiguration = myAgentConfigurationFixture.setUp();
    final TorrentConfiguration trackerConfiguration = new FakeTorrentConfiguration();
    Mockery m = new Mockery();
    final LeechSettings leechSettings = m.mock(LeechSettings.class);
    final SeedSettings seedingSettings = m.mock(SeedSettings.class);
    final ArtifactCacheProvider cacheProvider = m.mock(ArtifactCacheProvider.class);
    m.checking(new Expectations() {

        {
            allowing(cacheProvider).addListener(with(any(TorrentArtifactCacheListener.class)));
            allowing(leechSettings).isDownloadEnabled();
            will(returnValue(true));
            allowing(seedingSettings).isSeedingEnabled();
            will(returnValue(true));
        }
    });
    final ArtifactsWatcher artifactsWatcher = m.mock(ArtifactsWatcher.class);
    AgentTorrentsSeeder seeder = new AgentTorrentsSeeder(agentConfiguration, trackerConfiguration);
    TorrentFilesFactoryImpl tff = new TorrentFilesFactoryImpl(agentConfiguration, trackerConfiguration, new FakeAgentIdleTasks(), seeder);
    myTorrentsDownloadStatistic = new TorrentsDownloadStatistic();
    myTorrentsManager = new AgentTorrentsManager(dispatcher, cacheProvider, new CurrentBuildTrackerImpl(dispatcher), trackerConfiguration, seeder, tff, artifactsWatcher, myTorrentsDownloadStatistic, leechSettings, agentConfiguration, seedingSettings);
}
Also used : Expectations(org.jmock.Expectations) AgentLifeCycleListener(jetbrains.buildServer.agent.AgentLifeCycleListener) ArtifactsWatcher(jetbrains.buildServer.agent.artifacts.ArtifactsWatcher) Mockery(org.jmock.Mockery) CurrentBuildTrackerImpl(jetbrains.buildServer.agent.impl.CurrentBuildTrackerImpl) SeedSettings(jetbrains.buildServer.torrent.settings.SeedSettings) LeechSettings(jetbrains.buildServer.torrent.settings.LeechSettings) TorrentsDownloadStatistic(jetbrains.buildServer.torrent.util.TorrentsDownloadStatistic) BuildAgentConfiguration(jetbrains.buildServer.agent.BuildAgentConfiguration) ArtifactCacheProvider(jetbrains.buildServer.artifacts.ArtifactCacheProvider) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 63 with Mockery

use of org.jmock.Mockery in project teamcity-torrent-plugin by JetBrains.

the class BuildAgentConfigurationFixture method setUp.

public BuildAgentConfiguration setUp() throws IOException {
    myTmpFiles = new TempFiles();
    final File systemDir = myTmpFiles.createTempDir();
    final File torrentsDir = myTmpFiles.createTempDir();
    Mockery m = new Mockery();
    final BuildAgentConfiguration agentConfiguration = m.mock(BuildAgentConfiguration.class);
    m.checking(new Expectations() {

        {
            allowing(agentConfiguration).getServerUrl();
            will(returnValue("http://localhost:8111/bs"));
            allowing(agentConfiguration).getSystemDirectory();
            will(returnValue(systemDir));
            allowing(agentConfiguration).getCacheDirectory(with(Constants.TORRENTS_DIRNAME));
            will(returnValue(torrentsDir));
        }
    });
    return agentConfiguration;
}
Also used : Expectations(org.jmock.Expectations) File(java.io.File) Mockery(org.jmock.Mockery) BuildAgentConfiguration(jetbrains.buildServer.agent.BuildAgentConfiguration) TempFiles(jetbrains.buildServer.TempFiles)

Example 64 with Mockery

use of org.jmock.Mockery in project teamcity-torrent-plugin by JetBrains.

the class TorrentArtifactCacheListenerSecondTest method setUp.

@BeforeMethod
@Override
protected void setUp() throws Exception {
    super.setUp();
    myAgentDirectory = createTempDir();
    myM = new Mockery();
    final AgentRunningBuild build = myM.mock(AgentRunningBuild.class);
    final BuildProgressLogger logger = new FakeBuildProgressLogger();
    myBuildTracker = myM.mock(CurrentBuildTracker.class);
    myCacheProvider = myM.mock(ArtifactCacheProvider.class);
    myAgentConfiguration = myM.mock(BuildAgentConfiguration.class);
    final LeechSettings leechSettings = myM.mock(LeechSettings.class);
    final SeedSettings seedingSettings = myM.mock(SeedSettings.class);
    myM.checking(new Expectations() {

        {
            allowing(myBuildTracker).getCurrentBuild();
            will(returnValue(build));
            allowing(build).getBuildLogger();
            will(returnValue(logger));
            allowing(build).getAgentConfiguration();
            will(returnValue(myAgentConfiguration));
            allowing(build).getBuildTempDirectory();
            will(returnValue(new File(myAgentDirectory, "temp")));
            allowing(myAgentConfiguration).getSystemDirectory();
            will(returnValue(new File(myAgentDirectory, "system")));
            allowing(myAgentConfiguration).getCacheDirectory(with(Constants.TORRENTS_DIRNAME));
            will(returnValue(new File(myAgentDirectory, "torrents")));
            allowing(myAgentConfiguration).getServerUrl();
            will(returnValue("http://localhost:6969/bs"));
            allowing(build).getBuildTypeExternalId();
            will(returnValue(BUILD_EXTERNAL_ID));
            allowing(build).getBuildId();
            will(returnValue(BUILD_ID));
            allowing(myCacheProvider).addListener(with(any(ArtifactsCacheListener.class)));
            allowing(leechSettings).isDownloadEnabled();
            will(returnValue(true));
            allowing(seedingSettings).isSeedingEnabled();
            will(returnValue(true));
        }
    });
    final TorrentConfiguration configuration = new FakeTorrentConfiguration();
    myArtifactsWatcher = myM.mock(ArtifactsWatcher.class);
    AgentTorrentsSeeder seeder = new AgentTorrentsSeeder(myAgentConfiguration, configuration);
    TorrentFilesFactoryImpl torrentsFactory = new TorrentFilesFactoryImpl(myAgentConfiguration, configuration, new FakeAgentIdleTasks(), seeder);
    final EventDispatcher<AgentLifeCycleListener> eventDispatcher = EventDispatcher.create(AgentLifeCycleListener.class);
    AgentTorrentsManager manager = new AgentTorrentsManager(eventDispatcher, myCacheProvider, myBuildTracker, configuration, seeder, torrentsFactory, myArtifactsWatcher, new TorrentsDownloadStatistic(), leechSettings, myAgentConfiguration, seedingSettings);
    myCacheListener = new TorrentArtifactCacheListener(seeder.getTorrentsSeeder(), myBuildTracker, configuration, manager, torrentsFactory, myArtifactsWatcher, myAgentConfiguration);
    myCacheListener.onCacheInitialized(new DirectoryCacheProviderImpl(new File(myAgentDirectory, "cache"), new SimpleDigestCalculator()));
    manager.checkReady();
}
Also used : Mockery(org.jmock.Mockery) LeechSettings(jetbrains.buildServer.torrent.settings.LeechSettings) TorrentsDownloadStatistic(jetbrains.buildServer.torrent.util.TorrentsDownloadStatistic) ArtifactCacheProvider(jetbrains.buildServer.artifacts.ArtifactCacheProvider) Expectations(org.jmock.Expectations) ArtifactsCacheListener(jetbrains.buildServer.artifacts.ArtifactsCacheListener) ArtifactsWatcher(jetbrains.buildServer.agent.artifacts.ArtifactsWatcher) SeedSettings(jetbrains.buildServer.torrent.settings.SeedSettings) SimpleDigestCalculator(jetbrains.buildServer.artifacts.impl.SimpleDigestCalculator) DirectoryCacheProviderImpl(jetbrains.buildServer.artifacts.impl.DirectoryCacheProviderImpl) File(java.io.File) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 65 with Mockery

use of org.jmock.Mockery in project teamcity-torrent-plugin by JetBrains.

the class TorrentArtifactCacheListenerTest method setUp.

@BeforeMethod
@Override
protected void setUp() throws Exception {
    super.setUp();
    myTracker = new Tracker(6969);
    myTracker.start(false);
    myAgentConfiguration = myAgentConfigurationFixture.setUp();
    Mockery m = new Mockery();
    final AgentRunningBuild build = m.mock(AgentRunningBuild.class);
    final BuildProgressLogger logger = new FakeBuildProgressLogger();
    final CurrentBuildTracker buildTracker = m.mock(CurrentBuildTracker.class);
    final ArtifactCacheProvider cacheProvider = m.mock(ArtifactCacheProvider.class);
    final LeechSettings leechSettings = m.mock(LeechSettings.class);
    final SeedSettings seedingSettings = m.mock(SeedSettings.class);
    m.checking(new Expectations() {

        {
            allowing(buildTracker).getCurrentBuild();
            will(returnValue(build));
            allowing(build).getBuildLogger();
            will(returnValue(logger));
            allowing(build).getAgentConfiguration();
            will(returnValue(myAgentConfiguration));
            allowing(cacheProvider).addListener(with(any(ArtifactsCacheListener.class)));
            allowing(build).getBuildTypeExternalId();
            will(returnValue("1"));
            allowing(build).getBuildId();
            will(returnValue(1L));
            allowing(leechSettings).isDownloadEnabled();
            will(returnValue(true));
            allowing(seedingSettings).isSeedingEnabled();
            will(returnValue(true));
        }
    });
    final TorrentConfiguration configuration = new FakeTorrentConfiguration();
    final ArtifactsWatcher artifactsWatcher = m.mock(ArtifactsWatcher.class);
    mySeeder = new AgentTorrentsSeeder(myAgentConfiguration, configuration);
    TorrentFilesFactoryImpl torrentsFactory = new TorrentFilesFactoryImpl(myAgentConfiguration, configuration, new FakeAgentIdleTasks(), mySeeder);
    final EventDispatcher<AgentLifeCycleListener> eventDispatcher = EventDispatcher.create(AgentLifeCycleListener.class);
    AgentTorrentsManager manager = new AgentTorrentsManager(eventDispatcher, cacheProvider, buildTracker, configuration, mySeeder, torrentsFactory, artifactsWatcher, new TorrentsDownloadStatistic(), leechSettings, myAgentConfiguration, seedingSettings);
    myCacheListener = new TorrentArtifactCacheListener(mySeeder.getTorrentsSeeder(), buildTracker, configuration, manager, torrentsFactory, artifactsWatcher, myAgentConfiguration);
    myCacheListener.onCacheInitialized(new DirectoryCacheProviderImpl(getTorrentsDirectory(), new SimpleDigestCalculator()));
    manager.checkReady();
}
Also used : Expectations(org.jmock.Expectations) ArtifactsCacheListener(jetbrains.buildServer.artifacts.ArtifactsCacheListener) Tracker(com.turn.ttorrent.tracker.Tracker) ArtifactsWatcher(jetbrains.buildServer.agent.artifacts.ArtifactsWatcher) Mockery(org.jmock.Mockery) SeedSettings(jetbrains.buildServer.torrent.settings.SeedSettings) SimpleDigestCalculator(jetbrains.buildServer.artifacts.impl.SimpleDigestCalculator) LeechSettings(jetbrains.buildServer.torrent.settings.LeechSettings) DirectoryCacheProviderImpl(jetbrains.buildServer.artifacts.impl.DirectoryCacheProviderImpl) TorrentsDownloadStatistic(jetbrains.buildServer.torrent.util.TorrentsDownloadStatistic) ArtifactCacheProvider(jetbrains.buildServer.artifacts.ArtifactCacheProvider) 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