Search in sources :

Example 1 with XmlRpcHandlerManager

use of jetbrains.buildServer.XmlRpcHandlerManager in project teamcity-torrent-plugin by JetBrains.

the class TorrentTrackerManagerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Mockery m = new Mockery();
    final XmlRpcHandlerManager rpcHandlerManager = m.mock(XmlRpcHandlerManager.class);
    final ExecutorServices executorServices = m.mock(ExecutorServices.class);
    myExecutorService = Executors.newScheduledThreadPool(4);
    final RootUrlHolder rootUrlHolder = m.mock(RootUrlHolder.class);
    m.checking(new Expectations() {

        {
            allowing(rpcHandlerManager).addHandler(with(any(String.class)), with(any(Object.class)));
            allowing(executorServices).getNormalExecutorService();
            will(returnValue(myExecutorService));
            allowing(rootUrlHolder).getRootUrl();
            will(returnValue("http://localhost:8111"));
        }
    });
    myTorrentTrackerManager = new TorrentTrackerManager(new TorrentConfigurator(new ServerPaths(createTempDir().getAbsolutePath()), rootUrlHolder, rpcHandlerManager), executorServices, new EventDispatcher<BuildServerListener>(BuildServerListener.class) {
    }, m.mock(AddressChecker.class));
}
Also used : XmlRpcHandlerManager(jetbrains.buildServer.XmlRpcHandlerManager) Expectations(org.jmock.Expectations) RootUrlHolder(jetbrains.buildServer.RootUrlHolder) EventDispatcher(jetbrains.buildServer.util.EventDispatcher) ExecutorServices(jetbrains.buildServer.serverSide.executors.ExecutorServices) Mockery(org.jmock.Mockery) ServerPaths(jetbrains.buildServer.serverSide.ServerPaths) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with XmlRpcHandlerManager

use of jetbrains.buildServer.XmlRpcHandlerManager 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);
    m.checking(new Expectations() {

        {
            allowing(rootUrlHolder).getRootUrl();
            will(returnValue("http://localhost:8111/"));
            allowing(executorServices).getNormalExecutorService();
            will(returnValue(myExecutorService));
        }
    });
    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 = new BuildServerListenerEventDispatcher(new SecurityContextImpl());
    myTorrentsSeeder = new ServerTorrentsDirectorySeeder(serverPaths, serverSettings, myConfigurator, myDispatcher, executorServices);
}
Also used : Expectations(org.jmock.Expectations) RootUrlHolder(jetbrains.buildServer.RootUrlHolder) SecurityContextImpl(jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl) Mockery(org.jmock.Mockery) BuildServerListenerEventDispatcher(jetbrains.buildServer.serverSide.BuildServerListenerEventDispatcher) 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)

Example 3 with XmlRpcHandlerManager

use of jetbrains.buildServer.XmlRpcHandlerManager 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

RootUrlHolder (jetbrains.buildServer.RootUrlHolder)3 XmlRpcHandlerManager (jetbrains.buildServer.XmlRpcHandlerManager)3 ServerPaths (jetbrains.buildServer.serverSide.ServerPaths)3 Expectations (org.jmock.Expectations)3 Mockery (org.jmock.Mockery)3 ExecutorServices (jetbrains.buildServer.serverSide.executors.ExecutorServices)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 AddressChecker (com.turn.ttorrent.tracker.AddressChecker)1 AuthorizationInterceptor (jetbrains.buildServer.controllers.AuthorizationInterceptor)1 BuildServerListenerEventDispatcher (jetbrains.buildServer.serverSide.BuildServerListenerEventDispatcher)1 ServerSettings (jetbrains.buildServer.serverSide.ServerSettings)1 SecurityContextImpl (jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl)1 TorrentConfigurator (jetbrains.buildServer.torrent.TorrentConfigurator)1 TorrentTrackerManager (jetbrains.buildServer.torrent.TorrentTrackerManager)1 EventDispatcher (jetbrains.buildServer.util.EventDispatcher)1