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.ServiceException;
25 import org.apache.fulcrum.yaafi.TestComponent;
26 import org.apache.fulcrum.yaafi.framework.container.ServiceContainer;
27 import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerConfiguration;
28 import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerFactory;
29 import org.apache.fulcrum.yaafi.service.reconfiguration.ReconfigurationService;
30
31 /**
32 * Test suite for the ReconfigurationService. This test doesn't do
33 * anything apart from running a minute so you have some time to tinker
34 * with the component configuration file.
35 *
36 * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
37 */
38
39 public class ReconfigurationTest extends TestCase
40 {
41 private ServiceContainer container = null;
42
43 /**
44 * Constructor
45 * @param name the name of the test case
46 */
47 public ReconfigurationTest( String name )
48 {
49 super(name);
50 }
51
52 /**
53 * @see junit.framework.TestCase#tearDown()
54 */
55 protected void tearDown() throws Exception
56 {
57 ServiceContainerFactory.dispose(this.container);
58 super.tearDown();
59 }
60
61 /**
62 * @return get our simple test component
63 */
64 private TestComponent getTestComponent() throws ServiceException
65 {
66 return (TestComponent) container.lookup(
67 TestComponent.ROLE
68 );
69 }
70
71 /**
72 * Trigger the ReconfigurationService by instantiating it manually.
73 */
74 public void testReconfigurationService() throws Exception
75 {
76
77
78 ServiceContainerConfiguration config = new ServiceContainerConfiguration();
79 config.loadContainerConfiguration( "./src/test/TestYaafiContainerConfig.xml" );
80 this.container = ServiceContainerFactory.create( config );
81
82
83
84
85 ReconfigurationService reconfigurationService = null;
86
87 reconfigurationService = (ReconfigurationService) this.container.lookup(
88 ReconfigurationService.class.getName()
89 );
90
91 assertNotNull(reconfigurationService);
92
93
94
95
96
97 this.getTestComponent().test();
98 }
99 }