Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

ProcessNamesTest.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2006-2013 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;
  23. import com.dmdirc.harness.parser.TestParser;
  24. import com.dmdirc.parser.common.CallbackNotFoundException;
  25. import com.dmdirc.parser.common.ParserError;
  26. import com.dmdirc.parser.interfaces.Parser;
  27. import com.dmdirc.parser.interfaces.callbacks.ErrorInfoListener;
  28. import java.util.Date;
  29. import org.junit.Test;
  30. import static org.junit.Assert.*;
  31. import static org.mockito.Mockito.*;
  32. public class ProcessNamesTest {
  33. @Test
  34. public void testExternalNames() throws CallbackNotFoundException {
  35. final TestParser parser = new TestParser();
  36. final ErrorInfoListener test = mock(ErrorInfoListener.class);
  37. parser.injectConnectionStrings();
  38. parser.getCallbackManager().addCallback(ErrorInfoListener.class, test);
  39. parser.injectLine(":server 366 nick #nonexistant :End of /NAMES list.");
  40. verify(test, never()).onErrorInfo((Parser) anyObject(),
  41. (Date) anyObject(), (ParserError) anyObject());
  42. }
  43. @Test
  44. public void testChannelUmodes() {
  45. final TestParser parser = new TestParser();
  46. parser.injectConnectionStrings();
  47. parser.injectLine(":nick JOIN #DMDirc_testing");
  48. parser.injectLine(":server 353 nick = #DMDirc_testing :@nick +luser @+nick2 nick3");
  49. parser.injectLine(":server 366 nick #DMDirc_testing :End of /NAMES list");
  50. assertEquals(1, parser.getChannels().size());
  51. assertNotNull(parser.getChannel("#DMDirc_testing"));
  52. assertEquals(4, parser.getChannel("#DMDirc_testing").getChannelClients().size());
  53. assertNotNull(parser.getClient("luser"));
  54. assertEquals(1, parser.getClient("luser").getChannelClients().size());
  55. IRCChannelClientInfo cci = parser.getClient("luser").getChannelClients().get(0);
  56. assertEquals(parser.getChannel("#DMDirc_testing"), cci.getChannel());
  57. assertEquals("+", cci.getChanModeStr(true));
  58. cci = parser.getChannel("#DMDirc_testing").getChannelClient("nick2");
  59. assertNotNull(cci);
  60. assertEquals("@+", cci.getChanModeStr(true));
  61. cci = parser.getChannel("#DMDirc_testing").getChannelClient("nick3");
  62. assertNotNull(cci);
  63. assertEquals("", cci.getChanModeStr(true));
  64. }
  65. }