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);
}
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();
}
Aggregations