|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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) | |||
| Result | |||
|
0.26666668
|
net.sourceforge.pebble.plugins.TestPluginLocator.testNoType
net.sourceforge.pebble.plugins.TestPluginLocator.testNoType
|
1 PASS | |
|
0.26666668
|
net.sourceforge.pebble.plugins.TestPluginLocator.testNoType
net.sourceforge.pebble.plugins.TestPluginLocator.testNoType
|
1 PASS | |
|
0.24444444
|
net.sourceforge.pebble.plugins.TestPluginLocator.testUnweighted
net.sourceforge.pebble.plugins.TestPluginLocator.testUnweighted
|
1 PASS | |
|
0.24444444
|
net.sourceforge.pebble.plugins.TestPluginLocator.testUnweighted
net.sourceforge.pebble.plugins.TestPluginLocator.testUnweighted
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testWeighted
net.sourceforge.pebble.plugins.TestPluginLocator.testWeighted
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testWeighted
net.sourceforge.pebble.plugins.TestPluginLocator.testWeighted
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testRequired
net.sourceforge.pebble.plugins.TestPluginLocator.testRequired
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testTextAreaType
net.sourceforge.pebble.plugins.TestPluginLocator.testTextAreaType
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testPasswordType
net.sourceforge.pebble.plugins.TestPluginLocator.testPasswordType
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testTextAreaType
net.sourceforge.pebble.plugins.TestPluginLocator.testTextAreaType
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testPasswordType
net.sourceforge.pebble.plugins.TestPluginLocator.testPasswordType
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testProperty
net.sourceforge.pebble.plugins.TestPluginLocator.testProperty
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testRequired
net.sourceforge.pebble.plugins.TestPluginLocator.testRequired
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testProperty
net.sourceforge.pebble.plugins.TestPluginLocator.testProperty
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testStringType
net.sourceforge.pebble.plugins.TestPluginLocator.testStringType
|
1 PASS | |
|
0.15555556
|
net.sourceforge.pebble.plugins.TestPluginLocator.testStringType
net.sourceforge.pebble.plugins.TestPluginLocator.testStringType
|
1 PASS | |
|
0.06666667
|
net.sourceforge.pebble.plugins.TestPluginLocator.testDescription
net.sourceforge.pebble.plugins.TestPluginLocator.testDescription
|
1 PASS | |
|
0.06666667
|
net.sourceforge.pebble.plugins.TestPluginLocator.testDescription
net.sourceforge.pebble.plugins.TestPluginLocator.testDescription
|
1 PASS | |
| 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 |
@Override |
| 18 | protected void setUp() throws Exception { | |
| 19 | 18 | plugins = new HashMap<String, List<Plugin>>(); |
| 20 | } | |
| 21 | ||
| 22 | 2 |
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 |
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 |
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 |
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 |
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 |
public void testStringType() { |
| 66 | 2 | assertSame(PlainTextPluginConfigType.INSTANCE, getConfig(1).getType()); |
| 67 | } | |
| 68 | ||
| 69 | 2 |
public void testPasswordType() { |
| 70 | 2 | assertSame(PasswordPluginConfigType.INSTANCE, getConfig(2).getType()); |
| 71 | } | |
| 72 | ||
| 73 | 2 |
public void testTextAreaType() { |
| 74 | 2 | assertSame(TextAreaPluginConfigType.INSTANCE, getConfig(3).getType()); |
| 75 | } | |
| 76 | ||
| 77 | 2 |
public void testRequired() { |
| 78 | 2 | assertTrue(getConfig(4).isRequried()); |
| 79 | } | |
| 80 | ||
| 81 | 2 |
public void testProperty() { |
| 82 | 2 | assertEquals("value", getConfig(5).getProperties().get("property")); |
| 83 | } | |
| 84 | ||
| 85 | } | |
|
||||||||||||