Browse Source

PluginInfo unit tests

git-svn-id: http://svn.dmdirc.com/trunk@4241 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 years ago
parent
commit
565e6c7f67
2 changed files with 53 additions and 12 deletions
  1. 53
    12
      test/com/dmdirc/plugins/PluginInfoTest.java
  2. BIN
      test/com/dmdirc/plugins/testplugin.jar

+ 53
- 12
test/com/dmdirc/plugins/PluginInfoTest.java View File

@@ -19,25 +19,26 @@
19 19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 20
  * SOFTWARE.
21 21
  */
22
+
22 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 31
 import org.junit.Test;
25 32
 import static org.junit.Assert.*;
26 33
 
27
-public class PluginInfoTest extends junit.framework.TestCase {
34
+public class PluginInfoTest {
28 35
     
29 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 38
     @Test
40
-    public void testCheckMinimum() {
39
+    public void testCheckMinimum() throws PluginException {
40
+        pi = new PluginInfo("moo", false);
41
+        
41 42
         assertTrue(pi.checkMinimumVersion("5", 6));
42 43
         assertTrue(pi.checkMinimumVersion("5", 5));
43 44
         assertTrue(pi.checkMinimumVersion("0", 17));
@@ -48,7 +49,9 @@ public class PluginInfoTest extends junit.framework.TestCase {
48 49
     }
49 50
     
50 51
     @Test
51
-    public void testCheckMaximim() {
52
+    public void testCheckMaximim() throws PluginException {
53
+        pi = new PluginInfo("moo", false);
54
+        
52 55
         assertTrue(pi.checkMaximumVersion("6", 6));
53 56
         assertTrue(pi.checkMaximumVersion("7", 6));
54 57
         assertTrue(pi.checkMaximumVersion("0", 6));
@@ -60,7 +63,9 @@ public class PluginInfoTest extends junit.framework.TestCase {
60 63
     }
61 64
     
62 65
     @Test
63
-    public void testOS() {
66
+    public void testOS() throws PluginException {
67
+        pi = new PluginInfo("moo", false);
68
+        
64 69
         assertTrue(pi.checkOS("windows", "windows", "xp", "x86"));
65 70
         assertFalse(pi.checkOS("windows", "linux", "2.6.2.11", "x86"));
66 71
         assertTrue(pi.checkOS("windows:xp|98|3\\.1", "windows", "xp", "x86"));
@@ -71,5 +76,41 @@ public class PluginInfoTest extends junit.framework.TestCase {
71 76
         assertFalse(pi.checkOS("windows:xp|98|3\\.1:.86", "windows", "vista", "x86"));
72 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
 }

BIN
test/com/dmdirc/plugins/testplugin.jar View File


Loading…
Cancel
Save