01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.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.workflow.test.WorkflowTestCase;
26: import org.w3c.dom.Document;
27: import org.w3c.dom.Node;
28: import org.w3c.dom.NodeList;
29:
30: import edu.iu.uis.eden.test.TestUtilities;
31:
32: public class EDLGlobalConfigFactoryTest extends WorkflowTestCase {
33:
34: /**
35: * Test a positive case global parsing..
36: *
37: * @throws Exception
38: */
39: @Test
40: public void testEDLGlobalConfigParsing() throws Exception {
41:
42: EDLGlobalConfig edlGlobalConfig = EDLGlobalConfigFactory
43: .createEDLGlobalConfig("classpath:edu/iu/uis/eden/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
49: .getClass(), "FakeyEDL.xml");
50: Document doc = DocumentBuilderFactory.newInstance()
51: .newDocumentBuilder().parse(fakeyEDL);
52:
53: Object configProcessorInst = null;
54: NodeList edlDefinitionNodes = doc
55: .getElementsByTagName("fieldDef");
56: for (int i = 0; i < edlDefinitionNodes.getLength(); i++) {
57: Node definitionNode = edlDefinitionNodes.item(i);
58: Class configClass = (Class) edlGlobalConfig
59: .getConfigProcessor(definitionNode);
60: if (configClass != null) {
61: configProcessorInst = configClass.newInstance();
62: }
63:
64: }
65:
66: assertTrue("should be 1 preProcessor",
67: preProcessors.size() == 1);
68: assertTrue("should be 1 postProcessor",
69: postProcessors.size() == 1);
70: assertTrue("should be 1 stateComps", stateComps.size() == 1);
71: assertTrue("Object made from config proces, arg1",
72: configProcessorInst instanceof TestConfigProcessor);
73:
74: }
75:
76: }
|