001/**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.plugin;
017
018import org.junit.Test;
019import org.kuali.rice.core.api.config.property.ConfigContext;
020import org.kuali.rice.core.api.util.ClasspathOrFileResourceLoader;
021import org.kuali.rice.core.framework.resourceloader.BaseResourceLoader;
022import org.kuali.rice.kew.test.KEWTestCase;
023
024import java.util.List;
025
026import static org.junit.Assert.assertEquals;
027import static org.junit.Assert.assertNotNull;
028
029/**
030 * Tests that the PluginConfigParser properly parses the plugin config xml file.
031 * 
032 * @author Kuali Rice Team (rice.collab@kuali.org)
033 */
034public class PluginConfigParserTest extends KEWTestCase {
035
036    private PluginConfigParser parser = new PluginConfigParser();
037    private static final String CONFIG_PATH = "classpath:org/kuali/rice/kew/plugin/workflow.xml";
038    
039    @Test public void testParse() throws Exception {
040        
041        PluginConfig plugin = parser.parse(new ClasspathOrFileResourceLoader().getResource(CONFIG_PATH).getFile(), ConfigContext.getCurrentContextConfig());
042        assertNotNull(plugin);
043
044        List listeners = plugin.getListeners();
045        assertNotNull(listeners);
046        assertEquals(2, listeners.size());
047        String listenerClassName1 = (String)listeners.get(0);
048        String listenerClassName2 = (String)listeners.get(1);
049        assertEquals("org.kuali.rice.kew.plugin.TestPluginListener", listenerClassName1);
050        assertEquals("org.kuali.rice.kew.plugin.TestPluginListener2", listenerClassName2);
051
052        assertEquals("Plugin resource loader classname should be base resource loader", BaseResourceLoader.class.getName(), plugin.getResourceLoaderClassname());
053    }
054
055}