1 package org.apache.turbine.services.avaloncomponent; 2 3 18 19 import org.apache.commons.configuration.BaseConfiguration; 20 import org.apache.commons.configuration.Configuration; 21 22 import org.apache.turbine.services.ServiceManager; 23 import org.apache.turbine.services.TurbineServices; 24 import org.apache.turbine.test.BaseTestCase; 25 import org.apache.turbine.test.TestComponent; 26 27 28 34 public class TurbineAvalonComponentServiceTest 35 extends BaseTestCase 36 { 37 private static final String PREFIX = "services." + 38 AvalonComponentService.SERVICE_NAME + '.'; 39 40 47 public TurbineAvalonComponentServiceTest(String name) 48 throws Exception 49 { 50 super(name); 51 ServiceManager serviceManager = TurbineServices.getInstance(); 52 serviceManager.setApplicationRoot("."); 53 54 Configuration cfg = new BaseConfiguration(); 55 cfg.setProperty(PREFIX + "classname", 56 TurbineAvalonComponentService.class.getName()); 57 58 cfg.setProperty(PREFIX + "componentConfiguration", 60 "src/test/componentConfiguration.xml"); 61 cfg.setProperty(PREFIX + "componentRoles", 62 "src/test/componentRoles.xml"); 63 serviceManager.setConfiguration(cfg); 64 65 try 66 { 67 serviceManager.init(); 68 } 69 catch(Exception e) 70 { 71 e.printStackTrace(); 72 fail(); 73 } 74 } 75 76 80 public void testGetAndUseTestComponent() 81 { 82 try 83 { 84 AvalonComponentService cs = (AvalonComponentService) 85 TurbineServices.getInstance().getService(AvalonComponentService.SERVICE_NAME); 86 87 TestComponent tc = (TestComponent) cs.lookup(TestComponent.ROLE); 88 tc.test(); 89 cs.release(tc); 90 } 91 catch(Exception e) 92 { 93 e.printStackTrace(); 94 fail(); 95 } 96 } 97 } 98 | Popular Tags |