use of jetbrains.buildServer.serverSide.executors.ExecutorServices 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());
}
use of jetbrains.buildServer.serverSide.executors.ExecutorServices 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));
}
use of jetbrains.buildServer.serverSide.executors.ExecutorServices 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);
}
Aggregations