1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.edl;
18
19 import java.io.InputStream;
20 import java.util.Map;
21
22 import javax.xml.parsers.DocumentBuilderFactory;
23
24 import org.junit.Test;
25 import org.kuali.rice.kew.edl.EDLGlobalConfig;
26 import org.kuali.rice.kew.edl.EDLGlobalConfigFactory;
27 import org.kuali.rice.kew.test.KEWTestCase;
28 import org.kuali.rice.kew.test.TestUtilities;
29 import org.w3c.dom.Document;
30 import org.w3c.dom.Node;
31 import org.w3c.dom.NodeList;
32
33
34 public class EDLGlobalConfigFactoryTest extends KEWTestCase {
35
36
37
38
39
40
41 @Test public void testEDLGlobalConfigParsing() throws Exception {
42
43 EDLGlobalConfig edlGlobalConfig = EDLGlobalConfigFactory.createEDLGlobalConfig("classpath:org/kuali/rice/kew/edl/TestEDLConfig.xml");
44 Map preProcessors = edlGlobalConfig.getPreProcessors();
45 Map postProcessors = edlGlobalConfig.getPostProcessors();
46 Map stateComps = edlGlobalConfig.getStateComponents();
47
48 InputStream fakeyEDL = TestUtilities.loadResource(this.getClass(), "FakeyEDL.xml");
49 Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(fakeyEDL);
50
51 Object configProcessorInst = null;
52 NodeList edlDefinitionNodes = doc.getElementsByTagName("fieldDef");
53 for (int i = 0; i < edlDefinitionNodes.getLength(); i++) {
54 Node definitionNode = edlDefinitionNodes.item(i);
55 Class configClass = (Class)edlGlobalConfig.getConfigProcessor(definitionNode);
56 if (configClass != null) {
57 configProcessorInst = configClass.newInstance();
58 }
59
60 }
61
62 assertTrue("should be 1 preProcessor", preProcessors.size() == 1);
63 assertTrue("should be 1 postProcessor", postProcessors.size() == 1);
64 assertTrue("should be 1 stateComps", stateComps.size() == 1);
65 assertTrue("Object made from config proces, arg1", configProcessorInst instanceof TestConfigProcessor);
66
67 }
68
69
70 }