[511] | 1 | package de.ugoe.cs.quest.plugin; |
---|
| 2 | |
---|
| 3 | import java.io.File; |
---|
| 4 | |
---|
| 5 | import junitx.framework.ArrayAssert; |
---|
| 6 | |
---|
| 7 | import org.junit.*; |
---|
| 8 | import static org.junit.Assert.*; |
---|
| 9 | |
---|
| 10 | /** |
---|
| 11 | * The class <code>PluginLoaderTest</code> contains tests for the class |
---|
| 12 | * <code>{@link PluginLoader}</code>. |
---|
| 13 | * |
---|
| 14 | * @author Steffen Herbold |
---|
| 15 | * @version 1.0 |
---|
| 16 | */ |
---|
| 17 | public class PluginLoaderTest { |
---|
| 18 | |
---|
| 19 | @Test |
---|
| 20 | public void testPluginLoader_1() throws Exception { |
---|
| 21 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 22 | assertNotNull(loader); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | @Test(expected = java.security.InvalidParameterException.class) |
---|
| 26 | public void testPluginLoader_2() throws Exception { |
---|
| 27 | new PluginLoader(null); |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | @Test(expected = java.security.InvalidParameterException.class) |
---|
| 31 | public void testPluginLoader_3() throws Exception { |
---|
| 32 | new PluginLoader(new File("testdata/de.ugoe.cs.quest.plugin.PluginLoaderTest/jfcmonitor.jar")); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | @Test |
---|
| 36 | public void testCheckNameConformity_1() throws Exception { |
---|
| 37 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 38 | String filename = "quest-plugin-jfc-1.0.jar"; |
---|
| 39 | boolean expected = true; |
---|
| 40 | |
---|
| 41 | boolean result = loader.checkNameConformity(filename); |
---|
| 42 | |
---|
| 43 | assertEquals(expected, result); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | @Test |
---|
| 47 | public void testCheckNameConformity_2() throws Exception { |
---|
| 48 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 49 | String filename = "quest-plugin-jf-c-1.0.jar"; |
---|
| 50 | boolean expected = false; |
---|
| 51 | |
---|
| 52 | boolean result = loader.checkNameConformity(filename); |
---|
| 53 | |
---|
| 54 | assertEquals(expected, result); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | @Test |
---|
| 58 | public void testCheckNameConformity_3() throws Exception { |
---|
| 59 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 60 | String filename = "quest-plugin-jfc.jar"; |
---|
| 61 | boolean expected = false; |
---|
| 62 | |
---|
| 63 | boolean result = loader.checkNameConformity(filename); |
---|
| 64 | |
---|
| 65 | assertEquals(expected, result); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | @Test |
---|
| 69 | public void testCheckNameConformity_4() throws Exception { |
---|
| 70 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 71 | String filename = "quest-plugi-jfc-1.0.jar"; |
---|
| 72 | boolean expected = false; |
---|
| 73 | |
---|
| 74 | boolean result = loader.checkNameConformity(filename); |
---|
| 75 | |
---|
| 76 | assertEquals(expected, result); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | @Test |
---|
| 80 | public void testCheckNameConformity_5() throws Exception { |
---|
| 81 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 82 | String filename = "quest-pluginjfc-1.0.jar"; |
---|
| 83 | boolean expected = false; |
---|
| 84 | |
---|
| 85 | boolean result = loader.checkNameConformity(filename); |
---|
| 86 | |
---|
| 87 | assertEquals(expected, result); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | @Test |
---|
| 91 | public void testCheckNameConformity_6() throws Exception { |
---|
| 92 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 93 | String filename = "quest-plugin-jfc-1-0.jar"; |
---|
| 94 | boolean expected = false; |
---|
| 95 | |
---|
| 96 | boolean result = loader.checkNameConformity(filename); |
---|
| 97 | |
---|
| 98 | assertEquals(expected, result); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | @Test |
---|
| 102 | public void testCheckNameConformity_7() throws Exception { |
---|
| 103 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 104 | String filename = "quest-plugin-jfc-1.0.nojar"; |
---|
| 105 | boolean expected = false; |
---|
| 106 | |
---|
| 107 | boolean result = loader.checkNameConformity(filename); |
---|
| 108 | |
---|
| 109 | assertEquals(expected, result); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | @Test |
---|
| 113 | public void testCheckNameConformity_8() throws Exception { |
---|
| 114 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 115 | String filename = null; |
---|
| 116 | boolean expected = false; |
---|
| 117 | |
---|
| 118 | boolean result = loader.checkNameConformity(filename); |
---|
| 119 | |
---|
| 120 | assertEquals(expected, result); |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | @Test |
---|
| 124 | public void testCheckNameConformity_9() throws Exception { |
---|
| 125 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 126 | String filename = ""; |
---|
| 127 | boolean expected = false; |
---|
| 128 | |
---|
| 129 | boolean result = loader.checkNameConformity(filename); |
---|
| 130 | |
---|
| 131 | assertEquals(expected, result); |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | @Test |
---|
| 135 | public void testGetClassPathFromJar_1() throws Exception { |
---|
| 136 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 137 | File jarFile = new File("testdata/de.ugoe.cs.quest.plugin.PluginLoaderTest/jfcmonitor.jar"); |
---|
| 138 | |
---|
| 139 | String[] expected = new String[]{ "file:" + jarFile.getParentFile().getAbsolutePath()+"/javahelperlib.jar" }; |
---|
| 140 | |
---|
| 141 | String[] result = loader.getClassPathFromJar(jarFile); |
---|
| 142 | |
---|
| 143 | ArrayAssert.assertEquivalenceArrays(expected, result); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | @Test |
---|
| 147 | public void testGetClassPathFromJar_2() throws Exception { |
---|
| 148 | PluginLoader loader = new PluginLoader(new File(".")); |
---|
| 149 | File jarFile = new File("testdata/de.ugoe.cs.quest.plugin.PluginLoaderTest/jmi.jar"); |
---|
| 150 | |
---|
| 151 | String[] expected = new String[]{ }; |
---|
| 152 | |
---|
| 153 | String[] result = loader.getClassPathFromJar(jarFile); |
---|
| 154 | |
---|
| 155 | ArrayAssert.assertEquivalenceArrays(expected, result); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | } |
---|