瀏覽代碼

PluginInfo unit tests

git-svn-id: http://svn.dmdirc.com/trunk@4241 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 年之前
父節點
當前提交
565e6c7f67
共有 2 個文件被更改,包括 53 次插入12 次删除
  1. 53
    12
      test/com/dmdirc/plugins/PluginInfoTest.java
  2. 二進制
      test/com/dmdirc/plugins/testplugin.jar

+ 53
- 12
test/com/dmdirc/plugins/PluginInfoTest.java 查看文件

19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
  * SOFTWARE.
20
  * SOFTWARE.
21
  */
21
  */
22
+
22
 package com.dmdirc.plugins;
23
 package com.dmdirc.plugins;
23
 
24
 
25
+import com.dmdirc.Main;
26
+
27
+import java.io.File;
28
+import java.io.IOException;
29
+
30
+import org.junit.Ignore;
24
 import org.junit.Test;
31
 import org.junit.Test;
25
 import static org.junit.Assert.*;
32
 import static org.junit.Assert.*;
26
 
33
 
27
-public class PluginInfoTest extends junit.framework.TestCase {
34
+public class PluginInfoTest {
28
     
35
     
29
     private PluginInfo pi;
36
     private PluginInfo pi;
30
-    
31
-    public PluginInfoTest() {
32
-        try {
33
-            pi = new PluginInfo("moo", false);
34
-        } catch (PluginException ex) {
35
-            // Shouldn't happen
36
-        }
37
-    }
38
 
37
 
39
     @Test
38
     @Test
40
-    public void testCheckMinimum() {
39
+    public void testCheckMinimum() throws PluginException {
40
+        pi = new PluginInfo("moo", false);
41
+        
41
         assertTrue(pi.checkMinimumVersion("5", 6));
42
         assertTrue(pi.checkMinimumVersion("5", 6));
42
         assertTrue(pi.checkMinimumVersion("5", 5));
43
         assertTrue(pi.checkMinimumVersion("5", 5));
43
         assertTrue(pi.checkMinimumVersion("0", 17));
44
         assertTrue(pi.checkMinimumVersion("0", 17));
48
     }
49
     }
49
     
50
     
50
     @Test
51
     @Test
51
-    public void testCheckMaximim() {
52
+    public void testCheckMaximim() throws PluginException {
53
+        pi = new PluginInfo("moo", false);
54
+        
52
         assertTrue(pi.checkMaximumVersion("6", 6));
55
         assertTrue(pi.checkMaximumVersion("6", 6));
53
         assertTrue(pi.checkMaximumVersion("7", 6));
56
         assertTrue(pi.checkMaximumVersion("7", 6));
54
         assertTrue(pi.checkMaximumVersion("0", 6));
57
         assertTrue(pi.checkMaximumVersion("0", 6));
60
     }
63
     }
61
     
64
     
62
     @Test
65
     @Test
63
-    public void testOS() {
66
+    public void testOS() throws PluginException {
67
+        pi = new PluginInfo("moo", false);
68
+        
64
         assertTrue(pi.checkOS("windows", "windows", "xp", "x86"));
69
         assertTrue(pi.checkOS("windows", "windows", "xp", "x86"));
65
         assertFalse(pi.checkOS("windows", "linux", "2.6.2.11", "x86"));
70
         assertFalse(pi.checkOS("windows", "linux", "2.6.2.11", "x86"));
66
         assertTrue(pi.checkOS("windows:xp|98|3\\.1", "windows", "xp", "x86"));
71
         assertTrue(pi.checkOS("windows:xp|98|3\\.1", "windows", "xp", "x86"));
71
         assertFalse(pi.checkOS("windows:xp|98|3\\.1:.86", "windows", "vista", "x86"));
76
         assertFalse(pi.checkOS("windows:xp|98|3\\.1:.86", "windows", "vista", "x86"));
72
         assertFalse(pi.checkOS("windows:xp|98|3\\.1:.86", "linux", "2.6.2.11", "x86"));        
77
         assertFalse(pi.checkOS("windows:xp|98|3\\.1:.86", "linux", "2.6.2.11", "x86"));        
73
     }
78
     }
79
+    
80
+    @Test
81
+    public void testLoad() throws PluginException {
82
+        Main.setConfigDir(new File(getClass().getResource("testplugin.jar").getFile()).getParent());
83
+        PluginInfo pi = new PluginInfo("testplugin.jar");
84
+        assertEquals("Author <em@il>", pi.getAuthor());
85
+        assertEquals("Friendly", pi.getFriendlyVersion());
86
+        assertEquals("Description goes here", pi.getDescription());
87
+        assertEquals("randomname", pi.getName());
88
+        assertEquals("Friendly name", pi.getNiceName());
89
+        assertEquals(3, pi.getVersion());
90
+    }
91
+    
92
+    @Test @Ignore
93
+    public void testUpdate() throws PluginException, IOException {
94
+        final File dir = new File(File.createTempFile("dmdirc-plugin-test", null).getParentFile(),
95
+                "dmdirc-plugin-test-folder");
96
+        final File pluginDir = new File(dir, "plugins");
97
+        
98
+        dir.deleteOnExit();
99
+        pluginDir.mkdirs();
100
+        
101
+        new File(pluginDir, "test.jar").createNewFile();
102
+        new File(pluginDir, "test.jar.update").createNewFile();
103
+        
104
+        Main.setConfigDir(dir.getAbsolutePath());
105
+        System.out.println(Main.getConfigDir());
106
+        System.out.println(PluginManager.getPluginManager().getDirectory());
107
+        new PluginInfo("test.jar", false);
108
+        
109
+        assertTrue(new File(pluginDir, "test.jar").exists());
110
+        assertFalse(new File(pluginDir, "test.jar.update").exists());
111
+    }
74
 
112
 
113
+    public static junit.framework.Test suite() {
114
+        return new junit.framework.JUnit4TestAdapter(PluginInfoTest.class);
115
+    }
75
 }
116
 }

二進制
test/com/dmdirc/plugins/testplugin.jar 查看文件


Loading…
取消
儲存