use of jetbrains.buildServer.artifacts.impl.DirectoryCacheProviderImpl 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();
}
use of jetbrains.buildServer.artifacts.impl.DirectoryCacheProviderImpl 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();
}
Aggregations