Browse Source

Update unit tests for URI changes

Change-Id: I0dd005540f126b40c4d7f61384236ec21cfe5730
Reviewed-on: http://gerrit.dmdirc.com/57
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
Tested-by: Chris Smith <chris@dmdirc.com>
tags/0.6.3b1
Chris Smith 14 years ago
parent
commit
32cf9f348f

+ 3
- 1
test/com/dmdirc/InviteTest.java View File

@@ -25,6 +25,7 @@ package com.dmdirc;
25 25
 import com.dmdirc.config.IdentityManager;
26 26
 import com.dmdirc.addons.ui_dummy.DummyController;
27 27
 
28
+import java.net.URI;
28 29
 import java.util.Date;
29 30
 
30 31
 import org.junit.BeforeClass;
@@ -42,7 +43,8 @@ public class InviteTest {
42 43
         Main.setUI(new DummyController());
43 44
         IdentityManager.load();
44 45
         
45
-        server = new Server("irc-test://255.255.255.255", IdentityManager.getProfiles().get(0));
46
+        server = new Server(new URI("irc-test://255.255.255.255"),
47
+                IdentityManager.getProfiles().get(0));
46 48
         server.connect();
47 49
         
48 50
         test = new Invite(server, "#channel", "nick!ident@host");

+ 5
- 4
test/com/dmdirc/ServerManagerTest.java View File

@@ -26,8 +26,9 @@ import com.dmdirc.config.IdentityManager;
26 26
 import com.dmdirc.addons.ui_dummy.DummyController;
27 27
 import com.dmdirc.addons.ui_dummy.DummyQueryWindow;
28 28
 import com.dmdirc.plugins.PluginManager;
29
-import com.dmdirc.util.InvalidAddressException;
30 29
 
30
+import java.net.URI;
31
+import java.net.URISyntaxException;
31 32
 import org.junit.After;
32 33
 import org.junit.BeforeClass;
33 34
 import org.junit.Test;
@@ -101,10 +102,10 @@ public class ServerManagerTest {
101 102
     }
102 103
     
103 104
     @Test
104
-    public void testGetServerFromFrame() throws InvalidAddressException {
105
-        final Server serverA = new Server("irc-test://255.255.255.255",
105
+    public void testGetServerFromFrame() throws URISyntaxException {
106
+        final Server serverA = new Server(new URI("irc-test://255.255.255.255"),
106 107
                 IdentityManager.getProfiles().get(0));
107
-        final Server serverB = new Server("irc-test://255.255.255.254",
108
+        final Server serverB = new Server(new URI("irc-test://255.255.255.254"),
108 109
                 IdentityManager.getProfiles().get(0));
109 110
         serverA.connect();
110 111
         serverB.connect();

+ 2
- 1
test/com/dmdirc/ServerTest.java View File

@@ -25,6 +25,7 @@ package com.dmdirc;
25 25
 import com.dmdirc.config.IdentityManager;
26 26
 import com.dmdirc.addons.ui_dummy.DummyController;
27 27
 
28
+import java.net.URI;
28 29
 import org.junit.BeforeClass;
29 30
 import org.junit.Test;
30 31
 import static org.junit.Assert.*;
@@ -37,7 +38,7 @@ public class ServerTest {
37 38
     public static void setUp() throws Exception {
38 39
         Main.setUI(new DummyController());
39 40
         IdentityManager.load();
40
-        server = new Server("irc-test://255.255.255.255",
41
+        server = new Server(new URI("irc-test://255.255.255.255"),
41 42
                 IdentityManager.getProfiles().get(0));
42 43
         server.connect();
43 44
     }

+ 2
- 1
test/com/dmdirc/addons/logging/LoggingPluginTest.java View File

@@ -34,6 +34,7 @@ import com.dmdirc.addons.ui_dummy.DummyController;
34 34
 import com.dmdirc.parser.irc.IRCParser;
35 35
 import com.dmdirc.util.ConfigFile;
36 36
 
37
+import java.net.URI;
37 38
 import java.util.Map;
38 39
 
39 40
 import org.junit.BeforeClass;
@@ -51,7 +52,7 @@ public class LoggingPluginTest {
51 52
     public static void setUp() throws Exception {
52 53
         Main.setUI(new DummyController());
53 54
         IdentityManager.load();
54
-        server = new Server("irc-test://255.255.255.255",
55
+        server = new Server(new URI("irc-test://255.255.255.255"),
55 56
                 IdentityManager.getProfiles().get(0));
56 57
         server.connect();
57 58
         

+ 10
- 10
test/com/dmdirc/commandparser/commands/server/ChangeServerTest.java View File

@@ -27,8 +27,8 @@ import com.dmdirc.config.Identity;
27 27
 import com.dmdirc.config.IdentityManager;
28 28
 import com.dmdirc.ui.interfaces.InputWindow;
29 29
 
30
-import com.dmdirc.util.InvalidAddressException;
31
-import com.dmdirc.util.IrcAddress;
30
+import java.net.URI;
31
+import java.net.URISyntaxException;
32 32
 import org.junit.BeforeClass;
33 33
 import org.junit.Test;
34 34
 import static org.mockito.Mockito.*;
@@ -75,7 +75,7 @@ public class ChangeServerTest {
75 75
     }
76 76
 
77 77
     @Test
78
-    public void testExecuteBasic() throws InvalidAddressException {
78
+    public void testExecuteBasic() throws URISyntaxException {
79 79
         final InputWindow tiw = mock(InputWindow.class);
80 80
         final Identity profile = mock(Identity.class);
81 81
         final Server server = mock(Server.class);
@@ -83,11 +83,11 @@ public class ChangeServerTest {
83 83
 
84 84
         command.execute(tiw, server, false, new CommandArguments("/server foo:1234"));
85 85
 
86
-        verify(server).connect(eq(new IrcAddress("foo", 1234, "", false)), same(profile));
86
+        verify(server).connect(eq(new URI("irc://foo:1234")), same(profile));
87 87
     }
88 88
 
89 89
     @Test
90
-    public void testExecuteNoPort() throws InvalidAddressException {
90
+    public void testExecuteNoPort() throws URISyntaxException {
91 91
         final InputWindow tiw = mock(InputWindow.class);
92 92
         final Identity profile = mock(Identity.class);
93 93
         final Server server = mock(Server.class);
@@ -95,11 +95,11 @@ public class ChangeServerTest {
95 95
 
96 96
         command.execute(tiw, server, false, new CommandArguments("/server foo"));
97 97
 
98
-        verify(server).connect(eq(new IrcAddress("foo", 6667, "", false)), same(profile));
98
+        verify(server).connect(eq(new URI("irc://foo:6667")), same(profile));
99 99
     }
100 100
 
101 101
     @Test
102
-    public void testDeprecatedSSL() throws InvalidAddressException {
102
+    public void testDeprecatedSSL() throws URISyntaxException {
103 103
         final InputWindow tiw = mock(InputWindow.class);
104 104
         final Identity profile = mock(Identity.class);
105 105
         final Server server = mock(Server.class);
@@ -107,11 +107,11 @@ public class ChangeServerTest {
107 107
 
108 108
         command.execute(tiw, server, false, new CommandArguments("/server --ssl foo"));
109 109
 
110
-        verify(server).connect(eq(new IrcAddress("foo", 6667, "", true)), same(profile));
110
+        verify(server).connect(eq(new URI("ircs://foo:6667")), same(profile));
111 111
     }
112 112
 
113 113
     @Test
114
-    public void testExecuteComplex() throws InvalidAddressException {
114
+    public void testExecuteComplex() throws URISyntaxException {
115 115
         final InputWindow tiw = mock(InputWindow.class);
116 116
         final Identity profile = mock(Identity.class);
117 117
         final Server server = mock(Server.class);
@@ -119,7 +119,7 @@ public class ChangeServerTest {
119 119
 
120 120
         command.execute(tiw, server, false, new CommandArguments("/server foo:+1234 password"));
121 121
 
122
-        verify(server).connect(eq(new IrcAddress("foo", 1234, "password", true)), same(profile));
122
+        verify(server).connect(eq(new URI("ircs://password@foo:1234")), same(profile));
123 123
     }
124 124
 
125 125
 }

+ 0
- 45
test/com/dmdirc/util/InvalidAddressExceptionTest.java View File

@@ -1,45 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-package com.dmdirc.util;
23
-
24
-import org.junit.Test;
25
-import static org.junit.Assert.*;
26
-
27
-public class InvalidAddressExceptionTest {
28
-
29
-    @Test
30
-    public void testMessage() {
31
-        final InvalidAddressException iae = new InvalidAddressException("message");
32
-        
33
-        assertEquals("message", iae.getMessage());
34
-    }
35
-    
36
-    @Test
37
-    public void testCause() {
38
-        final Exception e = new Exception("moo");
39
-        final InvalidAddressException iae = new InvalidAddressException("message",
40
-                e);
41
-        
42
-        assertEquals(e, iae.getCause());
43
-    }
44
-
45
-}

+ 0
- 165
test/com/dmdirc/util/IrcAddressTest.java View File

@@ -1,165 +0,0 @@
1
-/*
2
- * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
-package com.dmdirc.util;
24
-
25
-import com.dmdirc.Main;
26
-import com.dmdirc.ServerManager;
27
-import com.dmdirc.config.IdentityManager;
28
-import com.dmdirc.addons.ui_dummy.DummyController;
29
-import com.dmdirc.plugins.PluginManager;
30
-
31
-import org.junit.BeforeClass;
32
-import org.junit.Test;
33
-import static org.junit.Assert.*;
34
-
35
-public class IrcAddressTest {
36
-
37
-    @BeforeClass
38
-    public static void setUp() {
39
-        IdentityManager.load();
40
-        Main.setUI(new DummyController());
41
-        Main.ensureExists(PluginManager.getPluginManager(), "tabcompletion");
42
-    }
43
-
44
-    @Test(expected=InvalidAddressException.class)
45
-    public void testInvalidProtocol() throws InvalidAddressException {
46
-        new IrcAddress("http://moo!");
47
-    }
48
-
49
-    @Test(expected=InvalidAddressException.class)
50
-    public void testNoProtocol() throws InvalidAddressException {
51
-        new IrcAddress("moo!");
52
-    }
53
-    
54
-    @Test(expected=InvalidAddressException.class)
55
-    public void testInvalidURL() throws InvalidAddressException {
56
-        new IrcAddress(":");
57
-    }    
58
-
59
-    @Test
60
-    public void testBasic() throws InvalidAddressException {
61
-        final IrcAddress address = new IrcAddress("irc://servername");
62
-        assertEquals("irc", address.getProtocol());
63
-        assertEquals("servername", address.getServer());
64
-        assertEquals("", address.getPassword());
65
-        assertEquals(-1, address.getPort());
66
-        assertFalse(address.isSSL());
67
-    }
68
-
69
-    @Test
70
-    public void testPasswordSSL() throws InvalidAddressException {
71
-        final IrcAddress address = new IrcAddress("ircs://password@servername");
72
-        assertEquals("irc", address.getProtocol());
73
-        assertEquals("servername", address.getServer());
74
-        assertEquals("password", address.getPassword());
75
-        assertEquals(-1, address.getPort());
76
-        assertTrue(address.isSSL());
77
-    }
78
-
79
-    @Test
80
-    public void testPort() throws InvalidAddressException {
81
-        final IrcAddress address = new IrcAddress("irc://servername:7000/");
82
-        assertEquals("irc", address.getProtocol());
83
-        assertEquals("servername", address.getServer());
84
-        assertEquals("", address.getPassword());
85
-        assertEquals(7000, address.getPort());
86
-        assertFalse(address.isSSL());
87
-    }
88
-
89
-    @Test(expected=InvalidAddressException.class)
90
-    public void testInvalidPort() throws InvalidAddressException {
91
-        new IrcAddress("irc://servername:port/");
92
-    }
93
-
94
-    @Test
95
-    public void testPortSSL() throws InvalidAddressException {
96
-        final IrcAddress address = new IrcAddress("ircs://servername:+7000/");
97
-        assertEquals("irc", address.getProtocol());
98
-        assertEquals("servername", address.getServer());
99
-        assertEquals("", address.getPassword());
100
-        assertEquals(7000, address.getPort());
101
-        assertTrue(address.isSSL());
102
-    }
103
-
104
-    @Test
105
-    public void testComplex() throws InvalidAddressException {
106
-        final IrcAddress address = new IrcAddress("ircs://password@servername:+7000/c1,c2,c3");
107
-        assertEquals("irc", address.getProtocol());
108
-        assertEquals("servername", address.getServer());
109
-        assertEquals("password", address.getPassword());
110
-        assertEquals(7000, address.getPort());
111
-        assertEquals(3, address.getChannels().size());
112
-        assertTrue(address.isSSL());
113
-    }
114
-
115
-    @Test
116
-    public void testConnect() throws InvalidAddressException {
117
-        final IrcAddress address = new IrcAddress("irc://255.255.255.205/a,b,c");
118
-
119
-        int initial = ServerManager.getServerManager().numServers();
120
-
121
-        address.connect();
122
-
123
-        assertEquals(initial + 1, ServerManager.getServerManager().numServers());
124
-
125
-        address.connect();
126
-
127
-        assertEquals(initial + 1, ServerManager.getServerManager().numServers());
128
-    }
129
-
130
-    @Test
131
-    public void testReservedChanNames() throws InvalidAddressException {
132
-        final IrcAddress address1 = new IrcAddress("irc://server/,needpass");
133
-        assertEquals(0, address1.getChannels().size());
134
-
135
-        final IrcAddress address2 = new IrcAddress("irc://server/MDbot,needkey");
136
-        assertEquals(1, address2.getChannels().size());
137
-        assertEquals("MDbot", address2.getChannels().get(0));
138
-
139
-        final IrcAddress address3 = new IrcAddress("irc://server/MDbot,isnick");
140
-        assertEquals(1, address3.getChannels().size());
141
-        assertEquals("MDbot", address3.getChannels().get(0));
142
-    }
143
-
144
-    @Test
145
-    public void testChannels() throws InvalidAddressException {
146
-        final IrcAddress address3 = new IrcAddress("irc://server/#MDbot");
147
-        assertEquals(1, address3.getChannels().size());
148
-        assertEquals("#MDbot", address3.getChannels().get(0));
149
-    }
150
-    
151
-    @Test
152
-    public void testChannelsQuery() throws InvalidAddressException {
153
-        final IrcAddress address3 = new IrcAddress("irc://server/MDbot?moo");
154
-        assertEquals(1, address3.getChannels().size());
155
-        assertEquals("MDbot?moo", address3.getChannels().get(0));
156
-    }    
157
-
158
-    @Test
159
-    public void testEncoding() throws InvalidAddressException {
160
-        final IrcAddress address1 = new IrcAddress("irc://server/%23DMDirc");
161
-        assertEquals(1, address1.getChannels().size());
162
-        assertEquals("#DMDirc", address1.getChannels().get(0));
163
-    }
164
-
165
-}

Loading…
Cancel
Save