1 package org.apache.fulcrum.yaafi.service;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.TestCase;
23
24 import org.apache.avalon.framework.service.ServiceManager;
25 import org.apache.fulcrum.yaafi.framework.container.ServiceContainer;
26 import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerConfiguration;
27 import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerFactory;
28 import org.apache.fulcrum.yaafi.service.servicemanager.ServiceManagerService;
29 import org.apache.fulcrum.yaafi.service.servicemanager.ServiceManagerServiceImpl;
30
31 /**
32 * Test suite for the ServiceManagereService.
33 *
34 * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
35 */
36
37 public class ServiceManagerServiceTest extends TestCase
38 {
39 private ServiceContainer container = null;
40
41 /**
42 * Constructor
43 * @param name the name of the test case
44 */
45 public ServiceManagerServiceTest( String name )
46 {
47 super(name);
48 }
49
50 /**
51 * @see junit.framework.TestCase#setUp()
52 */
53 protected void setUp() throws Exception
54 {
55 super.setUp();
56 ServiceContainerConfiguration config = new ServiceContainerConfiguration();
57 config.loadContainerConfiguration( "./src/test/TestYaafiContainerConfig.xml" );
58 this.container = ServiceContainerFactory.create( config );
59 }
60
61 /**
62 * @see junit.framework.TestCase#tearDown()
63 */
64 protected void tearDown() throws Exception
65 {
66 ServiceContainerFactory.dispose(this.container);
67 super.tearDown();
68 }
69
70 /**
71 * Access the ServiceManagerService
72 */
73 public void testServiceManagerService() throws Exception
74 {
75 ServiceManagerService serviceManagerService = ServiceManagerServiceImpl.getInstance();
76 assertNotNull(serviceManagerService);
77
78 assertNotNull( serviceManagerService.getAvalonLogger() );
79 assertNotNull( serviceManagerService.getContext().get("urn:avalon:home") );
80 assertNotNull( serviceManagerService.getContext().get("urn:avalon:temp") );
81
82
83 serviceManagerService.getParameters();
84
85
86 serviceManagerService = (ServiceManagerService) serviceManagerService.lookup( ServiceManagerService.class.getName() );
87 assertTrue( serviceManagerService.hasService( ServiceManagerService.class.getName() ) );
88 assertTrue( serviceManagerService.getServiceManager() instanceof ServiceManager );
89 serviceManagerService.release(serviceManagerService);
90 }
91 }