View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.plugin;
17  
18  import org.junit.Test;
19  import org.kuali.rice.core.api.config.property.ConfigContext;
20  import org.kuali.rice.core.api.util.ClasspathOrFileResourceLoader;
21  import org.kuali.rice.core.framework.resourceloader.BaseResourceLoader;
22  import org.kuali.rice.kew.test.KEWTestCase;
23  
24  import java.util.List;
25  
26  import static org.junit.Assert.assertEquals;
27  import static org.junit.Assert.assertNotNull;
28  
29  /**
30   * Tests that the PluginConfigParser properly parses the plugin config xml file.
31   * 
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class PluginConfigParserTest extends KEWTestCase {
35  
36      private PluginConfigParser parser = new PluginConfigParser();
37      private static final String CONFIG_PATH = "classpath:org/kuali/rice/kew/plugin/workflow.xml";
38      
39      @Test public void testParse() throws Exception {
40      	
41          PluginConfig plugin = parser.parse(new ClasspathOrFileResourceLoader().getResource(CONFIG_PATH).getFile(), ConfigContext.getCurrentContextConfig());
42          assertNotNull(plugin);
43  
44          List listeners = plugin.getListeners();
45          assertNotNull(listeners);
46          assertEquals(2, listeners.size());
47          String listenerClassName1 = (String)listeners.get(0);
48          String listenerClassName2 = (String)listeners.get(1);
49          assertEquals("org.kuali.rice.kew.plugin.TestPluginListener", listenerClassName1);
50          assertEquals("org.kuali.rice.kew.plugin.TestPluginListener2", listenerClassName2);
51  
52          assertEquals("Plugin resource loader classname should be base resource loader", BaseResourceLoader.class.getName(), plugin.getResourceLoaderClassname());
53      }
54  
55  }