use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.
the class DefaultThreadLocalInterceptorChainTest method test4.
public void test4() throws Throwable {
final ChainStack stack = new ChainStack();
final TestInterceptorInvoker interceptor1 = new TestInterceptorInvoker(stack);
final TestInterceptorInvoker interceptor2 = new TestInterceptorInvoker(stack);
final TestInterceptorInvoker invoker = new TestInterceptorInvoker(stack, "hoge");
final InterceptorChainList chainList = new DefaultInterceptorChainList(new Interceptor[] { interceptor1, interceptor2 });
final DefaultThreadLocalInterceptorChain chain = new DefaultThreadLocalInterceptorChain(new ServiceName("Test", "ChainList"), new ServiceName("Test", "Invoker"));
ServiceManagerFactory.registerManager("Test");
ServiceManagerFactory.registerService("Test", "ChainList", chainList);
ServiceManagerFactory.registerService("Test", "Invoker", invoker);
ServiceManagerFactory.findManager("Test").createAllService();
ServiceManagerFactory.findManager("Test").startAllService();
try {
Runnable runnable = new Runnable() {
public void run() {
stack.clear();
Object result = null;
try {
result = chain.invokeNext(new DefaultInvocationContext());
} catch (Throwable th) {
fail();
}
assertEquals("hoge", result);
assertEquals(3, stack.upList().size());
assertEquals(interceptor1, stack.upList().get(0));
assertEquals(interceptor2, stack.upList().get(1));
assertEquals(invoker, stack.upList().get(2));
assertEquals(3, stack.downList().size());
assertEquals(invoker, stack.downList().get(0));
assertEquals(interceptor2, stack.downList().get(1));
assertEquals(interceptor1, stack.downList().get(2));
assertEquals(0, stack.catchList().size());
}
};
Thread[] threads = new Thread[5];
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread(runnable);
}
for (int i = 0; i < threads.length; i++) {
threads[i].start();
}
for (int i = 0; i < threads.length; i++) {
threads[i].join();
}
} finally {
ServiceManagerFactory.findManager("Test").stopAllService();
ServiceManagerFactory.findManager("Test").destroyAllService();
ServiceManagerFactory.unregisterManager("Test");
}
}
use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.
the class ServiceNameEditorTest method testSetAsText3.
public void testSetAsText3() throws Exception {
ServiceNameEditor editor = new ServiceNameEditor();
editor.setServiceManagerName("Manager1");
editor.setAsText("Manager2#Service1");
assertEquals(new ServiceName("Manager2", "Service1"), editor.getValue());
}
use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.
the class ServiceNameRefArrayEditorTest method testSetValue2.
public void testSetValue2() throws Exception {
ServiceNameRefArrayEditor editor = new ServiceNameRefArrayEditor();
editor.setValue(new ServiceNameRef[] { new ServiceNameRef("Service1", new ServiceName("Manager1", "Service1")), new ServiceNameRef("Service2", new ServiceName("Manager2", "Service2")) });
assertEquals("Service1=Manager1#Service1" + System.getProperty("line.separator") + "Service2=Manager2#Service2", editor.getAsText());
}
use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.
the class ServiceNameRefArrayEditorTest method testSetAsText3.
public void testSetAsText3() throws Exception {
ServiceNameRefArrayEditor editor = new ServiceNameRefArrayEditor();
editor.setServiceManagerName("Manager1");
editor.setAsText("Service1=#Service1\nService2=Manager2#Service2");
Object val = editor.getValue();
assertEquals(2, Array.getLength(val));
assertEquals(new ServiceNameRef("Service1", new ServiceName("Manager1", "Service1")), Array.get(val, 0));
assertEquals(new ServiceNameRef("Service2", new ServiceName("Manager2", "Service2")), Array.get(val, 1));
}
use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.
the class ServiceNameRefArrayEditorTest method testSetValue1.
public void testSetValue1() throws Exception {
ServiceNameRefArrayEditor editor = new ServiceNameRefArrayEditor();
editor.setValue(new ServiceNameRef[] { new ServiceNameRef("Service1", new ServiceName("Manager1", "Service1")) });
assertEquals("Service1=Manager1#Service1", editor.getAsText());
}
Aggregations