Selaa lähdekoodia

Unit test changes

Move parser test harness to parser module

Change-Id: Ic4003a54acfcadd2c0a52978bb3e4acd5c91dedd
Reviewed-on: http://gerrit.dmdirc.com/455
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
Tested-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3
Chris Smith 14 vuotta sitten
vanhempi
commit
e749bc70ff

+ 44
- 0
test/com/dmdirc/harness/parser/TestIChannelPart.java Näytä tiedosto

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.interfaces.callbacks.ChannelPartListener;
29
+
30
+public class TestIChannelPart implements ChannelPartListener {
31
+
32
+    public ChannelInfo channel;
33
+
34
+    public ChannelClientInfo cclient;
35
+
36
+    public String reason;
37
+
38
+    public void onChannelPart(Parser tParser, ChannelInfo cChannel,
39
+                              ChannelClientInfo cChannelClient, String sReason) {
40
+        channel = cChannel;
41
+        cclient = cChannelClient;
42
+        reason = sReason;
43
+    }
44
+}

+ 36
- 0
test/com/dmdirc/harness/parser/TestIChannelSelfJoin.java Näytä tiedosto

@@ -0,0 +1,36 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+import com.dmdirc.parser.interfaces.callbacks.ChannelSelfJoinListener;
28
+
29
+public class TestIChannelSelfJoin implements ChannelSelfJoinListener {
30
+
31
+    public ChannelInfo channel = null;
32
+
33
+    public void onChannelSelfJoin(Parser tParser, ChannelInfo cChannel) {
34
+        channel = cChannel;
35
+    }
36
+}

+ 43
- 0
test/com/dmdirc/harness/parser/TestIChannelTopic.java Näytä tiedosto

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+import com.dmdirc.parser.interfaces.callbacks.ChannelTopicListener;
28
+
29
+public class TestIChannelTopic implements ChannelTopicListener {
30
+
31
+    public boolean triggered;
32
+
33
+    public boolean isJoin;
34
+
35
+    public ChannelInfo channel;
36
+
37
+    public void onChannelTopic(Parser tParser, ChannelInfo cChannel,
38
+                               boolean bIsJoinTopic) {
39
+        triggered = true;
40
+        isJoin = bIsJoinTopic;
41
+        channel = cChannel;
42
+    }
43
+}

+ 37
- 0
test/com/dmdirc/harness/parser/TestIConnectError.java Näytä tiedosto

@@ -0,0 +1,37 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.callbacks.ConnectErrorListener;
27
+import com.dmdirc.parser.common.ParserError;
28
+
29
+public class TestIConnectError implements ConnectErrorListener {
30
+
31
+    public boolean error = false;
32
+
33
+    @Override
34
+    public void onConnectError(Parser tParser, ParserError errorInfo) {
35
+        error = true;
36
+    }
37
+}

+ 36
- 0
test/com/dmdirc/harness/parser/TestIErrorInfo.java Näytä tiedosto

@@ -0,0 +1,36 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
27
+import com.dmdirc.parser.common.ParserError;
28
+
29
+public class TestIErrorInfo implements ErrorInfoListener {
30
+
31
+    public boolean error = false;
32
+
33
+    public void onErrorInfo(Parser tParser, ParserError errorInfo) {
34
+        error = true;
35
+    }
36
+}

+ 40
- 0
test/com/dmdirc/harness/parser/TestINickChanged.java Näytä tiedosto

@@ -0,0 +1,40 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.ClientInfo;
26
+import com.dmdirc.parser.interfaces.Parser;
27
+import com.dmdirc.parser.interfaces.callbacks.NickChangeListener;
28
+
29
+public class TestINickChanged implements NickChangeListener {
30
+
31
+    public String oldNick = null;
32
+    public ClientInfo client;
33
+
34
+    @Override
35
+    public void onNickChanged(Parser tParser, ClientInfo cClient,
36
+                              String sOldNick) {
37
+        oldNick = sOldNick;
38
+        client = cClient;
39
+    }
40
+}

+ 36
- 0
test/com/dmdirc/harness/parser/TestINoticeAuth.java Näytä tiedosto

@@ -0,0 +1,36 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.callbacks.AuthNoticeListener;
27
+
28
+public class TestINoticeAuth implements AuthNoticeListener {
29
+
30
+    public String message = null;
31
+
32
+    @Override
33
+    public void onNoticeAuth(Parser tParser, String sData) {
34
+        message = sData;
35
+    }
36
+}

+ 39
- 0
test/com/dmdirc/harness/parser/TestINumeric.java Näytä tiedosto

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.callbacks.NumericListener;
27
+
28
+public class TestINumeric implements NumericListener {
29
+
30
+    public int numeric = 0;
31
+
32
+    public String[] data;
33
+
34
+    @Override
35
+    public void onNumeric(Parser tParser, int numeric, String[] token) {
36
+        this.numeric = numeric;
37
+        data = token;
38
+    }
39
+}

+ 36
- 0
test/com/dmdirc/harness/parser/TestIPost005.java Näytä tiedosto

@@ -0,0 +1,36 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.callbacks.Post005Listener;
27
+
28
+public class TestIPost005 implements Post005Listener {
29
+
30
+    public boolean done = false;
31
+
32
+    @Override
33
+    public void onPost005(Parser tParser) {
34
+        done = true;
35
+    }
36
+}

+ 37
- 0
test/com/dmdirc/harness/parser/TestIPrivateAction.java Näytä tiedosto

@@ -0,0 +1,37 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.callbacks.PrivateActionListener;
27
+
28
+public class TestIPrivateAction implements PrivateActionListener {
29
+
30
+    public String message, host;
31
+
32
+    @Override
33
+    public void onPrivateAction(Parser tParser, String sMessage, String sHost) {
34
+        message = sMessage;
35
+        host = sHost;
36
+    }
37
+}

+ 39
- 0
test/com/dmdirc/harness/parser/TestIPrivateCTCP.java Näytä tiedosto

@@ -0,0 +1,39 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.callbacks.PrivateCtcpListener;
27
+
28
+public class TestIPrivateCTCP implements PrivateCtcpListener {
29
+
30
+    public String type, message, host;
31
+
32
+    @Override
33
+    public void onPrivateCTCP(Parser tParser, String sType, String sMessage,
34
+                              String sHost) {
35
+        type = sType;
36
+        message = sMessage;
37
+        host = sHost;
38
+    }
39
+}

+ 38
- 0
test/com/dmdirc/harness/parser/TestIPrivateMessage.java Näytä tiedosto

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.callbacks.PrivateMessageListener;
27
+
28
+public class TestIPrivateMessage implements PrivateMessageListener {
29
+
30
+    public String host, message;
31
+
32
+    @Override
33
+    public void onPrivateMessage(Parser tParser, String sMessage,
34
+                                 String sHost) {
35
+        host = sHost;
36
+        message = sMessage;
37
+    }
38
+}

+ 59
- 0
test/com/dmdirc/harness/parser/TestIQuit.java Näytä tiedosto

@@ -0,0 +1,59 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
26
+import com.dmdirc.parser.interfaces.ChannelInfo;
27
+import com.dmdirc.parser.interfaces.ClientInfo;
28
+import com.dmdirc.parser.interfaces.Parser;
29
+import com.dmdirc.parser.interfaces.callbacks.ChannelQuitListener;
30
+import com.dmdirc.parser.interfaces.callbacks.QuitListener;
31
+
32
+public class TestIQuit implements ChannelQuitListener, QuitListener {
33
+
34
+    public ChannelInfo channel;
35
+
36
+    public ChannelClientInfo cclient;
37
+
38
+    public ClientInfo client;
39
+
40
+    public String reason;
41
+
42
+    public int count = 0;
43
+
44
+    @Override
45
+    public void onChannelQuit(Parser tParser, ChannelInfo cChannel,
46
+                              ChannelClientInfo cChannelClient, String sReason) {
47
+        this.channel = cChannel;
48
+        this.cclient = cChannelClient;
49
+        this.reason = sReason;
50
+        this.count++;
51
+    }
52
+
53
+    @Override
54
+    public void onQuit(Parser tParser, ClientInfo cClient, String sReason) {
55
+        this.client = cClient;
56
+        this.reason = sReason;
57
+        this.count++;
58
+    }
59
+}

+ 36
- 0
test/com/dmdirc/harness/parser/TestIServerError.java Näytä tiedosto

@@ -0,0 +1,36 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.interfaces.Parser;
26
+import com.dmdirc.parser.interfaces.callbacks.ServerErrorListener;
27
+
28
+public class TestIServerError implements ServerErrorListener {
29
+
30
+    public String message = null;
31
+
32
+    @Override
33
+    public void onServerError(Parser tParser, String sMessage) {
34
+        message = sMessage;
35
+    }
36
+}

+ 103
- 0
test/com/dmdirc/harness/parser/TestParser.java Näytä tiedosto

@@ -0,0 +1,103 @@
1
+/*
2
+ * Copyright (c) 2006-2010 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.harness.parser;
24
+
25
+import com.dmdirc.parser.common.MyInfo;
26
+import com.dmdirc.parser.common.QueuePriority;
27
+import com.dmdirc.parser.interfaces.Parser;
28
+import com.dmdirc.parser.irc.*;
29
+import java.net.URI;
30
+import java.util.ArrayList;
31
+import java.util.List;
32
+import java.util.Timer;
33
+
34
+public class TestParser extends IRCParser implements Parser {
35
+
36
+    public final List<String> sentLines = new ArrayList<String>();
37
+
38
+    public String nick = "nick";
39
+    
40
+    public String network = null;
41
+
42
+    public TestParser() {
43
+        super();
44
+        currentSocketState = SocketState.OPEN;
45
+    }
46
+
47
+    public TestParser(MyInfo myDetails, URI address) {
48
+        super(myDetails, address);
49
+        currentSocketState = SocketState.OPEN;
50
+    }
51
+
52
+    @Override
53
+    protected boolean doSendString(String line, QueuePriority priority, boolean fromParser) {
54
+        sentLines.add(line);
55
+        return true;
56
+    }
57
+    
58
+    public String[] getLine(int index) {
59
+        return tokeniseLine(sentLines.get(index));
60
+    }
61
+    
62
+    public void injectLine(String line) {
63
+        processLine(line);
64
+    }
65
+    
66
+    public void injectConnectionStrings() {
67
+        final String[] lines = new String[]{
68
+            "NOTICE AUTH :Blah, blah",
69
+            ":server 001 " + nick + " :Welcome to the Testing IRC Network, " + nick,
70
+            ":server 002 " + nick + " :Your host is server.net, running version foo",
71
+            ":server 003 " + nick + " :This server was created Sun Jan 6 2008 at 17:34:54 CET",
72
+            ":server 004 " + nick + " server.net foo dioswkgxRXInP bRIeiklmnopstvrDcCNuMT bklov",
73
+            ":server 005 " + nick + " WHOX WALLCHOPS WALLVOICES USERIP PREFIX=(ov)@+ " +
74
+                    (network == null ? "" : "NETWORK=" + network + " ") +
75
+                    ":are supported by this server",
76
+            ":server 005 " + nick + " MAXNICKLEN=15 TOPICLEN=250 AWAYLEN=160 MODES=6 " +
77
+                    "CHANMODES=bIeR,k,l,imnpstrDducCNMT :are supported by this server",
78
+        };
79
+        
80
+        sendConnectionStrings();
81
+        
82
+        for (String line : lines) {
83
+            injectLine(line);
84
+        }
85
+        
86
+        sentLines.clear();
87
+    }
88
+
89
+    @Override
90
+    protected void pingTimerTask(final Timer timer) {
91
+        // Do nothing
92
+    }
93
+
94
+    @Override
95
+    public void run() {
96
+        injectConnectionStrings();
97
+    }
98
+    
99
+    public void runSuper() {
100
+        super.run();
101
+    }
102
+
103
+}

Loading…
Peruuta
Tallenna