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