Exemplo n.º 1
0
  @Test
  public void testCreate() {
    IRCMessage msg = new IRCMessage("PRIVMSG", "#channel", "word1");

    assertTrue(msg.getPrefix().isEmpty());
    assertEquals(msg.getCommand(), "PRIVMSG");
    assertEquals(msg.getParameters()[0], "#channel");
    assertEquals(msg.getParameters()[1], "word1");
  }
Exemplo n.º 2
0
  @Test
  public void testParseWithWholeSentence() {
    String prefix = "[email protected]";
    String command = "PRIVMSG";
    String channel = "#channel";
    String sentence = "this is a sentence";

    String messageText = String.format(":%s %s %s :%s", prefix, command, channel, sentence);
    IRCMessage message = IRCMessage.parseMessage(messageText);

    assertEquals(message.getPrefix(), prefix);
    assertEquals(message.getCommand(), command);

    String[] messageParameters = message.getParameters();
    assertEquals(messageParameters.length, 2);

    assertEquals(messageParameters[0], channel);
    assertEquals(messageParameters[1], sentence);
  }
Exemplo n.º 3
0
  @Test
  public void testParse() {
    String command = "TESTMESSAGE";
    String[] parameters = new String[] {"#channel", "word1", "word2"};

    String messageText =
        String.format("%s %s %s %s", command, parameters[0], parameters[1], parameters[2]);
    IRCMessage message = IRCMessage.parseMessage(messageText);

    assertTrue(message.getPrefix().isEmpty());
    assertEquals(message.getCommand(), command);

    String[] messageParameters = message.getParameters();
    assertEquals(messageParameters.length, parameters.length);

    for (int i = 0; i < parameters.length; i++) {
      assertEquals(messageParameters[i], parameters[i]);
    }
  }
Exemplo n.º 4
0
  @Test
  public void testParseWithPrefix() {
    String prefix = "[email protected]";
    String command = "TESTMESSAGE";
    String[] parameters = new String[] {"#channel", "word1", "word2"};

    String messageText =
        String.format(
            ":%s %s %s %s %s", prefix, command, parameters[0], parameters[1], parameters[2]);
    IRCMessage message = IRCMessage.parseMessage(messageText);

    assertEquals(message.getPrefix(), prefix);
    assertEquals(message.getCommand(), command);

    String[] messageParameters = message.getParameters();
    assertEquals(messageParameters.length, parameters.length);

    for (int i = 0; i < parameters.length; i++) {
      assertEquals(messageParameters[i], parameters[i]);
    }
  }