Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
34   85   11   3,09
0   67   0,32   11
11     1  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  TestPluginLocator       Line # 13 34 0% 11 0 100% 1.0
 
  (18)
 
1    package net.sourceforge.pebble.plugins;
2   
3    import junit.framework.TestCase;
4   
5    import java.net.URL;
6    import java.util.HashMap;
7    import java.util.List;
8    import java.util.Map;
9   
10    /**
11    * @author James Roper
12    */
 
13    public class TestPluginLocator extends TestCase {
14    private Map<String, List<Plugin>> plugins;
15    private URL testPlugins = this.getClass().getResource("/test-plugins.xml");
16   
 
17  18 toggle @Override
18    protected void setUp() throws Exception {
19  18 plugins = new HashMap<String, List<Plugin>>();
20    }
21   
 
22  2 toggle public void testUnweighted() {
23  2 PluginLocator.installPlugins(plugins, testPlugins);
24  2 List<Plugin> ps = plugins.get("plugin-type");
25  2 assertEquals(2, ps.size());
26  2 Plugin plugin = ps.get(0);
27  2 assertEquals("Unweighted", plugin.getName());
28  2 assertEquals(100, plugin.getWeight());
29  2 assertEquals("java.util.ArrayList", plugin.getPluginClass());
30  2 assertNull(plugin.getDescription());
31  2 assertFalse(plugin.isConfigurable());
32  2 assertEquals(0, plugin.getPluginConfig().size());
33    }
34   
 
35  2 toggle public void testWeighted() {
36  2 PluginLocator.installPlugins(plugins, testPlugins);
37  2 List<Plugin> ps = plugins.get("plugin-type");
38  2 assertEquals(2, ps.size());
39  2 Plugin plugin = ps.get(1);
40  2 assertEquals("Weighted", plugin.getName());
41  2 assertEquals(20, plugin.getWeight());
42    }
43   
 
44  2 toggle public void testDescription() {
45  2 PluginLocator.installPlugins(plugins, testPlugins);
46  2 assertEquals("My description", plugins.get("description-plugin-type").get(0).getDescription());
47    }
48   
 
49  12 toggle private PluginConfig getConfig(int index) {
50  12 PluginLocator.installPlugins(plugins, testPlugins);
51  12 Plugin plugin = plugins.get("configured-plugin-type").get(0);
52  12 assertTrue(plugin.isConfigurable());
53  12 return ((List<PluginConfig>) plugin.getPluginConfig()).get(index);
54    }
55   
 
56  2 toggle public void testNoType() {
57  2 PluginConfig config = getConfig(0);
58  2 assertEquals("No type", config.getName());
59  2 assertEquals("notype", config.getKey());
60  2 assertSame(PlainTextPluginConfigType.INSTANCE, config.getType());
61  2 assertTrue(config.getProperties().isEmpty());
62  2 assertFalse(config.isRequried());
63    }
64   
 
65  2 toggle public void testStringType() {
66  2 assertSame(PlainTextPluginConfigType.INSTANCE, getConfig(1).getType());
67    }
68   
 
69  2 toggle public void testPasswordType() {
70  2 assertSame(PasswordPluginConfigType.INSTANCE, getConfig(2).getType());
71    }
72   
 
73  2 toggle public void testTextAreaType() {
74  2 assertSame(TextAreaPluginConfigType.INSTANCE, getConfig(3).getType());
75    }
76   
 
77  2 toggle public void testRequired() {
78  2 assertTrue(getConfig(4).isRequried());
79    }
80   
 
81  2 toggle public void testProperty() {
82  2 assertEquals("value", getConfig(5).getProperties().get("property"));
83    }
84   
85    }