Search in sources :

Example 1 with TrackerClientFactoryImpl

use of com.turn.ttorrent.client.announce.TrackerClientFactoryImpl 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());
}
Also used : Expectations(org.jmock.Expectations) SelectorFactoryImpl(com.turn.ttorrent.client.SelectorFactoryImpl) Tracker(com.turn.ttorrent.tracker.Tracker) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TimeUnit(java.util.concurrent.TimeUnit) TorrentConfiguration(jetbrains.buildServer.torrent.TorrentConfiguration) TrackerClientFactoryImpl(com.turn.ttorrent.client.announce.TrackerClientFactoryImpl) Mockery(org.jmock.Mockery) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with TrackerClientFactoryImpl

use of com.turn.ttorrent.client.announce.TrackerClientFactoryImpl 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);
}
Also used : Expectations(org.jmock.Expectations) SelectorFactoryImpl(com.turn.ttorrent.client.SelectorFactoryImpl) RootUrlHolder(jetbrains.buildServer.RootUrlHolder) ServerResponsibility(jetbrains.buildServer.serverSide.ServerResponsibility) TrackerClientFactoryImpl(com.turn.ttorrent.client.announce.TrackerClientFactoryImpl) BuildServerListener(jetbrains.buildServer.serverSide.BuildServerListener) Mockery(org.jmock.Mockery) XmlRpcHandlerManager(jetbrains.buildServer.XmlRpcHandlerManager) ServerSettings(jetbrains.buildServer.serverSide.ServerSettings) ExecutorServices(jetbrains.buildServer.serverSide.executors.ExecutorServices) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

SelectorFactoryImpl (com.turn.ttorrent.client.SelectorFactoryImpl)2 TrackerClientFactoryImpl (com.turn.ttorrent.client.announce.TrackerClientFactoryImpl)2 Expectations (org.jmock.Expectations)2 Mockery (org.jmock.Mockery)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Tracker (com.turn.ttorrent.tracker.Tracker)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 TimeUnit (java.util.concurrent.TimeUnit)1 RootUrlHolder (jetbrains.buildServer.RootUrlHolder)1 XmlRpcHandlerManager (jetbrains.buildServer.XmlRpcHandlerManager)1 BuildServerListener (jetbrains.buildServer.serverSide.BuildServerListener)1 ServerPaths (jetbrains.buildServer.serverSide.ServerPaths)1 ServerResponsibility (jetbrains.buildServer.serverSide.ServerResponsibility)1 ServerSettings (jetbrains.buildServer.serverSide.ServerSettings)1 ExecutorServices (jetbrains.buildServer.serverSide.executors.ExecutorServices)1 TorrentConfiguration (jetbrains.buildServer.torrent.TorrentConfiguration)1