You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ProcessMessageTest.java 4.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (c) 2006-2015 DMDirc Developers
  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.parser.irc.processors;
  23. import com.dmdirc.harness.parser.TestParser;
  24. import com.dmdirc.parser.common.CallbackNotFoundException;
  25. import com.dmdirc.parser.interfaces.Parser;
  26. import com.dmdirc.parser.interfaces.callbacks.PrivateActionListener;
  27. import com.dmdirc.parser.interfaces.callbacks.PrivateCtcpListener;
  28. import com.dmdirc.parser.interfaces.callbacks.PrivateMessageListener;
  29. import java.util.Date;
  30. import org.junit.Ignore;
  31. import org.junit.Test;
  32. import static org.mockito.Mockito.*;
  33. @Ignore
  34. public class ProcessMessageTest {
  35. @Test
  36. public void testPrivateMessage() throws CallbackNotFoundException {
  37. final TestParser parser = new TestParser();
  38. final PrivateMessageListener ipmtest = mock(PrivateMessageListener.class);
  39. final PrivateActionListener ipatest = mock(PrivateActionListener.class);
  40. final PrivateCtcpListener ipctest = mock(PrivateCtcpListener.class);
  41. parser.injectConnectionStrings();
  42. parser.injectLine(":a!b@c PRIVMSG nick :Hello!");
  43. verify(ipmtest).onPrivateMessage(same(parser), (Date) anyObject(),
  44. eq("Hello!"), eq("a!b@c"));
  45. verify(ipatest, never()).onPrivateAction((Parser) anyObject(),
  46. (Date) anyObject(), anyString(), anyString());
  47. verify(ipctest, never()).onPrivateCTCP((Parser) anyObject(),
  48. (Date) anyObject(), anyString(), anyString(), anyString());
  49. }
  50. @Test
  51. public void testPrivateAction() throws CallbackNotFoundException {
  52. final TestParser parser = new TestParser();
  53. final PrivateMessageListener ipmtest = mock(PrivateMessageListener.class);
  54. final PrivateActionListener ipatest = mock(PrivateActionListener.class);
  55. final PrivateCtcpListener ipctest = mock(PrivateCtcpListener.class);
  56. parser.injectConnectionStrings();
  57. parser.injectLine(":a!b@c PRIVMSG nick :" + ((char) 1) + "ACTION meep" + ((char) 1));
  58. verify(ipmtest, never()).onPrivateMessage((Parser) anyObject(),
  59. (Date) anyObject(), anyString(), anyString());
  60. verify(ipatest).onPrivateAction(same(parser), (Date) anyObject(),
  61. eq("meep"), eq("a!b@c"));
  62. verify(ipctest, never()).onPrivateCTCP((Parser) anyObject(),
  63. (Date) anyObject(), anyString(), anyString(), anyString());
  64. }
  65. @Test
  66. public void testPrivateCTCP() throws CallbackNotFoundException {
  67. final TestParser parser = new TestParser();
  68. final PrivateMessageListener ipmtest = mock(PrivateMessageListener.class);
  69. final PrivateActionListener ipatest = mock(PrivateActionListener.class);
  70. final PrivateCtcpListener ipctest = mock(PrivateCtcpListener.class);
  71. parser.injectConnectionStrings();
  72. parser.injectLine(":a!b@c PRIVMSG nick :" + ((char) 1) + "FOO meep" + ((char) 1));
  73. verify(ipmtest, never()).onPrivateMessage((Parser) anyObject(),
  74. (Date) anyObject(), anyString(), anyString());
  75. verify(ipatest, never()).onPrivateAction((Parser) anyObject(),
  76. (Date) anyObject(), anyString(), anyString());
  77. verify(ipctest).onPrivateCTCP(same(parser),
  78. (Date) anyObject(), eq("FOO"), eq("meep"), eq("a!b@c"));
  79. }
  80. }