Browse Source

Down with dodgy harness classes, up with mocks!

Change-Id: I48ceb58b942dfb017e8698d4b9bca5a1e11dfb61
Reviewed-on: http://gerrit.dmdirc.com/462
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
Tested-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3
Chris Smith 14 years ago
parent
commit
3ac2bf9d29

+ 0
- 44
test/com/dmdirc/harness/parser/TestIChannelPart.java View File

@@ -1,44 +0,0 @@
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
-}

+ 0
- 36
test/com/dmdirc/harness/parser/TestIChannelSelfJoin.java View File

@@ -1,36 +0,0 @@
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
-}

+ 0
- 43
test/com/dmdirc/harness/parser/TestIChannelTopic.java View File

@@ -1,43 +0,0 @@
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
-}

+ 0
- 37
test/com/dmdirc/harness/parser/TestIConnectError.java View File

@@ -1,37 +0,0 @@
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
-}

+ 0
- 36
test/com/dmdirc/harness/parser/TestIErrorInfo.java View File

@@ -1,36 +0,0 @@
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
-}

+ 0
- 40
test/com/dmdirc/harness/parser/TestINickChanged.java View File

@@ -1,40 +0,0 @@
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
-}

+ 0
- 36
test/com/dmdirc/harness/parser/TestINoticeAuth.java View File

@@ -1,36 +0,0 @@
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
-}

+ 0
- 39
test/com/dmdirc/harness/parser/TestINumeric.java View File

@@ -1,39 +0,0 @@
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
-}

+ 0
- 36
test/com/dmdirc/harness/parser/TestIPost005.java View File

@@ -1,36 +0,0 @@
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
-}

+ 0
- 37
test/com/dmdirc/harness/parser/TestIPrivateAction.java View File

@@ -1,37 +0,0 @@
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
-}

+ 0
- 39
test/com/dmdirc/harness/parser/TestIPrivateCTCP.java View File

@@ -1,39 +0,0 @@
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
-}

+ 0
- 38
test/com/dmdirc/harness/parser/TestIPrivateMessage.java View File

@@ -1,38 +0,0 @@
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
-}

+ 0
- 59
test/com/dmdirc/harness/parser/TestIQuit.java View File

@@ -1,59 +0,0 @@
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
-}

+ 0
- 36
test/com/dmdirc/harness/parser/TestIServerError.java View File

@@ -1,36 +0,0 @@
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
-}

+ 74
- 65
test/com/dmdirc/parser/irc/IRCParserTest.java View File

@@ -25,15 +25,8 @@ package com.dmdirc.parser.irc;
25 25
 import com.dmdirc.parser.common.MyInfo;
26 26
 import com.dmdirc.parser.common.ChannelListModeItem;
27 27
 import com.dmdirc.parser.common.ParserError;
28
-import com.dmdirc.harness.parser.TestIPrivateCTCP;
29 28
 import com.dmdirc.harness.parser.TestParser;
30
-import com.dmdirc.harness.parser.TestIConnectError;
31
-import com.dmdirc.harness.parser.TestINoticeAuth;
32
-import com.dmdirc.harness.parser.TestINumeric;
33
-import com.dmdirc.harness.parser.TestIServerError;
34
-import com.dmdirc.harness.parser.TestIPost005;
35
-import com.dmdirc.harness.parser.TestIPrivateMessage;
36
-import com.dmdirc.harness.parser.TestIPrivateAction;
29
+import com.dmdirc.parser.interfaces.Parser;
37 30
 import com.dmdirc.parser.interfaces.callbacks.AuthNoticeListener;
38 31
 import com.dmdirc.parser.common.CallbackNotFoundException;
39 32
 import com.dmdirc.parser.interfaces.callbacks.CallbackInterface;
@@ -90,12 +83,12 @@ public class IRCParserTest {
90 83
         myParser.injectConnectionStrings();
91 84
         myParser.injectLine(":nick2!ident@host NICK :nick");
92 85
 
93
-        verify(error, never()).onErrorInfo((IRCParser) anyObject(), (ParserError) anyObject());
86
+        verify(error, never()).onErrorInfo(same(myParser), (ParserError) anyObject());
94 87
     }
95 88
     
96 89
     @Test
97 90
     public void testProxyPortWithBindIP() {
98
-        final TestIConnectError tice = new TestIConnectError();
91
+        final ConnectErrorListener tice = mock(ConnectErrorListener.class);
99 92
         final ServerInfo si = new ServerInfo();
100 93
         si.setProxyPort(155555);
101 94
         si.setUseSocks(true);
@@ -104,9 +97,8 @@ public class IRCParserTest {
104 97
         myParser.getCallbackManager().addCallback(ConnectErrorListener.class, tice);
105 98
         myParser.setBindIP("0.0.0.0");
106 99
         myParser.run();
107
-        
108
-        assertTrue("Using an invalid socks proxy port should raise a connect error event",
109
-                tice.error);
100
+
101
+        verify(tice).onConnectError(same(myParser), (ParserError) anyObject());
110 102
     }
111 103
 
112 104
     @Test
@@ -178,63 +170,63 @@ public class IRCParserTest {
178 170
 
179 171
     @Test
180 172
     public void testError() throws CallbackNotFoundException {
181
-        final TestIServerError test = new TestIServerError();
173
+        final ServerErrorListener test = mock(ServerErrorListener.class);
182 174
 
183 175
         final TestParser parser = new TestParser();
184 176
         parser.getCallbackManager().addCallback(ServerErrorListener.class, test);
185 177
         parser.injectLine("ERROR :You smell of cheese");
186 178
 
187
-        assertNotNull(test.message);
188
-        assertEquals("ERROR message should be passed to callback",
189
-                "You smell of cheese", test.message);
179
+        verify(test).onServerError(same(parser), eq("You smell of cheese"));
190 180
     }
191 181
 
192 182
     @Test
193
-    public void testAuthNotices() throws CallbackNotFoundException {
194
-        final TestINoticeAuth test = new TestINoticeAuth();
183
+    public void testAuthNotice() throws CallbackNotFoundException {
184
+        final AuthNoticeListener test = mock(AuthNoticeListener.class);
195 185
         final TestParser parser = new TestParser();
196 186
         parser.getCallbackManager().addCallback(AuthNoticeListener.class, test);
197 187
         parser.sendConnectionStrings();
198
-        parser.injectLine("NOTICE AUTH :Random auth notice?");
199 188
 
200
-        assertNotNull(test.message);
201
-        assertEquals("Random auth notice?", test.message);
189
+        parser.injectLine("NOTICE AUTH :Random auth notice?");
190
+        verify(test).onNoticeAuth(same(parser), eq("Random auth notice?"));
191
+    }
202 192
 
203
-        test.message = null;
193
+    @Test
194
+    public void testAuthNoticeTwenty() throws CallbackNotFoundException {
195
+        final AuthNoticeListener test = mock(AuthNoticeListener.class);
196
+        final TestParser parser = new TestParser();
197
+        parser.getCallbackManager().addCallback(AuthNoticeListener.class, test);
198
+        parser.sendConnectionStrings();
204 199
 
205 200
         parser.injectLine(":us.ircnet.org 020 * :Stupid notice");
206
-
207
-        assertNotNull(test.message);
208
-        assertEquals("Stupid notice", test.message);
201
+        verify(test).onNoticeAuth(same(parser), eq("Stupid notice"));
209 202
     }
210 203
 
211 204
     @Test
212 205
     public void testPre001NickChange() throws CallbackNotFoundException {
213
-        final TestINoticeAuth test = new TestINoticeAuth();
206
+        final AuthNoticeListener test = mock(AuthNoticeListener.class);
214 207
         final TestParser parser = new TestParser();
215 208
         parser.getCallbackManager().addCallback(AuthNoticeListener.class, test);
216 209
         parser.sendConnectionStrings();
217 210
         parser.injectLine(":chris!@ NICK :user2");
218 211
 
219
-        assertNull(test.message);
212
+        verify(test, never()).onNoticeAuth((Parser) anyObject(),anyString());
220 213
     }
221 214
 
222 215
     @Test
223 216
     public void testNumeric() throws CallbackNotFoundException {
224
-        final TestINumeric test = new TestINumeric();
217
+        final NumericListener test = mock(NumericListener.class);
225 218
         final TestParser parser = new TestParser();
226 219
         parser.getCallbackManager().addCallback(NumericListener.class, test);
227 220
 
228 221
         parser.injectLine(":server 001 nick :Hi there, nick");
229 222
 
230
-        assertEquals(1, test.numeric);
231
-        assertTrue(Arrays.equals(new String[]{":server", "001", "nick", "Hi there, nick"},
232
-                test.data));
223
+        verify(test).onNumeric(same(parser), eq(1),
224
+                eq(new String[]{":server", "001", "nick", "Hi there, nick"}));
233 225
     }
234 226
 
235 227
     @Test
236 228
     public void testPost005() throws CallbackNotFoundException {
237
-        final TestIPost005 test = new TestIPost005();
229
+        final Post005Listener test = mock(Post005Listener.class);
238 230
         final TestParser parser = new TestParser();
239 231
         parser.getCallbackManager().addCallback(Post005Listener.class, test);
240 232
 
@@ -253,11 +245,11 @@ public class IRCParserTest {
253 245
         };
254 246
 
255 247
         for (String string : strings) {
256
-            assertFalse("OnPost005 fired too early", test.done);
248
+            verify(test, never()).onPost005((Parser) anyObject());
257 249
             parser.injectLine(string);
258 250
         }
259 251
 
260
-        assertTrue("OnPost005 not fired", test.done);
252
+        verify(test).onPost005(same(parser));
261 253
     }
262 254
 
263 255
     @Test
@@ -359,11 +351,11 @@ public class IRCParserTest {
359 351
     }
360 352
 
361 353
     @Test
362
-    public void testPrivateMessages() throws CallbackNotFoundException {
354
+    public void testPrivateMessage() throws CallbackNotFoundException {
363 355
         final TestParser parser = new TestParser();
364
-        final TestIPrivateMessage ipmtest = new TestIPrivateMessage();
365
-        final TestIPrivateAction ipatest = new TestIPrivateAction();
366
-        final TestIPrivateCTCP ipctest = new TestIPrivateCTCP();
356
+        final PrivateMessageListener ipmtest = mock(PrivateMessageListener.class);
357
+        final PrivateActionListener ipatest = mock(PrivateActionListener.class);
358
+        final PrivateCtcpListener ipctest = mock(PrivateCtcpListener.class);
367 359
 
368 360
         parser.injectConnectionStrings();
369 361
 
@@ -372,30 +364,47 @@ public class IRCParserTest {
372 364
         parser.getCallbackManager().addCallback(PrivateCtcpListener.class, ipctest);
373 365
 
374 366
         parser.injectLine(":a!b@c PRIVMSG nick :Hello!");
375
-        assertNotNull(ipmtest.host);
376
-        assertNull(ipatest.host);
377
-        assertNull(ipctest.host);
378
-        assertEquals("a!b@c", ipmtest.host);
379
-        assertEquals("Hello!", ipmtest.message);
380
-        ipmtest.host = null;
381
-        ipmtest.message = null;
367
+        verify(ipmtest).onPrivateMessage(same(parser), eq("Hello!"), eq("a!b@c"));
368
+        verify(ipatest, never()).onPrivateAction((Parser) anyObject(), anyString(), anyString());
369
+        verify(ipctest, never()).onPrivateCTCP((Parser) anyObject(), anyString(), anyString(), anyString());
370
+    }
371
+
372
+    @Test
373
+    public void testPrivateAction() throws CallbackNotFoundException {
374
+        final TestParser parser = new TestParser();
375
+        final PrivateMessageListener ipmtest = mock(PrivateMessageListener.class);
376
+        final PrivateActionListener ipatest = mock(PrivateActionListener.class);
377
+        final PrivateCtcpListener ipctest = mock(PrivateCtcpListener.class);
378
+
379
+        parser.injectConnectionStrings();
380
+
381
+        parser.getCallbackManager().addCallback(PrivateMessageListener.class, ipmtest);
382
+        parser.getCallbackManager().addCallback(PrivateActionListener.class, ipatest);
383
+        parser.getCallbackManager().addCallback(PrivateCtcpListener.class, ipctest);
382 384
 
383 385
         parser.injectLine(":a!b@c PRIVMSG nick :" + ((char) 1) + "ACTION meep" + ((char) 1));
384
-        assertNull(ipmtest.host);
385
-        assertNotNull(ipatest.host);
386
-        assertNull(ipctest.host);
387
-        assertEquals("a!b@c", ipatest.host);
388
-        assertEquals("meep", ipatest.message);
389
-        ipatest.host = null;
390
-        ipatest.message = null;
386
+        verify(ipmtest, never()).onPrivateMessage((Parser) anyObject(), anyString(), anyString());
387
+        verify(ipatest).onPrivateAction(same(parser), eq("meep"), eq("a!b@c"));
388
+        verify(ipctest, never()).onPrivateCTCP((Parser) anyObject(), anyString(), anyString(), anyString());
389
+    }
390
+
391
+    @Test
392
+    public void testPrivateCTCP() throws CallbackNotFoundException {
393
+        final TestParser parser = new TestParser();
394
+        final PrivateMessageListener ipmtest = mock(PrivateMessageListener.class);
395
+        final PrivateActionListener ipatest = mock(PrivateActionListener.class);
396
+        final PrivateCtcpListener ipctest = mock(PrivateCtcpListener.class);
397
+
398
+        parser.injectConnectionStrings();
399
+
400
+        parser.getCallbackManager().addCallback(PrivateMessageListener.class, ipmtest);
401
+        parser.getCallbackManager().addCallback(PrivateActionListener.class, ipatest);
402
+        parser.getCallbackManager().addCallback(PrivateCtcpListener.class, ipctest);
391 403
 
392 404
         parser.injectLine(":a!b@c PRIVMSG nick :" + ((char) 1) + "FOO meep" + ((char) 1));
393
-        assertNull(ipmtest.host);
394
-        assertNull(ipatest.host);
395
-        assertNotNull(ipctest.host);
396
-        assertEquals("a!b@c", ipctest.host);
397
-        assertEquals("FOO", ipctest.type);
398
-        assertEquals("meep", ipctest.message);
405
+        verify(ipmtest, never()).onPrivateMessage((Parser) anyObject(), anyString(), anyString());
406
+        verify(ipatest, never()).onPrivateAction((Parser) anyObject(), anyString(), anyString());
407
+        verify(ipctest).onPrivateCTCP(same(parser), eq("FOO"), eq("meep"), eq("a!b@c"));
399 408
     }
400 409
 
401 410
     private void testListModes(String numeric1, String numeric2, char mode) {
@@ -493,28 +502,28 @@ public class IRCParserTest {
493 502
     @Test
494 503
     public void testIllegalPort1() throws URISyntaxException {
495 504
         final TestParser tp = new TestParser(new MyInfo(), new URI("irc://127.0.0.1:0/"));
496
-        final TestIConnectError tiei = new TestIConnectError();
505
+        final ConnectErrorListener tiei = mock(ConnectErrorListener.class);
497 506
         tp.getCallbackManager().addCallback(ConnectErrorListener.class, tiei);
498 507
         tp.runSuper();
499
-        assertTrue(tiei.error);
508
+        verify(tiei).onConnectError(same(tp), (ParserError) anyObject());
500 509
     }
501 510
     
502 511
     @Test
503 512
     public void testIllegalPort2() throws URISyntaxException {
504 513
         final TestParser tp = new TestParser(new MyInfo(), new URI("irc://127.0.0.1:1/"));
505
-        final TestIConnectError tiei = new TestIConnectError();
514
+        final ConnectErrorListener tiei = mock(ConnectErrorListener.class);
506 515
         tp.getCallbackManager().addCallback(ConnectErrorListener.class, tiei);
507 516
         tp.runSuper();
508
-        assertTrue(tiei.error);
517
+        verify(tiei).onConnectError(same(tp), (ParserError) anyObject());
509 518
     }    
510 519
     
511 520
     @Test
512 521
     public void testIllegalPort3() throws URISyntaxException {
513 522
         final TestParser tp = new TestParser(new MyInfo(), new URI("irc://127.0.0.1:65570/"));
514
-        final TestIConnectError tiei = new TestIConnectError();
523
+        final ConnectErrorListener tiei = mock(ConnectErrorListener.class);
515 524
         tp.getCallbackManager().addCallback(ConnectErrorListener.class, tiei);
516 525
         tp.runSuper();
517
-        assertTrue(tiei.error);
526
+        verify(tiei).onConnectError(same(tp), (ParserError) anyObject());
518 527
     }
519 528
 
520 529
     private void doIRCdTest(final String ircd, final String expected) {

+ 5
- 4
test/com/dmdirc/parser/irc/Process004005Test.java View File

@@ -22,11 +22,12 @@
22 22
 
23 23
 package com.dmdirc.parser.irc;
24 24
 
25
-import com.dmdirc.harness.parser.TestIErrorInfo;
25
+import com.dmdirc.parser.common.ParserError;
26 26
 import com.dmdirc.harness.parser.TestParser;
27 27
 import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
28 28
 import org.junit.Test;
29 29
 import static org.junit.Assert.*;
30
+import static org.mockito.Mockito.*;
30 31
 
31 32
 public class Process004005Test {
32 33
     
@@ -62,13 +63,13 @@ public class Process004005Test {
62 63
     @Test
63 64
     public void testCaseMappingUnknown() {
64 65
         final TestParser tp = doCaseMappingTest("rfc1459", 4);
65
-        final TestIErrorInfo tiei = new TestIErrorInfo();
66
+        final ErrorInfoListener info = mock(ErrorInfoListener.class);
66 67
         
67
-        tp.getCallbackManager().addCallback(ErrorInfoListener.class, tiei);
68
+        tp.getCallbackManager().addCallback(ErrorInfoListener.class, info);
68 69
         
69 70
         tp.injectLine(":server 005 nick CASEMAPPING=unknown :are supported by this server");
70 71
         
71
-        assertTrue(tiei.error);
72
+        verify(info).onErrorInfo(same(tp), (ParserError) anyObject());
72 73
     }
73 74
 
74 75
 }

+ 3
- 11
test/com/dmdirc/parser/irc/ProcessJoinTest.java View File

@@ -22,14 +22,12 @@
22 22
 
23 23
 package com.dmdirc.parser.irc;
24 24
 
25
-import com.dmdirc.harness.parser.TestIChannelSelfJoin;
26 25
 import com.dmdirc.harness.parser.TestParser;
27 26
 import com.dmdirc.parser.common.CallbackNotFoundException;
28 27
 import com.dmdirc.parser.interfaces.callbacks.ChannelJoinListener;
29
-
30 28
 import com.dmdirc.parser.interfaces.callbacks.ChannelSelfJoinListener;
29
+
31 30
 import org.junit.Test;
32
-import static org.junit.Assert.*;
33 31
 import static org.mockito.Mockito.*;
34 32
 
35 33
 public class ProcessJoinTest {
@@ -37,19 +35,13 @@ public class ProcessJoinTest {
37 35
     @Test
38 36
     public void testSelfJoinChannel() throws CallbackNotFoundException {
39 37
         final TestParser parser = new TestParser();
40
-        final TestIChannelSelfJoin test = new TestIChannelSelfJoin();
38
+        final ChannelSelfJoinListener test = mock(ChannelSelfJoinListener.class);
41 39
 
42 40
         parser.injectConnectionStrings();
43 41
         parser.getCallbackManager().addCallback(ChannelSelfJoinListener.class, test);
44 42
         parser.injectLine(":nick JOIN #DMDirc_testing");
45 43
 
46
-        assertNotNull(test.channel);
47
-        assertEquals("#DMDirc_testing", test.channel.getName());
48
-        assertEquals("#DMDirc_testing", test.channel.toString());
49
-        assertSame(parser, test.channel.getParser());
50
-        assertEquals(1, parser.getChannels().size());
51
-        assertTrue(parser.getChannels().contains(test.channel));
52
-        assertEquals(test.channel, parser.getChannel("#DMDirc_testing"));
44
+        verify(test).onChannelSelfJoin(same(parser), same(parser.getChannel("#DMDirc_testing")));
53 45
     }
54 46
     
55 47
     @Test

+ 5
- 3
test/com/dmdirc/parser/irc/ProcessNamesTest.java View File

@@ -23,24 +23,26 @@
23 23
 package com.dmdirc.parser.irc;
24 24
 
25 25
 import com.dmdirc.harness.parser.TestParser;
26
-import com.dmdirc.harness.parser.TestIErrorInfo;
27 26
 import com.dmdirc.parser.common.CallbackNotFoundException;
27
+import com.dmdirc.parser.common.ParserError;
28
+import com.dmdirc.parser.interfaces.Parser;
28 29
 import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
29 30
 import org.junit.Test;
30 31
 import static org.junit.Assert.*;
32
+import static org.mockito.Mockito.*;
31 33
 
32 34
 public class ProcessNamesTest {
33 35
     
34 36
     @Test
35 37
     public void testExternalNames() throws CallbackNotFoundException {
36 38
         final TestParser parser = new TestParser();
37
-        final TestIErrorInfo test = new TestIErrorInfo();
39
+        final ErrorInfoListener test = mock(ErrorInfoListener.class);
38 40
         parser.injectConnectionStrings();
39 41
         parser.getCallbackManager().addCallback(ErrorInfoListener.class, test);
40 42
         
41 43
         parser.injectLine(":server 366 nick #nonexistant :End of /NAMES list.");
42 44
         
43
-        assertFalse("Should not error on unknown NAMES replies", test.error);
45
+        verify(test, never()).onErrorInfo((Parser) anyObject(), (ParserError) anyObject());
44 46
     }
45 47
     
46 48
     @Test

+ 13
- 13
test/com/dmdirc/parser/irc/ProcessNickTest.java View File

@@ -23,20 +23,22 @@
23 23
 package com.dmdirc.parser.irc;
24 24
 
25 25
 import com.dmdirc.harness.parser.TestParser;
26
-import com.dmdirc.harness.parser.TestIErrorInfo;
27
-import com.dmdirc.harness.parser.TestINickChanged;
26
+import com.dmdirc.parser.common.ParserError;
27
+import com.dmdirc.parser.interfaces.ClientInfo;
28
+import com.dmdirc.parser.interfaces.Parser;
28 29
 import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
29 30
 import com.dmdirc.parser.interfaces.callbacks.NickChangeListener;
30 31
 import com.dmdirc.parser.common.CallbackNotFoundException;
31 32
 import org.junit.Test;
32 33
 import static org.junit.Assert.*;
34
+import static org.mockito.Mockito.*;
33 35
 
34 36
 public class ProcessNickTest {
35 37
     
36 38
     @Test
37 39
     public void testNickSameName() {
38 40
         final TestParser parser = new TestParser();
39
-        final TestINickChanged tinc = new TestINickChanged();
41
+        final NickChangeListener tinc = mock(NickChangeListener.class);
40 42
 
41 43
         parser.getCallbackManager().addCallback(NickChangeListener.class, tinc);
42 44
         
@@ -53,9 +55,8 @@ public class ProcessNickTest {
53 55
         IRCChannelClientInfo cci = parser.getClient("LUSER").getChannelClients().get(0);
54 56
         assertEquals(parser.getChannel("#DMDirc_testing"), cci.getChannel());
55 57
         assertEquals("+", cci.getChanModeStr(true));
56
-        
57
-        assertSame(cci.getClient(), tinc.client);
58
-        assertEquals("luser", tinc.oldNick);
58
+
59
+        verify(tinc).onNickChanged(same(parser), same(parser.getClient("LUSER")), eq("luser"));
59 60
     }
60 61
     
61 62
     @Test
@@ -80,7 +81,7 @@ public class ProcessNickTest {
80 81
     @Test
81 82
     public void testOverrideNick() throws CallbackNotFoundException {
82 83
         final TestParser parser = new TestParser();
83
-        final TestIErrorInfo info = new TestIErrorInfo();
84
+        final ErrorInfoListener info = mock(ErrorInfoListener.class);
84 85
         
85 86
         parser.getCallbackManager().addCallback(ErrorInfoListener.class, info);
86 87
         parser.injectConnectionStrings();
@@ -89,22 +90,21 @@ public class ProcessNickTest {
89 90
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list");
90 91
         parser.injectLine(":luser!lu@ser.com NICK nick3");
91 92
 
92
-        assertTrue("Parser should raise an error if a nick change overrides an "
93
-                + "existing client", info.error);
93
+        verify(info).onErrorInfo(same(parser),(ParserError) anyObject());
94 94
     }
95 95
     
96 96
     @Test
97 97
     public void testUnknownNick() {
98 98
         final TestParser parser = new TestParser();
99
-        final TestINickChanged tinc = new TestINickChanged();
99
+        final NickChangeListener tinc = mock(NickChangeListener.class);
100 100
         
101 101
         parser.getCallbackManager().addCallback(NickChangeListener.class, tinc);
102 102
         
103 103
         parser.injectConnectionStrings();
104 104
         parser.injectLine(":random!lu@ser NICK rand");
105
-        
106
-        assertNull(tinc.client);
107
-        assertNull(tinc.oldNick);
105
+
106
+        verify(tinc, never()).onNickChanged((Parser) anyObject(), (ClientInfo) anyObject(),
107
+                anyString());
108 108
     }
109 109
 
110 110
 }

+ 18
- 20
test/com/dmdirc/parser/irc/ProcessPartTest.java View File

@@ -25,10 +25,12 @@ package com.dmdirc.parser.irc;
25 25
 import com.dmdirc.harness.parser.TestParser;
26 26
 import com.dmdirc.harness.parser.TestIChannelPart;
27 27
 import com.dmdirc.parser.common.CallbackNotFoundException;
28
-
28
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
29 29
 import com.dmdirc.parser.interfaces.callbacks.ChannelPartListener;
30
+
30 31
 import org.junit.Test;
31 32
 import static org.junit.Assert.*;
33
+import static org.mockito.Mockito.*;
32 34
 
33 35
 public class ProcessPartTest {
34 36
     
@@ -42,22 +44,20 @@ public class ProcessPartTest {
42 44
         parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser");
43 45
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
44 46
         
45
-        final TestIChannelPart test = new TestIChannelPart();
47
+        final ChannelPartListener test = mock(ChannelPartListener.class);
46 48
         parser.getCallbackManager().addCallback(ChannelPartListener.class, test);
47 49
         
48 50
         assertEquals(2, parser.getChannel("#DMDirc_testing").getChannelClients().size());
49
-        
51
+
52
+        final ChannelClientInfo cci = parser.getChannel("#DMDirc_testing")
53
+                .getChannelClient("luser");
54
+
50 55
         parser.injectLine(":luser!foo@barsville PART #DMDirc_testing :Bye bye, cruel world");
51 56
         
52 57
         assertEquals(1, parser.getChannel("#DMDirc_testing").getChannelClients().size());
53
-        
54
-        assertNotNull(test.channel);
55
-        assertNotNull(test.cclient);
56
-        assertNotNull(test.reason);
57
-        
58
-        assertEquals("#DMDirc_testing", test.channel.getName());
59
-        assertEquals("luser", test.cclient.getClient().getNickname());
60
-        assertEquals("Bye bye, cruel world", test.reason);
58
+
59
+        verify(test).onChannelPart(same(parser), same(parser.getChannel("#DMDirc_testing")),
60
+                same(cci), eq("Bye bye, cruel world"));
61 61
     }
62 62
     
63 63
     @Test
@@ -70,22 +70,20 @@ public class ProcessPartTest {
70 70
         parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser");
71 71
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
72 72
         
73
-        final TestIChannelPart test = new TestIChannelPart();
73
+        final ChannelPartListener test = mock(ChannelPartListener.class);
74 74
         parser.getCallbackManager().addCallback(ChannelPartListener.class, test);
75 75
         
76 76
         assertEquals(2, parser.getChannel("#DMDirc_testing").getChannelClients().size());
77
+
78
+        final ChannelClientInfo cci = parser.getChannel("#DMDirc_testing")
79
+                .getChannelClient("luser");
77 80
         
78 81
         parser.injectLine(":luser!foo@barsville PART #DMDirc_testing");
79 82
         
80 83
         assertEquals(1, parser.getChannel("#DMDirc_testing").getChannelClients().size());
81
-        
82
-        assertNotNull(test.channel);
83
-        assertNotNull(test.cclient);
84
-        assertNotNull(test.reason);
85
-        
86
-        assertEquals("#DMDirc_testing", test.channel.getName());
87
-        assertEquals("luser", test.cclient.getClient().getNickname());
88
-        assertEquals("", test.reason);
84
+
85
+        verify(test).onChannelPart(same(parser), same(parser.getChannel("#DMDirc_testing")),
86
+                same(cci), eq(""));
89 87
     }    
90 88
 
91 89
 }

+ 20
- 26
test/com/dmdirc/parser/irc/ProcessQuitTest.java View File

@@ -23,13 +23,15 @@
23 23
 package com.dmdirc.parser.irc;
24 24
 
25 25
 import com.dmdirc.harness.parser.TestParser;
26
-import com.dmdirc.harness.parser.TestIQuit;
27 26
 import com.dmdirc.parser.interfaces.callbacks.ChannelQuitListener;
28 27
 import com.dmdirc.parser.interfaces.callbacks.QuitListener;
28
+import com.dmdirc.parser.interfaces.ChannelClientInfo;
29
+import com.dmdirc.parser.interfaces.ClientInfo;
29 30
 import com.dmdirc.parser.common.CallbackNotFoundException;
30 31
 
31 32
 import org.junit.Test;
32 33
 import static org.junit.Assert.*;
34
+import static org.mockito.Mockito.*;
33 35
 
34 36
 public class ProcessQuitTest {
35 37
     
@@ -46,24 +48,22 @@ public class ProcessQuitTest {
46 48
         parser.injectLine(":server 353 nick = #DMDirc_testing2 :@nick +luser2");
47 49
         parser.injectLine(":server 366 nick #DMDirc_testing2 :End of /NAMES list.");        
48 50
         
49
-        final TestIQuit test = new TestIQuit();
51
+        final ChannelQuitListener test = mock(ChannelQuitListener.class);
50 52
         parser.getCallbackManager().addCallback(ChannelQuitListener.class, test);
51 53
         
52 54
         assertEquals(2, parser.getChannel("#DMDirc_testing").getChannelClients().size());
55
+
56
+        final ChannelClientInfo cci = parser.getChannel("#DMDirc_testing")
57
+                .getChannelClient("luser");
53 58
         
54 59
         parser.injectLine(":luser!foo@barsville QUIT :Bye bye, cruel world");
55 60
         
56 61
         assertEquals(1, parser.getChannel("#DMDirc_testing").getChannelClients().size());
57 62
         assertEquals(2, parser.getChannel("#DMDirc_testing2").getChannelClients().size());
58
-        
59
-        assertNotNull(test.channel);
60
-        assertNotNull(test.cclient);
61
-        assertNotNull(test.reason);
62
-        
63
-        assertEquals(1, test.count);
64
-        assertEquals("#DMDirc_testing", test.channel.getName());
65
-        assertEquals("luser", test.cclient.getClient().getNickname());
66
-        assertEquals("Bye bye, cruel world", test.reason);
63
+
64
+        verify(test).onChannelQuit(same(parser),
65
+                same(parser.getChannel("#DMDirc_testing")), same(cci),
66
+                eq("Bye bye, cruel world"));
67 67
     }
68 68
     
69 69
     @Test
@@ -79,22 +79,19 @@ public class ProcessQuitTest {
79 79
         parser.injectLine(":server 353 nick = #DMDirc_testing2 :@nick +luser2");
80 80
         parser.injectLine(":server 366 nick #DMDirc_testing2 :End of /NAMES list.");
81 81
         
82
-        final TestIQuit test = new TestIQuit();
82
+        final QuitListener test = mock(QuitListener.class);
83 83
         parser.getCallbackManager().addCallback(QuitListener.class, test);
84 84
         
85 85
         assertEquals(2, parser.getChannel("#DMDirc_testing").getChannelClients().size());
86
+
87
+        final ClientInfo client = parser.getClient("luser");
86 88
         
87 89
         parser.injectLine(":luser!foo@barsville QUIT :Bye bye, cruel world");
88 90
         
89 91
         assertEquals(1, parser.getChannel("#DMDirc_testing").getChannelClients().size());
90 92
         assertEquals(2, parser.getChannel("#DMDirc_testing2").getChannelClients().size());
91
-        
92
-        assertNotNull(test.client);
93
-        assertNotNull(test.reason);
94
-        
95
-        assertEquals(1, test.count);
96
-        assertEquals("luser", test.client.getNickname());
97
-        assertEquals("Bye bye, cruel world", test.reason);
93
+
94
+        verify(test).onQuit(same(parser), same(client), eq("Bye bye, cruel world"));
98 95
     }
99 96
     
100 97
     @Test
@@ -107,21 +104,18 @@ public class ProcessQuitTest {
107 104
         parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser");
108 105
         parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
109 106
         
110
-        final TestIQuit test = new TestIQuit();
107
+        final QuitListener test = mock(QuitListener.class);
111 108
         parser.getCallbackManager().addCallback(QuitListener.class, test);
112 109
         
113 110
         assertEquals(2, parser.getChannel("#DMDirc_testing").getChannelClients().size());
111
+
112
+        final ClientInfo client = parser.getClient("luser");
114 113
         
115 114
         parser.injectLine(":luser!foo@barsville QUIT");
116 115
         
117 116
         assertEquals(1, parser.getChannel("#DMDirc_testing").getChannelClients().size());
118 117
         
119
-        assertNotNull(test.client);
120
-        assertNotNull(test.reason);
121
-        
122
-        assertEquals(1, test.count);
123
-        assertEquals("luser", test.client.getNickname());
124
-        assertEquals("", test.reason);
118
+        verify(test).onQuit(same(parser), same(client), eq(""));
125 119
     }    
126 120
 
127 121
 }

+ 18
- 16
test/com/dmdirc/parser/irc/ProcessTopicTest.java View File

@@ -23,37 +23,38 @@
23 23
 package com.dmdirc.parser.irc;
24 24
 
25 25
 import com.dmdirc.harness.parser.TestParser;
26
-import com.dmdirc.harness.parser.TestIChannelTopic;
27 26
 import com.dmdirc.parser.common.CallbackNotFoundException;
28 27
 import com.dmdirc.parser.interfaces.callbacks.ChannelTopicListener;
29 28
 import org.junit.Test;
30 29
 import static org.junit.Assert.*;
30
+import static org.mockito.Mockito.*;
31 31
 
32 32
 public class ProcessTopicTest {
33 33
     
34 34
     @Test
35 35
     public void testBasicTopic() throws CallbackNotFoundException {
36 36
         final TestParser parser = new TestParser();
37
-        final TestIChannelTopic test = new TestIChannelTopic();
37
+        final ChannelTopicListener test = mock(ChannelTopicListener.class);
38 38
         parser.injectConnectionStrings();
39 39
         parser.getCallbackManager().addCallback(ChannelTopicListener.class, test);
40 40
         
41 41
         parser.injectLine(":nick JOIN #DMDirc_testing");
42 42
         parser.injectLine(":server 332 nick #DMDirc_testing :This be a topic");
43 43
         parser.injectLine(":server 333 nick #DMDirc_testing Q 1207350306");
44
-        
45
-        assertTrue(test.triggered);
46
-        assertTrue(test.isJoin);
47
-        assertEquals("#DMDirc_testing", test.channel.getName());
48
-        assertEquals("This be a topic", test.channel.getTopic());
49
-        assertEquals("Q", test.channel.getTopicSetter());
50
-        assertEquals(1207350306l, test.channel.getTopicTime());
44
+
45
+        verify(test).onChannelTopic(same(parser), same(parser.getChannel("#DMDirc_testing")),
46
+                eq(true));
47
+
48
+        assertEquals("#DMDirc_testing", parser.getChannel("#DMDirc_testing").getName());
49
+        assertEquals("This be a topic", parser.getChannel("#DMDirc_testing").getTopic());
50
+        assertEquals("Q", parser.getChannel("#DMDirc_testing").getTopicSetter());
51
+        assertEquals(1207350306l, parser.getChannel("#DMDirc_testing").getTopicTime());
51 52
     }
52 53
     
53 54
     @Test
54 55
     public void testTopicChange() throws CallbackNotFoundException {
55 56
         final TestParser parser = new TestParser();
56
-        final TestIChannelTopic test = new TestIChannelTopic();
57
+        final ChannelTopicListener test = mock(ChannelTopicListener.class);
57 58
         parser.injectConnectionStrings();
58 59
         
59 60
         parser.injectLine(":nick JOIN #DMDirc_testing");
@@ -63,13 +64,14 @@ public class ProcessTopicTest {
63 64
         parser.getCallbackManager().addCallback(ChannelTopicListener.class, test);
64 65
         
65 66
         parser.injectLine(":foobar TOPIC #DMDirc_testing :New topic here");
67
+
68
+        verify(test).onChannelTopic(same(parser), same(parser.getChannel("#DMDirc_testing")),
69
+                eq(false));
66 70
         
67
-        assertTrue(test.triggered);
68
-        assertFalse(test.isJoin);
69
-        assertEquals("#DMDirc_testing", test.channel.getName());
70
-        assertEquals("New topic here", test.channel.getTopic());
71
-        assertEquals("foobar", test.channel.getTopicSetter());
72
-        assertTrue(1207350306l < test.channel.getTopicTime());
71
+        assertEquals("#DMDirc_testing", parser.getChannel("#DMDirc_testing").getName());
72
+        assertEquals("New topic here", parser.getChannel("#DMDirc_testing").getTopic());
73
+        assertEquals("foobar", parser.getChannel("#DMDirc_testing").getTopicSetter());
74
+        assertTrue(1207350306l < parser.getChannel("#DMDirc_testing").getTopicTime());
73 75
     }    
74 76
 
75 77
 }

Loading…
Cancel
Save