示例#1
0
  @Test
  public void writeMOTDObject() throws IOException {
    MOTDWriter w = new MOTDWriter(new MOTD(NUMBER, MESSAGE));
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    w.write(out);

    CDataInputStream in = new CDataInputStream(new ByteArrayInputStream(out.toByteArray()));
    assertEquals(0x14, in.readByte());
    assertEquals(String.valueOf(NUMBER) + "\n" + MESSAGE, in.readString());
  }
示例#2
0
  @Test
  public void writeChanged() throws IOException {
    MOTDWriter w = new MOTDWriter();
    w.setMessage(MESSAGE);
    w.setNumber(NUMBER);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    w.write(out);

    CDataInputStream in = new CDataInputStream(new ByteArrayInputStream(out.toByteArray()));
    assertEquals(0x14, in.readByte());
    assertEquals(String.valueOf(NUMBER) + "\n" + MESSAGE, in.readString());
  }