Ejemplo n.º 1
0
  @Test
  public void testListUidl() throws IOException {
    initAccount();

    // load messages with POP3 label
    long mailSizeRegular = getResourceSize(EMAIL_REGULAR);
    long mailSizeAttach = getResourceSize(EMAIL_LARGE_ATT);

    Map<String, UUID> messages = new HashMap<String, UUID>(2);
    Integer labelId = ReservedLabels.POP3.getId();

    messages.put("headers", RestV2IT.addMessage(EMAIL_REGULAR, labelId));
    messages.put("attach", RestV2IT.addMessage(EMAIL_LARGE_ATT, labelId));

    // initialize POP3 client
    POP3Client client = new POP3Client();
    client.connect(POP3_HOST, POP3_PORT);

    boolean loginSuccess = client.login(TEST_ACCOUNT, TEST_PASSWORD);
    assertThat(loginSuccess, is(true));

    // LIST all messages
    POP3MessageInfo[] info = client.listMessages();
    assertThat(info.length, equalTo(2));
    assertThat((int) mailSizeAttach, equalTo(info[0].size));
    assertThat((int) mailSizeRegular, equalTo(info[1].size));
    assertThat(info[0].number, equalTo(1));
    assertThat(info[1].number, equalTo(2));

    // LIST one message
    POP3MessageInfo msgInfo = client.listMessage(1);
    assertThat((int) mailSizeAttach, equalTo(msgInfo.size));
    assertThat(msgInfo.number, equalTo(1));

    // LIST message that does not exist
    msgInfo = client.listMessage(10);
    assertThat(msgInfo, nullValue());

    // UIDL all messages
    info = client.listUniqueIdentifiers();
    assertThat(info.length, equalTo(2));
    assertThat(info[0].identifier, equalTo(Base64UUIDUtils.encode(messages.get("attach"))));
    assertThat(info[1].identifier, equalTo(Base64UUIDUtils.encode(messages.get("headers"))));
    assertThat(info[0].number, equalTo(1));
    assertThat(info[1].number, equalTo(2));

    // UIDL one message
    msgInfo = client.listUniqueIdentifier(1);
    assertThat(msgInfo.identifier, equalTo(Base64UUIDUtils.encode(messages.get("attach"))));
    assertThat(msgInfo.number, equalTo(1));

    // UIDL message that does not exist
    msgInfo = client.listUniqueIdentifier(10);
    assertThat(msgInfo, nullValue());

    boolean logoutSuccess = client.logout();
    assertThat(logoutSuccess, is(true));
  }
Ejemplo n.º 2
0
  @Test
  public void testRset() throws IOException {
    initAccount();

    Integer labelId = ReservedLabels.POP3.getId();
    RestV2IT.addMessage(EMAIL_REGULAR, labelId);

    // initialize POP3 client
    POP3Client client = new POP3Client();
    client.connect(POP3_HOST, POP3_PORT);

    // Login
    boolean loginSuccess = client.login(TEST_ACCOUNT, TEST_PASSWORD);
    assertThat(loginSuccess, is(true));

    // LIST all messages
    POP3MessageInfo[] info = client.listMessages();
    assertThat(info.length, equalTo(1));

    // DELE message 1
    boolean deleteResult = client.deleteMessage(1);
    assertThat(deleteResult, is(true));

    // LIST remaining
    info = client.listMessages();
    assertThat(info.length, equalTo(0));

    // RSET. After this the deleted mark should be removed again
    boolean resetRestult = client.reset();
    assertThat(resetRestult, is(true));

    // LIST all messages
    info = client.listMessages();
    assertThat(info.length, equalTo(1));

    // Logout
    boolean logoutSuccess = client.logout();
    assertThat(logoutSuccess, is(true));
  }
Ejemplo n.º 3
0
  @Test
  public void testDele() throws IOException {
    initAccount();

    Map<String, UUID> messages = new HashMap<String, UUID>(2);
    Integer labelId = ReservedLabels.POP3.getId();

    messages.put("headers", RestV2IT.addMessage(EMAIL_REGULAR, labelId));
    messages.put("attach", RestV2IT.addMessage(EMAIL_LARGE_ATT, labelId));

    // initialize POP3 client
    POP3Client client = new POP3Client();
    client.connect(POP3_HOST, POP3_PORT);

    // Login
    boolean loginSuccess = client.login(TEST_ACCOUNT, TEST_PASSWORD);
    assertThat(loginSuccess, is(true));

    // LIST all messages
    POP3MessageInfo[] info = client.listMessages();
    assertThat(info.length, equalTo(2));

    // DELE message 1
    boolean deleteResult = client.deleteMessage(1);
    assertThat(deleteResult, is(true));

    // LIST remaining
    info = client.listMessages();
    assertThat(info.length, equalTo(1));

    // DELE message 1 again
    deleteResult = client.deleteMessage(1);
    assertThat(deleteResult, is(false));

    // LIST remaining
    info = client.listMessages();
    assertThat(info.length, equalTo(1));

    // DELE message 2
    deleteResult = client.deleteMessage(2);
    assertThat(deleteResult, is(true));

    info = client.listMessages();
    assertThat(info.length, equalTo(0));

    // QUIT so the messages get expunged
    boolean logoutSuccess = client.logout();
    assertThat(logoutSuccess, is(true));

    // reconnect
    client.connect(POP3_HOST, POP3_PORT);

    // Login
    loginSuccess = client.login(TEST_ACCOUNT, TEST_PASSWORD);
    assertThat(loginSuccess, is(true));

    info = client.listMessages();
    assertThat(info.length, equalTo(0));

    logoutSuccess = client.logout();
    assertThat(logoutSuccess, is(true));
  }