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.

NullCallbacksTest.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * Copyright (c) 2006-2008 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;
  23. import org.junit.Test;
  24. import static org.junit.Assert.*;
  25. public class NullCallbacksTest extends junit.framework.TestCase {
  26. private IRCProcessor getProcessor(String callback, String param) {
  27. final TestParser parser = new TestParser();
  28. parser.getCallbackManager().delCallbackType(
  29. parser.getCallbackManager().getCallbackType(callback));
  30. try {
  31. return parser.getProcessingManager().getProcessor(param);
  32. } catch (ProcessorNotFoundException ex) {
  33. assertFalse(true);
  34. return null;
  35. }
  36. }
  37. @Test
  38. public void testProcess001() {
  39. boolean exception = false;
  40. try {
  41. ((Process001) getProcessor("OnServerReady", "001")).callServerReady();
  42. } catch (Throwable ex) {
  43. exception = true;
  44. }
  45. assertFalse(exception);
  46. }
  47. @Test
  48. public void testProcess004005() {
  49. boolean exception = false;
  50. try {
  51. ((Process004005) getProcessor("OnGotNetwork", "004")).callGotNetwork();
  52. } catch (Throwable ex) {
  53. exception = true;
  54. }
  55. assertFalse(exception);
  56. }
  57. @Test
  58. public void testProcess464() {
  59. boolean exception = false;
  60. try {
  61. ((Process464) getProcessor("OnPasswordRequired", "464")).callPasswordRequired();
  62. } catch (Throwable ex) {
  63. exception = true;
  64. }
  65. assertFalse(exception);
  66. }
  67. @Test
  68. public void testProcessAway() {
  69. boolean exception = false;
  70. try {
  71. ((ProcessAway) getProcessor("OnAwayState", "301")).callAwayState(false, "");
  72. } catch (Throwable ex) {
  73. exception = true;
  74. }
  75. assertFalse(exception);
  76. }
  77. @Test
  78. public void testProcessInvite() {
  79. boolean exception = false;
  80. try {
  81. ((ProcessInvite) getProcessor("OnInvite", "INVITE")).callInvite("", "");
  82. } catch (Throwable ex) {
  83. exception = true;
  84. }
  85. assertFalse(exception);
  86. }
  87. @Test
  88. public void testProcessJoin() {
  89. boolean exception = false;
  90. try {
  91. ((ProcessJoin) getProcessor("OnChannelJoin", "JOIN")).callChannelJoin(null, null);
  92. ((ProcessJoin) getProcessor("OnChannelSelfJoin", "JOIN")).callChannelSelfJoin(null);
  93. } catch (Throwable ex) {
  94. exception = true;
  95. }
  96. assertFalse(exception);
  97. }
  98. @Test
  99. public void testProcessKick() {
  100. boolean exception = false;
  101. try {
  102. ((ProcessKick) getProcessor("OnChannelKick", "KICK")).callChannelKick(null,
  103. null, null, null, null);
  104. } catch (Throwable ex) {
  105. exception = true;
  106. }
  107. assertFalse(exception);
  108. }
  109. @Test
  110. public void testProcessListModes() {
  111. boolean exception = false;
  112. try {
  113. ((ProcessListModes) getProcessor("OnChannelGotListModes", "346"))
  114. .callChannelGotListModes(null);
  115. } catch (Throwable ex) {
  116. exception = true;
  117. }
  118. assertFalse(exception);
  119. }
  120. @Test
  121. public void testProcessMOTD() {
  122. boolean exception = false;
  123. try {
  124. ((ProcessMOTD) getProcessor("OnMOTDStart", "372")).callMOTDStart(null);
  125. ((ProcessMOTD) getProcessor("OnMOTDLine", "372")).callMOTDLine(null);
  126. ((ProcessMOTD) getProcessor("OnMOTDEnd", "372")).callMOTDEnd(false, null);
  127. } catch (Throwable ex) {
  128. exception = true;
  129. }
  130. assertFalse(exception);
  131. }
  132. }