@Test
public void testAllowedHeaders() throws Exception {
assumeEnvironment(Environment.APPSPOT, Environment.CAPEDWARF);
MimeProperties mp = new MimeProperties();
mp.subject = "Allowed-Headers-Test-" + System.currentTimeMillis();
mp.from = getEmail("from-test-header", EmailMessageField.FROM);
mp.to = getEmail("to-test-header", EmailMessageField.TO);
mp.body = BODY;
MailService.Message msg = createMailServiceMessage(mp);
msg.setTextBody(BODY);
// https://developers.google.com/appengine/docs/java/mail/#Sending_Mail_with_Headers
Set<MailService.Header> headers = new HashSet<>();
Map<String, String> headersMap = createExpectedHeaders();
for (Map.Entry entry : headersMap.entrySet()) {
headers.add(new MailService.Header(entry.getKey().toString(), entry.getValue().toString()));
}
msg.setHeaders(headers);
mailService.send(msg);
MimeProperties receivedMp = pollForMatchingMail(mp);
assertHeadersExist(receivedMp, createExpectedHeadersVerifyList(headersMap));
}