Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ProcessPartTest.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.parser.irc;
  23. import com.dmdirc.harness.parser.TestParser;
  24. import com.dmdirc.harness.parser.TestIChannelPart;
  25. import com.dmdirc.parser.irc.callbacks.CallbackNotFoundException;
  26. import com.dmdirc.parser.irc.callbacks.interfaces.IChannelPart;
  27. import com.dmdirc.parser.irc.callbacks.interfaces.IChannelQuit;
  28. import com.dmdirc.parser.irc.callbacks.interfaces.IQuit;
  29. import org.junit.Test;
  30. import static org.junit.Assert.*;
  31. public class ProcessPartTest {
  32. @Test
  33. public void testNormalPart() throws CallbackNotFoundException {
  34. final TestParser parser = new TestParser();
  35. parser.injectConnectionStrings();
  36. parser.injectLine(":nick JOIN #DMDirc_testing");
  37. parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser");
  38. parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
  39. final TestIChannelPart test = new TestIChannelPart();
  40. parser.getCallbackManager().addCallback("OnChannelPart", test);
  41. assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
  42. parser.injectLine(":luser!foo@barsville PART #DMDirc_testing :Bye bye, cruel world");
  43. assertEquals(1, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
  44. assertNotNull(test.channel);
  45. assertNotNull(test.cclient);
  46. assertNotNull(test.reason);
  47. assertEquals("#DMDirc_testing", test.channel.getName());
  48. assertEquals("luser", test.cclient.getClient().getNickname());
  49. assertEquals("Bye bye, cruel world", test.reason);
  50. }
  51. @Test
  52. public void testEmptyPart() throws CallbackNotFoundException {
  53. final TestParser parser = new TestParser();
  54. parser.injectConnectionStrings();
  55. parser.injectLine(":nick JOIN #DMDirc_testing");
  56. parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser");
  57. parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list.");
  58. final TestIChannelPart test = new TestIChannelPart();
  59. parser.getCallbackManager().addCallback("OnChannelPart", test);
  60. assertEquals(2, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
  61. parser.injectLine(":luser!foo@barsville PART #DMDirc_testing");
  62. assertEquals(1, parser.getChannelInfo("#DMDirc_testing").getChannelClients().size());
  63. assertNotNull(test.channel);
  64. assertNotNull(test.cclient);
  65. assertNotNull(test.reason);
  66. assertEquals("#DMDirc_testing", test.channel.getName());
  67. assertEquals("luser", test.cclient.getClient().getNickname());
  68. assertEquals("", test.reason);
  69. }
  70. }