KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > enterprise > deploy > shared > factories > DeploymentFactoryManagerTest


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package test.enterprise.deploy.shared.factories;
8
9 import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager JavaDoc;
10 import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
11 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException JavaDoc;
12 import javax.enterprise.deploy.spi.factories.DeploymentFactory JavaDoc;
13
14 import junit.framework.TestCase;
15 import test.enterprise.deploy.spi.factories.AdvancedDeploymentFactory;
16 import test.enterprise.deploy.spi.factories.BasicDeploymentFactory;
17
18 /**
19  * @author letiemble
20  * @version $Revision: 1.1 $
21  */

22 public class DeploymentFactoryManagerTest extends TestCase
23 {
24    /** Description of the Field */
25    protected DeploymentFactoryManager JavaDoc manager;
26
27
28    /** Constructor for the TypeTest object */
29    public DeploymentFactoryManagerTest()
30    {
31       super();
32    }
33
34
35    /**
36     * Constructor for the TypeTest object
37     *
38     * @param name Description of the Parameter
39     */

40    public DeploymentFactoryManagerTest(String JavaDoc name)
41    {
42       super(name);
43    }
44
45
46    /** A unit test for JUnit */
47    public void testNoFactory()
48    {
49       DeploymentFactory JavaDoc[] factories = manager.getDeploymentFactories();
50       assertEquals("No factory must be found", factories.length, 0);
51    }
52
53
54    /** A unit test for JUnit */
55    public void testWithFactories()
56    {
57       BasicDeploymentFactory factory1 = new BasicDeploymentFactory();
58     AdvancedDeploymentFactory factory2 = new AdvancedDeploymentFactory();
59
60       manager.registerDeploymentFactory(factory1);
61       assertEquals("One factory must be found", manager.getDeploymentFactories().length, 1);
62
63       manager.registerDeploymentFactory(factory1);
64       assertEquals("One factory must be found", manager.getDeploymentFactories().length, 1);
65
66       manager.registerDeploymentFactory(factory2);
67       assertEquals("Two factories must be found", manager.getDeploymentFactories().length, 2);
68       
69       DeploymentManager JavaDoc dmanager;
70       
71       try{
72         dmanager = manager.getDeploymentManager(BasicDeploymentFactory.URI + "//localhost:6969", null, null);
73         assertNotNull("DeploymentManager cannot be null", dmanager);
74
75         dmanager = manager.getDisconnectedDeploymentManager(BasicDeploymentFactory.URI + "//localhost:6969");
76         assertNotNull("DeploymentManager cannot be null", dmanager);
77
78         dmanager = manager.getDeploymentManager(AdvancedDeploymentFactory.URI + "//localhost:6969", null, null);
79         assertNotNull("DeploymentManager cannot be null", dmanager);
80
81         dmanager = manager.getDisconnectedDeploymentManager(AdvancedDeploymentFactory.URI + "//localhost:6969");
82         assertNotNull("DeploymentManager cannot be null", dmanager);
83       }catch(DeploymentManagerCreationException JavaDoc dmce){
84         fail("Creation shoud be successfull");
85       }
86    }
87
88
89    /**
90     * The JUnit setup method
91     *
92     * @exception Exception Description of the Exception
93     */

94    protected void setUp()
95       throws Exception JavaDoc
96    {
97     this.manager = DeploymentFactoryManager.getInstance();
98    }
99
100
101    /**
102     * The teardown method for JUnit
103     *
104     * @exception Exception Description of the Exception
105     */

106    protected void tearDown()
107       throws Exception JavaDoc
108    {
109       this.manager = null;
110    }
111 }
112
Popular Tags