Search in sources :

Example 1 with ArtifactCacheProvider

use of jetbrains.buildServer.artifacts.ArtifactCacheProvider 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 2 with ArtifactCacheProvider

use of jetbrains.buildServer.artifacts.ArtifactCacheProvider 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

ArtifactsWatcher (jetbrains.buildServer.agent.artifacts.ArtifactsWatcher)2 ArtifactCacheProvider (jetbrains.buildServer.artifacts.ArtifactCacheProvider)2 LeechSettings (jetbrains.buildServer.torrent.settings.LeechSettings)2 SeedSettings (jetbrains.buildServer.torrent.settings.SeedSettings)2 TorrentsDownloadStatistic (jetbrains.buildServer.torrent.util.TorrentsDownloadStatistic)2 Expectations (org.jmock.Expectations)2 Mockery (org.jmock.Mockery)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Tracker (com.turn.ttorrent.tracker.Tracker)1 AgentLifeCycleListener (jetbrains.buildServer.agent.AgentLifeCycleListener)1 BuildAgentConfiguration (jetbrains.buildServer.agent.BuildAgentConfiguration)1 CurrentBuildTrackerImpl (jetbrains.buildServer.agent.impl.CurrentBuildTrackerImpl)1 ArtifactsCacheListener (jetbrains.buildServer.artifacts.ArtifactsCacheListener)1 DirectoryCacheProviderImpl (jetbrains.buildServer.artifacts.impl.DirectoryCacheProviderImpl)1 SimpleDigestCalculator (jetbrains.buildServer.artifacts.impl.SimpleDigestCalculator)1