001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.edl;
018:
019: import java.util.Map;
020:
021: import org.junit.Test;
022: import org.kuali.rice.config.Config;
023: import org.kuali.rice.core.Core;
024: import org.kuali.workflow.test.WorkflowTestCase;
025: import org.springframework.mock.web.MockHttpServletRequest;
026: import org.w3c.dom.Element;
027:
028: import edu.iu.uis.eden.KEWServiceLocator;
029:
030: public class EDLControllerTest extends WorkflowTestCase {
031:
032: protected void loadTestData() throws Exception {
033: super .loadXmlFile("widgets.xml");
034: super .loadXmlFile("edlstyle.xml");
035: super .loadXmlFile("FakeyEDL.xml");
036: }
037:
038: @Test
039: public void testEDLControllerCreation() throws Exception {
040: Core.getCurrentContextConfig().overrideProperty(
041: Config.EDL_CONFIG_LOCATION,
042: "classpath:edu/iu/uis/eden/edl/TestEDLConfig.xml");
043:
044: EDLController edlController = getEDLService().getEDLController(
045: "FakeyEDL");
046: edlController.setEdlContext(getEDLcontext());
047: assertNotNull(
048: "There should be a default dom in the edlcontoller",
049: edlController.getDefaultDOM());
050: edlController.notifyComponents();
051:
052: assertTrue("PreProcess component should have been notified",
053: TestPreProcessor.isContacted());
054: assertTrue("PostProcessor component should have been notified",
055: TestPostProcessor.isContacted());
056: assertTrue("State component should have been notified",
057: TestStateComponent.isContacted());
058: assertTrue("ConfigProcess component should have been notified",
059: TestConfigProcessor.isContacted());
060:
061: //make sure they all have the correct config element passed in
062: Element preProcessorConfigElement = (Element) ((Map.Entry) edlController
063: .getEdlGlobalConfig().getPreProcessors().entrySet()
064: .iterator().next()).getKey();
065: assertEquals(
066: "PreProcessor config element is of the wrong class",
067: "edu.iu.uis.eden.edl.TestPreProcessor",
068: preProcessorConfigElement.getFirstChild()
069: .getNodeValue());
070:
071: Element postProcessorConfigElement = (Element) ((Map.Entry) edlController
072: .getEdlGlobalConfig().getPostProcessors().entrySet()
073: .iterator().next()).getKey();
074: assertEquals(
075: "PostProcessor config element is of the wrong class",
076: "edu.iu.uis.eden.edl.TestPostProcessor",
077: postProcessorConfigElement.getFirstChild()
078: .getNodeValue());
079:
080: Element stateConfigElement = (Element) ((Map.Entry) edlController
081: .getEdlGlobalConfig().getStateComponents().entrySet()
082: .iterator().next()).getKey();
083: assertEquals("State config element is of the wrong class",
084: "edu.iu.uis.eden.edl.TestStateComponent",
085: stateConfigElement.getFirstChild().getNodeValue());
086:
087: Element configProcessorConfigElement = (Element) ((Map.Entry) edlController
088: .getConfigProcessors().entrySet().iterator().next())
089: .getKey();
090: assertEquals("Config processor element should be fielDef",
091: "fieldDef", configProcessorConfigElement.getNodeName());
092:
093: }
094:
095: private EDLContext getEDLcontext() {
096: EDLContext edlContext = new EDLContext();
097: edlContext.setRequestParser(new RequestParser(
098: new MockHttpServletRequest()));
099: return edlContext;
100: }
101:
102: private EDocLiteService getEDLService() {
103: return (EDocLiteService) KEWServiceLocator.getEDocLiteService();
104: }
105:
106: }
|