Search in sources :

Example 1 with HeaderTerm

use of jakarta.mail.search.HeaderTerm in project exist by eXist-db.

the class MessageListFunctions method parseHeaderTerm.

private SearchTerm parseHeaderTerm(Node terms) throws XPathException {
    SearchTerm st = null;
    String pattern = ((Element) terms).getAttribute("pattern");
    String name = ((Element) terms).getAttribute("name");
    if (StringUtils.isEmpty(name)) {
        throw (new XPathException(this, "name not specified for term with type: " + ((Element) terms).getAttribute("type")));
    }
    if (pattern != null && !pattern.isEmpty()) {
        st = new HeaderTerm(name, pattern);
    } else {
        throw (new XPathException(this, "pattern attribute must be specified for term with type: " + ((Element) terms).getAttribute("type")));
    }
    return (st);
}
Also used : XPathException(org.exist.xquery.XPathException) Element(org.w3c.dom.Element) HeaderTerm(jakarta.mail.search.HeaderTerm) SearchTerm(jakarta.mail.search.SearchTerm)

Example 2 with HeaderTerm

use of jakarta.mail.search.HeaderTerm in project simple-java-mail by bbottema.

the class ImmutableDelegatingSMTPMessageTest method testIrrelevantGettersAndAllowedMutatorsAreDelegatedProperly.

@Test
public void testIrrelevantGettersAndAllowedMutatorsAreDelegatedProperly() throws MessagingException, IOException {
    MimeMessage mockMmessage = mock(MimeMessage.class);
    ImmutableDelegatingSMTPMessage subject = new ImmutableDelegatingSMTPMessage(mockMmessage, "envelop@from.com");
    final ByteArrayInputStream dummyIs = new ByteArrayInputStream(new byte[] {});
    when(mockMmessage.getRawInputStream()).thenReturn(dummyIs);
    when(mockMmessage.getInputStream()).thenReturn(dummyIs);
    assertThat(subject.getRawInputStream()).isSameAs(dummyIs);
    verify(mockMmessage).getRawInputStream();
    assertThat(subject.getInputStream()).isSameAs(dummyIs);
    verify(mockMmessage).getInputStream();
    assertThat(subject.isMimeType("moo")).isFalse();
    verify(mockMmessage).isMimeType("moo");
    final Message dummyMessage = mock(Message.class);
    when(mockMmessage.reply(anyBoolean())).thenReturn(dummyMessage);
    assertThat(subject.reply(true)).isSameAs(dummyMessage);
    verify(mockMmessage).reply(true);
    when(mockMmessage.reply(anyBoolean(), anyBoolean())).thenReturn(dummyMessage);
    assertThat(subject.reply(false, true)).isSameAs(dummyMessage);
    verify(mockMmessage).reply(false, true);
    assertThat(subject.isSet(ANSWERED)).isFalse();
    verify(mockMmessage).isSet(ANSWERED);
    HeaderTerm term = new HeaderTerm("name", "pattern");
    assertThat(subject.match(term)).isFalse();
    verify(mockMmessage).match(term);
    OutputStream bos = new ByteArrayOutputStream();
    subject.writeTo(bos);
    verify(mockMmessage).writeTo(bos);
    subject.writeTo(bos, new String[] { "a", "b" });
    verify(mockMmessage).writeTo(bos, new String[] { "a", "b" });
    subject.saveChanges();
    verify(mockMmessage).saveChanges();
}
Also used : EmailConverter.emailToMimeMessage(org.simplejavamail.converter.EmailConverter.emailToMimeMessage) MimeMessage(jakarta.mail.internet.MimeMessage) SMTPMessage(com.sun.mail.smtp.SMTPMessage) Message(jakarta.mail.Message) EmailConverter.emailToMimeMessage(org.simplejavamail.converter.EmailConverter.emailToMimeMessage) MimeMessage(jakarta.mail.internet.MimeMessage) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) HeaderTerm(jakarta.mail.search.HeaderTerm) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Aggregations

HeaderTerm (jakarta.mail.search.HeaderTerm)2 SMTPMessage (com.sun.mail.smtp.SMTPMessage)1 Message (jakarta.mail.Message)1 MimeMessage (jakarta.mail.internet.MimeMessage)1 SearchTerm (jakarta.mail.search.SearchTerm)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 XPathException (org.exist.xquery.XPathException)1 Test (org.junit.Test)1 EmailConverter.emailToMimeMessage (org.simplejavamail.converter.EmailConverter.emailToMimeMessage)1 Element (org.w3c.dom.Element)1