コード例 #1
0
  @Test
  public void shouldAddNothingWhenNoConfiguredAttribute() throws MessagingException {
    FakeMailetConfig mailetConfig = new FakeMailetConfig("Test", FakeMailContext.defaultContext());

    mailet.init(mailetConfig);

    Mail mail =
        MailUtil.createMockMail2Recipients(
            new MimeMessage(Session.getDefaultInstance(new Properties())));

    mailet.service(mail);

    assertThat(mail.getAttributeNames()).isEmpty();
  }
コード例 #2
0
  @Test
  public void shouldOverwriteAttributeWhenAttributeAlreadyPresent() throws MessagingException {
    FakeMailetConfig mailetConfig = new FakeMailetConfig("Test", FakeMailContext.defaultContext());
    mailetConfig.setProperty("org.apache.james.junit1", "bar");

    mailet.init(mailetConfig);

    Mail mail =
        MailUtil.createMockMail2Recipients(
            new MimeMessage(Session.getDefaultInstance(new Properties())));
    mail.setAttribute("org.apache.james.junit1", "foo");

    mailet.service(mail);

    assertThat(mail.getAttribute("org.apache.james.junit1")).isEqualTo("bar");
  }
コード例 #3
0
  @Test
  public void shouldAddConfiguredAttributes() throws MessagingException {
    FakeMailetConfig mailetConfig = new FakeMailetConfig("Test", FakeMailContext.defaultContext());
    mailetConfig.setProperty("org.apache.james.junit1", "true");
    mailetConfig.setProperty("org.apache.james.junit2", "happy");

    mailet.init(mailetConfig);

    Mail mail =
        MailUtil.createMockMail2Recipients(
            new MimeMessage(Session.getDefaultInstance(new Properties())));

    mailet.service(mail);

    assertThat(mail.getAttribute("org.apache.james.junit1")).isEqualTo("true");
    assertThat(mail.getAttribute("org.apache.james.junit2")).isEqualTo("happy");
  }
コード例 #4
0
 @Test
 public void shouldThrowWhenNullProperty() throws MessagingException {
   FakeMailetConfig mailetConfig = new FakeMailetConfig("Test", FakeMailContext.defaultContext());
   expectedException.expect(NullPointerException.class);
   mailetConfig.setProperty(null, "bar");
 }
コード例 #5
0
 @Test
 public void shouldThrowWhenNullValue() throws MessagingException {
   FakeMailetConfig mailetConfig = new FakeMailetConfig("Test", FakeMailContext.defaultContext());
   expectedException.expect(NullPointerException.class);
   mailetConfig.setProperty("org.apache.james.junit1", null);
 }