KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > repository > config > test > RepositoryConfigBuilderTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.repository.config.test;
8
9
10 import java.io.File JavaDoc;
11 import java.util.HashMap JavaDoc;
12 import java.util.Map JavaDoc;
13
14 import junit.framework.TestCase;
15
16 import org.jdom.Document;
17 import org.jdom.input.SAXBuilder;
18
19 import com.inversoft.config.ConfigurationException;
20 import com.inversoft.util.FileTools;
21 import com.inversoft.verge.repository.config.RepositoryConfigBuilder;
22 import com.inversoft.verge.repository.config.RepositoryConfigFactory;
23 import com.inversoft.verge.repository.config.RepositoryConfigRegistry;
24
25
26 /**
27  * <p>
28  * This class contains the TestCases for the builder
29  * </p>
30  *
31  * @author Brian Pontarelli
32  * @since 2.0
33  * @version 2.0
34  */

35 public class RepositoryConfigBuilderTest extends TestCase {
36
37     /**
38      * Constructs a new <code>RepositoryConfigBuilderTest</code> TestCase instance
39      */

40     public RepositoryConfigBuilderTest(String JavaDoc name) {
41         super(name);
42     }
43
44
45     /**
46      * Test building
47      */

48     public void testBuild() {
49
50         RepositoryConfigBuilder builder = new RepositoryConfigBuilder();
51         RepositoryConfigRegistry registry =
52             (RepositoryConfigRegistry) new RepositoryConfigFactory().createRegistry();
53         Document doc = getDocument();
54         try {
55             builder.build(doc, registry);
56         } catch (ConfigurationException ce) {
57             fail(ce.toString());
58         }
59     }
60
61     /**
62      * Test validating
63      */

64     public void testValidate() {
65
66         RepositoryConfigBuilder builder = new RepositoryConfigBuilder();
67         RepositoryConfigRegistry registry =
68             (RepositoryConfigRegistry) new RepositoryConfigFactory().createRegistry();
69         Document doc = getDocument();
70         Map JavaDoc registries = new HashMap JavaDoc();
71         registries.put(RepositoryConfigFactory.NAME, registry);
72         try {
73             builder.build(doc, registry);
74             builder.validate(registry, registries);
75         } catch (Exception JavaDoc e) {
76             fail(e.toString());
77         }
78     }
79
80     /**
81      * Gets the test document from the repository/test dir
82      */

83     public Document getDocument() {
84
85         try {
86             SAXBuilder builder = new SAXBuilder();
87             File JavaDoc file = new File JavaDoc(FileTools.convertPath("src/com/inversoft/verge/repository/test/test-config.xml"));
88             return builder.build(file);
89         } catch (Exception JavaDoc e) {
90             fail(e.toString());
91         }
92
93         return null;
94     }
95 }
96
Popular Tags