Search in sources :

Example 1 with AddressChecker

use of com.turn.ttorrent.tracker.AddressChecker in project teamcity-torrent-plugin by JetBrains.

the class TorrentTrackerConfiguratorTest method setUp.

@BeforeMethod
@Override
protected void setUp() throws Exception {
    super.setUp();
    Mockery m = new Mockery();
    final AddressChecker addressChecker = m.mock(AddressChecker.class);
    m.checking(new Expectations() {

        {
            allowing(addressChecker).isBadAddress(with(any(String.class)));
            will(returnValue(false));
        }
    });
    myTrackerManager = new TorrentTrackerManager(myConfigurator, new ExecutorServices() {

        @NotNull
        public ScheduledExecutorService getNormalExecutorService() {
            return ExecutorsFactory.newFixedScheduledExecutor("aaa", 1);
        }

        @NotNull
        public ExecutorService getLowPriorityExecutorService() {
            return null;
        }
    }, myDispatcher, addressChecker);
    myDispatcher.getMulticaster().serverStartup();
    new WaitFor(5 * 1000) {

        @Override
        protected boolean condition() {
            return !myTorrentsSeeder.getTorrentsSeeder().isStopped();
        }
    };
    assertFalse(myTorrentsSeeder.getTorrentsSeeder().isStopped());
}
Also used : Expectations(org.jmock.Expectations) AddressChecker(com.turn.ttorrent.tracker.AddressChecker) WaitFor(jetbrains.buildServer.util.WaitFor) ExecutorServices(jetbrains.buildServer.serverSide.executors.ExecutorServices) Mockery(org.jmock.Mockery) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with AddressChecker

use of com.turn.ttorrent.tracker.AddressChecker in project teamcity-torrent-plugin by JetBrains.

the class TrackerControllerTest method createController.

@Override
@SuppressWarnings("unchecked")
protected TrackerController createController() throws IOException {
    Mockery m = new Mockery();
    final XmlRpcHandlerManager rpcHandlerManager = m.mock(XmlRpcHandlerManager.class);
    final AddressChecker addressChecker = m.mock(AddressChecker.class);
    AuthorizationInterceptor interceptor = m.mock(AuthorizationInterceptor.class);
    m.checking(new Expectations() {

        {
            allowing(rpcHandlerManager).addHandler(with(any(String.class)), with(any(Object.class)));
            allowing(interceptor).addPathNotRequiringAuth(with(any(String.class)));
            allowing(addressChecker).isBadAddress(with(any(String.class)));
            will(returnValue(false));
        }
    });
    final TorrentConfigurator configurator = new TorrentConfigurator(new ServerPaths(createTempDir().getAbsolutePath()), myFixture.getSingletonService(RootUrlHolder.class), rpcHandlerManager);
    myTorrentTrackerManager = new TorrentTrackerManager(configurator, myFixture.getSingletonService(ExecutorServices.class), myFixture.getSingletonService(EventDispatcher.class), addressChecker);
    myTorrentTrackerManager.startTracker();
    return new TrackerController(myWebManager, myTorrentTrackerManager, interceptor);
}
Also used : XmlRpcHandlerManager(jetbrains.buildServer.XmlRpcHandlerManager) Expectations(org.jmock.Expectations) AddressChecker(com.turn.ttorrent.tracker.AddressChecker) RootUrlHolder(jetbrains.buildServer.RootUrlHolder) AuthorizationInterceptor(jetbrains.buildServer.controllers.AuthorizationInterceptor) TorrentConfigurator(jetbrains.buildServer.torrent.TorrentConfigurator) Mockery(org.jmock.Mockery) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) TorrentTrackerManager(jetbrains.buildServer.torrent.TorrentTrackerManager)

Aggregations

AddressChecker (com.turn.ttorrent.tracker.AddressChecker)2 Expectations (org.jmock.Expectations)2 Mockery (org.jmock.Mockery)2 RootUrlHolder (jetbrains.buildServer.RootUrlHolder)1 XmlRpcHandlerManager (jetbrains.buildServer.XmlRpcHandlerManager)1 AuthorizationInterceptor (jetbrains.buildServer.controllers.AuthorizationInterceptor)1 ServerPaths (jetbrains.buildServer.serverSide.ServerPaths)1 ExecutorServices (jetbrains.buildServer.serverSide.executors.ExecutorServices)1 TorrentConfigurator (jetbrains.buildServer.torrent.TorrentConfigurator)1 TorrentTrackerManager (jetbrains.buildServer.torrent.TorrentTrackerManager)1 WaitFor (jetbrains.buildServer.util.WaitFor)1 BeforeMethod (org.testng.annotations.BeforeMethod)1