use of com.turn.ttorrent.client.SelectorFactoryImpl in project teamcity-torrent-plugin by JetBrains.
the class TorrentsSeederTest method setUp.
@BeforeMethod
@Override
protected void setUp() throws Exception {
super.setUp();
myTracker = new Tracker(6969);
myTracker.start(false);
Mockery m = new Mockery();
myExecutorService = m.mock(ScheduledExecutorService.class);
final TorrentConfiguration torrentConfiguration = m.mock(TorrentConfiguration.class);
m.checking(new Expectations() {
{
allowing(torrentConfiguration).getWorkerPoolSize();
will(returnValue(10));
allowing(torrentConfiguration).getPieceHashingPoolSize();
will(returnValue(4));
allowing(myExecutorService).submit(with(any(Runnable.class)));
allowing(myExecutorService).scheduleWithFixedDelay(with(any(Runnable.class)), with(any(Long.class)), with(any(Long.class)), with(any(TimeUnit.class)));
allowing(myExecutorService).shutdownNow();
}
});
myDirectorySeeder = new TorrentsSeeder(createTempDir(), 100, null, myExecutorService, torrentConfiguration, new TrackerClientFactoryImpl());
myDirectorySeeder.start(new InetAddress[] { InetAddress.getLocalHost() }, myTracker.getAnnounceURI(), 3, new SelectorFactoryImpl());
}
use of com.turn.ttorrent.client.SelectorFactoryImpl in project teamcity-torrent-plugin by JetBrains.
the class ServerTorrentsSeederTestCase method setUp.
@BeforeMethod
@Override
protected void setUp() throws Exception {
super.setUp();
final Mockery m = new Mockery();
final ServerPaths serverPaths = new ServerPaths(createTempDir().getAbsolutePath());
final RootUrlHolder rootUrlHolder = m.mock(RootUrlHolder.class);
final ExecutorServices executorServices = m.mock(ExecutorServices.class);
myExecutorService = Executors.newScheduledThreadPool(1);
final ServerResponsibility serverResponsibility = m.mock(ServerResponsibility.class);
m.checking(new Expectations() {
{
allowing(rootUrlHolder).getRootUrl();
will(returnValue("http://localhost:8111/"));
allowing(executorServices).getNormalExecutorService();
will(returnValue(myExecutorService));
allowing(serverResponsibility).canManageBuilds();
will(returnValue(true));
}
});
final ServerSettings serverSettings = m.mock(ServerSettings.class);
m.checking(new Expectations() {
{
allowing(serverSettings).getArtifactDirectories();
will(returnValue(Collections.singletonList(serverPaths.getArtifactsDirectory())));
}
});
myConfigurator = new TorrentConfigurator(serverPaths, rootUrlHolder, new XmlRpcHandlerManager() {
public void addHandler(String handlerName, Object handler) {
}
public void addSessionHandler(String handlerName, Object handler) {
}
});
myConfigurator.setDownloadEnabled(true);
myConfigurator.setSeedingEnabled(true);
myDispatcher = EventDispatcher.create(BuildServerListener.class);
myTorrentsSeeder = new ServerTorrentsDirectorySeeder(serverPaths, serverSettings, myConfigurator, myDispatcher, executorServices, new SelectorFactoryImpl(), new TrackerClientFactoryImpl(), serverResponsibility);
}
Aggregations