예제 #1
0
  @Test
  public void findEncryptedPartsShouldReturnMultipleEncryptedParts() throws Exception {
    MimeMessage message = new MimeMessage();
    MimeMultipart multipartMixed = new MimeMultipart();
    multipartMixed.setSubType("mixed");
    MimeMessageHelper.setBody(message, multipartMixed);

    MimeMultipart mulitpartEncryptedOne = new MimeMultipart();
    mulitpartEncryptedOne.setSubType("encrypted");
    MimeBodyPart bodyPartOne = new MimeBodyPart(mulitpartEncryptedOne);
    multipartMixed.addBodyPart(bodyPartOne);

    MimeBodyPart bodyPartTwo = new MimeBodyPart(null, "text/plain");
    multipartMixed.addBodyPart(bodyPartTwo);

    MimeMultipart mulitpartEncryptedThree = new MimeMultipart();
    mulitpartEncryptedThree.setSubType("encrypted");
    MimeBodyPart bodyPartThree = new MimeBodyPart(mulitpartEncryptedThree);
    multipartMixed.addBodyPart(bodyPartThree);

    List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
    assertEquals(2, encryptedParts.size());
    assertSame(bodyPartOne, encryptedParts.get(0));
    assertSame(bodyPartThree, encryptedParts.get(1));
  }
예제 #2
0
  @Test
  public void findEncryptedPartsShouldReturnEmptyEncryptedPart() throws Exception {
    MimeMessage message = new MimeMessage();
    MimeMultipart mulitpartEncrypted = new MimeMultipart();
    mulitpartEncrypted.setSubType("encrypted");
    MimeMessageHelper.setBody(message, mulitpartEncrypted);

    List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
    assertEquals(1, encryptedParts.size());
    assertSame(message, encryptedParts.get(0));
  }