1 15 package org.apache.hivemind; 16 17 import hivemind.test.FrameworkTestCase; 18 19 import org.apache.hivemind.definition.ServicePointDefinition; 20 import org.apache.hivemind.definition.impl.ModuleDefinitionHelper; 21 import org.apache.hivemind.definition.impl.ModuleDefinitionImpl; 22 import org.apache.hivemind.internal.ServiceModel; 23 24 31 public class TestBeanService extends FrameworkTestCase 32 { 33 34 private void attempt(String serviceModel) throws Exception 35 { 36 Registry reg = createRegistryWithPojo(serviceModel); 37 38 Reverser r = (Reverser) reg.getService("bean.Reverser", Reverser.class); 39 40 assertEquals("DNIMEVIH", r.reverse("HIVEMIND")); 41 r.reverse("HIVEMIND"); 43 reg.shutdown(); 44 45 try 46 { 47 r.reverse("SHUTDOWN"); 48 unreachable(); 49 } 50 catch (ApplicationRuntimeException ex) 51 { 52 } 53 } 54 55 public void testSimple() throws Exception 56 { 57 attempt(ServiceModel.SINGLETON); 58 } 59 60 public void testThreaded() throws Exception 61 { 62 attempt(ServiceModel.THREADED); 63 } 64 65 public void testPooled() throws Exception 66 { 67 attempt(ServiceModel.POOLED); 68 } 69 70 73 private Registry createRegistryWithPojo(final String serviceModel) 74 { 75 ModuleDefinitionImpl module = createModuleDefinition("bean"); 76 ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module); 77 78 ServicePointDefinition sp1 = helper.addServicePoint("Reverser", Reverser.class.getName()); 79 helper.addSimpleServiceImplementation(sp1, Reverser.class.getName(), serviceModel); 80 81 return buildFrameworkRegistry(module); 82 } 83 } | Popular Tags |