use of org.apache.felix.dm.Logger in project felix by apache.
the class ConfigurationDependencyImplTest method createConfigurationDependency.
private ConfigurationDependencyImpl createConfigurationDependency(Object service) {
BundleContext bc = mock(BundleContext.class);
Logger mockLogger = mock(Logger.class);
ComponentContext component = mock(ComponentContext.class);
when(component.getExecutor()).thenReturn(Executors.newSingleThreadExecutor());
when(component.getLogger()).thenReturn(mockLogger);
ConfigurationDependencyImpl result = new ConfigurationDependencyImpl(bc, mockLogger);
result.setCallback(service, "updated").setPid("does.not.matter");
result.setComponentContext(component);
result.start();
return result;
}
use of org.apache.felix.dm.Logger in project felix by apache.
the class SerialExecutorTest method testSerialExecutor.
@Test
public void testSerialExecutor() {
info("Testing serial executor");
int cores = Math.max(10, Runtime.getRuntime().availableProcessors());
ExecutorService threadPool = null;
try {
threadPool = Executors.newFixedThreadPool(cores);
final SerialExecutor serial = new SerialExecutor(new Logger(null));
long timeStamp = System.currentTimeMillis();
for (int i = 0; i < TESTS; i++) {
final CountDownLatch latch = new CountDownLatch(cores * 2);
final SerialTask task = new SerialTask(serial, latch);
for (int j = 0; j < cores; j++) {
threadPool.execute(new Runnable() {
public void run() {
serial.execute(task);
}
});
}
Assert.assertTrue("Test " + i + " did not terminate timely", latch.await(20000, TimeUnit.MILLISECONDS));
}
long now = System.currentTimeMillis();
System.out.println("Performed " + TESTS + " tests in " + (now - timeStamp) + " ms.");
timeStamp = now;
} catch (Throwable t) {
t.printStackTrace();
Assert.fail("Test failed: " + t.getMessage());
} finally {
if (threadPool != null) {
shutdown(threadPool);
}
}
}
Aggregations