Search in sources :

Example 1 with TorrentConfiguration

use of jetbrains.buildServer.torrent.TorrentConfiguration 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);
    myDirectorySeeder.start(new InetAddress[] { InetAddress.getLocalHost() }, myTracker.getAnnounceURI(), 3);
}
Also used : Expectations(org.jmock.Expectations) Tracker(com.turn.ttorrent.tracker.Tracker) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TimeUnit(java.util.concurrent.TimeUnit) TorrentConfiguration(jetbrains.buildServer.torrent.TorrentConfiguration) Mockery(org.jmock.Mockery) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Tracker (com.turn.ttorrent.tracker.Tracker)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 TimeUnit (java.util.concurrent.TimeUnit)1 TorrentConfiguration (jetbrains.buildServer.torrent.TorrentConfiguration)1 Expectations (org.jmock.Expectations)1 Mockery (org.jmock.Mockery)1 BeforeMethod (org.testng.annotations.BeforeMethod)1