Example #1
0
  /**
   * Encodes a sample string, decodes it and makes sure that the decoded string has the same value
   * as the original
   */
  public void testEncodeDecode() {
    String data = "string to encode";
    byte[] expectedReturn = data.getBytes();

    byte[] encodedData = base64.encode(data.getBytes());
    byte[] actualReturn = base64.decode(encodedData);
    assertTrue("encode decode failed.", Arrays.equals(expectedReturn, actualReturn));
  }
Example #2
0
  /**
   * Encodes a sample string, decodes it and makes sure that the decoded string has the same value
   * as the original
   */
  public void testEncodeDecode1() {
    String data = "string to encode";
    byte[] expectedReturn = data.getBytes();

    byte[] encodedData = base64.encode(data.getBytes());

    String encodedString = new String(encodedData);

    byte[] actualReturn = base64.decode(encodedString);
    assertTrue("encode decode failed.", Arrays.equals(expectedReturn, actualReturn));

    assertEquals("Original and destination string do not match", data, new String(actualReturn));
  }
  /** Creates an Message through the advance createMessage() method and inspects its parameters. */
  public void testCreateMessage2() {
    String body =
        "This is an IM coming from the tested implementation" + " on " + new Date().toString();
    String contentType = "text/html";
    String encoding = "UTF-16";
    String subject = "test message";
    net.java.sip.communicator.service.protocol.Message msg =
        opSetBasicIM.createMessage(body.getBytes(), contentType, encoding, subject);

    assertEquals("message body", body, msg.getContent());
    assertTrue("message body bytes", Arrays.equals(body.getBytes(), msg.getRawData()));
    assertEquals("message length", body.length(), msg.getSize());
    assertEquals("message content type", contentType, msg.getContentType());
    assertEquals("message encoding", encoding, msg.getEncoding());
    assertNotNull("message uid", msg.getMessageUID());

    // a further test on message uid.
    net.java.sip.communicator.service.protocol.Message msg2 = opSetBasicIM.createMessage(body);
    assertFalse("message uid", msg.getMessageUID().equals(msg2.getMessageUID()));
  }
  /** Creates an Message through the simple createMessage() method and inspects its parameters. */
  public void testCreateMessage1() {
    String body =
        "This is an IM coming from the tested implementation" + " on " + new Date().toString();
    net.java.sip.communicator.service.protocol.Message msg = opSetBasicIM1.createMessage(body);

    assertEquals("message body", body, msg.getContent());
    assertTrue("message body bytes", Arrays.equals(body.getBytes(), msg.getRawData()));
    assertEquals("message length", body.length(), msg.getSize());
    assertEquals(
        "message content type",
        OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE,
        msg.getContentType());

    assertEquals(
        "message encoding",
        OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING,
        msg.getEncoding());

    assertNotNull("message uid", msg.getMessageUID());

    // a further test on message uid.
    net.java.sip.communicator.service.protocol.Message msg2 = opSetBasicIM1.createMessage(body);
    assertFalse("message uid", msg.getMessageUID().equals(msg2.getMessageUID()));
  }