1
2
3
4
5
6
7
8
9 package bexee.core;
10
11 import junit.framework.TestCase;
12 import bexee.util.Constants;
13
14 /***
15 * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:12 $
16 * @author Patric Fornasier
17 */
18 public class ProcessControllerFactoryTest extends TestCase {
19
20 private static final String IMPL = "bexee.core.ProcessControllerFactoryTest$MockProcessController";
21
22 protected void tearDown() throws Exception {
23 super.tearDown();
24
25
26 System.getProperties().remove(Constants.OPT_CONTROLLER);
27 }
28
29 /***
30 * Test if the factory returns the correct default implementation if no
31 * system property is set.
32 */
33 public void testGetInstance() {
34 ProcessController controller = ProcessControllerFactory
35 .createProcessController();
36 assertTrue(controller instanceof ProcessControllerImpl);
37 }
38
39 /***
40 * Test whether the factory returns the default implementation if an invalid
41 * class name is provided.
42 */
43 public void testWrongClassName()
44 {
45
46 System.setProperty(Constants.OPT_CONTROLLER, "nonExistingClass");
47
48
49 ProcessController controller = ProcessControllerFactory.createProcessController();
50 assertTrue(controller instanceof ProcessControllerImpl);
51 }
52
53 /***
54 * Test whether the factory returns the right implementation based on a
55 * system property.
56 */
57 public void testGetInstanceBySystemProperty() {
58
59
60 System.setProperty(Constants.OPT_CONTROLLER, IMPL);
61
62 ProcessController controller = ProcessControllerFactory
63 .createProcessController();
64 assertTrue(controller instanceof ProcessControllerFactoryTest.MockProcessController);
65 }
66
67 /***
68 * Mock class extending the <code>ProcessControllerImpl</code> for
69 * testing.
70 *
71 * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:12 $
72 * @author Patric Fornasier
73 */
74 public static class MockProcessController extends ProcessControllerImpl {
75
76 }
77 }