Get rid of trivial static factory methods
This commit is contained in:
parent
a7abf62dc1
commit
84cef1d8b1
25 changed files with 66 additions and 86 deletions
|
@ -461,7 +461,7 @@ public class MessageTest {
|
|||
}
|
||||
|
||||
private MimeMessage sampleMessage() throws MessagingException, IOException {
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
message.setFrom(new Address("from@example.com"));
|
||||
message.setRecipient(RecipientType.TO, new Address("to@example.com"));
|
||||
message.setSubject("Test Message");
|
||||
|
|
|
@ -61,17 +61,13 @@ public class MimeMessage extends Message {
|
|||
private String serverExtra;
|
||||
|
||||
|
||||
public static MimeMessage createMimeMessage() {
|
||||
return new MimeMessage();
|
||||
}
|
||||
|
||||
public static MimeMessage parseMimeMessage(InputStream in, boolean recurse) throws IOException, MessagingException {
|
||||
MimeMessage mimeMessage = createMimeMessage();
|
||||
MimeMessage mimeMessage = new MimeMessage();
|
||||
mimeMessage.parse(in, recurse);
|
||||
return mimeMessage;
|
||||
}
|
||||
|
||||
protected MimeMessage() {
|
||||
public MimeMessage() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -478,7 +474,7 @@ public class MimeMessage extends Message {
|
|||
expect(Part.class);
|
||||
Part part = (Part) stack.peek();
|
||||
|
||||
MimeMessage m = createMimeMessage();
|
||||
MimeMessage m = new MimeMessage();
|
||||
part.setBody(m);
|
||||
stack.addFirst(m);
|
||||
}
|
||||
|
@ -615,7 +611,7 @@ public class MimeMessage extends Message {
|
|||
|
||||
@Override
|
||||
public MimeMessage clone() {
|
||||
MimeMessage message = createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
copy(message);
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -501,7 +501,7 @@ class ImapFolder extends Folder<ImapMessage> {
|
|||
|
||||
@Override
|
||||
public ImapMessage getMessage(String uid) throws MessagingException {
|
||||
return ImapMessage.createImapMessage(uid, this);
|
||||
return new ImapMessage(uid, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -635,7 +635,7 @@ class ImapFolder extends Folder<ImapMessage> {
|
|||
listener.messageStarted(uid, i, count);
|
||||
}
|
||||
|
||||
ImapMessage message = ImapMessage.createImapMessage(uid, this);
|
||||
ImapMessage message = new ImapMessage(uid, this);
|
||||
messages.add(message);
|
||||
|
||||
if (listener != null) {
|
||||
|
|
|
@ -587,7 +587,7 @@ class ImapFolderPusher extends ImapFolder {
|
|||
|
||||
List<Message> messages = new ArrayList<Message>();
|
||||
for (long uid = startUid; uid <= newUid; uid++) {
|
||||
ImapMessage message = ImapMessage.createImapMessage(Long.toString(uid), ImapFolderPusher.this);
|
||||
ImapMessage message = new ImapMessage(Long.toString(uid), ImapFolderPusher.this);
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
|
@ -626,7 +626,7 @@ class ImapFolderPusher extends ImapFolder {
|
|||
}
|
||||
|
||||
for (String uid : removeUids) {
|
||||
ImapMessage message = ImapMessage.createImapMessage(uid, ImapFolderPusher.this);
|
||||
ImapMessage message = new ImapMessage(uid, ImapFolderPusher.this);
|
||||
|
||||
try {
|
||||
message.setFlagInternal(Flag.DELETED, true);
|
||||
|
@ -662,7 +662,7 @@ class ImapFolderPusher extends ImapFolder {
|
|||
List<Message> messages = new ArrayList<Message>(count);
|
||||
|
||||
for (long uid = startUid; uid < uidNext; uid++) {
|
||||
ImapMessage message = ImapMessage.createImapMessage(Long.toString(uid), ImapFolderPusher.this);
|
||||
ImapMessage message = new ImapMessage(Long.toString(uid), ImapFolderPusher.this);
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,7 @@ import com.fsck.k9.mail.internet.MimeMessage;
|
|||
|
||||
|
||||
class ImapMessage extends MimeMessage {
|
||||
static ImapMessage createImapMessage(String uid, Folder folder) {
|
||||
return new ImapMessage(uid, folder);
|
||||
}
|
||||
|
||||
private ImapMessage(String uid, Folder folder) {
|
||||
ImapMessage(String uid, Folder folder) {
|
||||
this.mUid = uid;
|
||||
this.mFolder = folder;
|
||||
}
|
||||
|
|
|
@ -586,7 +586,7 @@ public class Pop3Store extends RemoteStore {
|
|||
public Pop3Message getMessage(String uid) throws MessagingException {
|
||||
Pop3Message message = mUidToMsgMap.get(uid);
|
||||
if (message == null) {
|
||||
message = Pop3Message.createPop3Message(uid, this);
|
||||
message = new Pop3Message(uid, this);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
@ -668,7 +668,7 @@ public class Pop3Store extends RemoteStore {
|
|||
return;
|
||||
}
|
||||
String msgUid = uidParts[2];
|
||||
message = Pop3Message.createPop3Message(msgUid, this);
|
||||
message = new Pop3Message(msgUid, this);
|
||||
indexMessage(msgNum, message);
|
||||
}
|
||||
}
|
||||
|
@ -708,7 +708,7 @@ public class Pop3Store extends RemoteStore {
|
|||
if (msgNum >= start && msgNum <= end) {
|
||||
Pop3Message message = mMsgNumToMsgMap.get(msgNum);
|
||||
if (message == null) {
|
||||
message = Pop3Message.createPop3Message(msgUid, this);
|
||||
message = new Pop3Message(msgUid, this);
|
||||
indexMessage(msgNum, message);
|
||||
}
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ public class Pop3Store extends RemoteStore {
|
|||
|
||||
Pop3Message message = mUidToMsgMap.get(msgUid);
|
||||
if (message == null) {
|
||||
message = Pop3Message.createPop3Message(msgUid, this);
|
||||
message = new Pop3Message(msgUid, this);
|
||||
}
|
||||
indexMessage(msgNum, message);
|
||||
}
|
||||
|
@ -1184,11 +1184,7 @@ public class Pop3Store extends RemoteStore {
|
|||
}//Pop3Folder
|
||||
|
||||
static class Pop3Message extends MimeMessage {
|
||||
public static Pop3Message createPop3Message(String uid, Pop3Folder folder) {
|
||||
return new Pop3Message(uid, folder);
|
||||
}
|
||||
|
||||
private Pop3Message(String uid, Pop3Folder folder) {
|
||||
Pop3Message(String uid, Pop3Folder folder) {
|
||||
mUid = uid;
|
||||
mFolder = folder;
|
||||
mSize = -1;
|
||||
|
|
|
@ -225,7 +225,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
|
|||
|
||||
@Override
|
||||
public WebDavMessage getMessage(String uid) throws MessagingException {
|
||||
return WebDavMessage.createWebDavMessage(uid, this);
|
||||
return new WebDavMessage(uid, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -265,7 +265,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
|
|||
if (listener != null) {
|
||||
listener.messageStarted(uids[i], i, uidsLength);
|
||||
}
|
||||
WebDavMessage message = WebDavMessage.createWebDavMessage(uids[i], this);
|
||||
WebDavMessage message = new WebDavMessage(uids[i], this);
|
||||
message.setUrl(uidToUrl.get(uids[i]));
|
||||
messages.add(message);
|
||||
|
||||
|
@ -696,7 +696,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
|
|||
+ " while sending/appending message. Response = "
|
||||
+ response.getStatusLine().toString() + " for message " + messageURL);
|
||||
}
|
||||
WebDavMessage retMessage = WebDavMessage.createWebDavMessage(message.getUid(), this);
|
||||
WebDavMessage retMessage = new WebDavMessage(message.getUid(), this);
|
||||
|
||||
retMessage.setUrl(messageURL);
|
||||
retMessages.add(retMessage);
|
||||
|
|
|
@ -21,11 +21,8 @@ import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
|
|||
class WebDavMessage extends MimeMessage {
|
||||
private String mUrl = "";
|
||||
|
||||
static WebDavMessage createWebDavMessage(String uid, Folder folder) {
|
||||
return new WebDavMessage(uid, folder);
|
||||
}
|
||||
|
||||
private WebDavMessage(String uid, Folder folder) {
|
||||
WebDavMessage(String uid, Folder folder) {
|
||||
this.mUid = uid;
|
||||
this.mFolder = folder;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class CharsetSupportTest {
|
|||
|
||||
charsetOnMail = "CP932";
|
||||
expect = "shift_jis";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, MimeMessage.createMimeMessage()));
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, new MimeMessage()));
|
||||
|
||||
// charsetOnMail = "koi8-u";
|
||||
// expect = "koi8-r";
|
||||
|
@ -28,73 +28,73 @@ public class CharsetSupportTest {
|
|||
|
||||
MimeMessage message;
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@docomo.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-docomo-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@dwmail.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-docomo-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@pdx.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-docomo-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@willcom.com");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-docomo-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@emnet.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-docomo-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@emobile.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-docomo-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@softbank.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-softbank-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@vodafone.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-softbank-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@disney.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-softbank-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@vertuclub.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-softbank-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@ezweb.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-kddi-shift_jis-2007";
|
||||
assertEquals(expect, CharsetSupport.fixupCharset(charsetOnMail, message));
|
||||
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setHeader("From", "aaa@ido.ne.jp");
|
||||
charsetOnMail = "shift_jis";
|
||||
expect = "x-kddi-shift_jis-2007";
|
||||
|
|
|
@ -117,7 +117,7 @@ public class ListHeadersTest {
|
|||
}
|
||||
|
||||
private MimeMessage buildMimeMessageWithListPostValue(String... values) throws MessagingException {
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
for (String value : values) {
|
||||
message.addHeader("List-Post", value);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class MessageIdGeneratorTest {
|
|||
|
||||
@Test
|
||||
public void generateMessageId_withFromAndReplyToAddress() throws Exception {
|
||||
Message message = MimeMessage.createMimeMessage();
|
||||
Message message = new MimeMessage();
|
||||
message.setFrom(new Address("alice@example.org"));
|
||||
message.setReplyTo(Address.parse("bob@example.com"));
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class MessageIdGeneratorTest {
|
|||
|
||||
@Test
|
||||
public void generateMessageId_withReplyToAddress() throws Exception {
|
||||
Message message = MimeMessage.createMimeMessage();
|
||||
Message message = new MimeMessage();
|
||||
message.setReplyTo(Address.parse("bob@example.com"));
|
||||
|
||||
String result = messageIdGenerator.generateMessageId(message);
|
||||
|
@ -51,7 +51,7 @@ public class MessageIdGeneratorTest {
|
|||
|
||||
@Test
|
||||
public void generateMessageId_withoutRelevantHeaders() throws Exception {
|
||||
Message message = MimeMessage.createMimeMessage();
|
||||
Message message = new MimeMessage();
|
||||
|
||||
String result = messageIdGenerator.generateMessageId(message);
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ public class WebDavFolderTest {
|
|||
|
||||
List<WebDavMessage> messages = new ArrayList<>();
|
||||
for (int i = 0; i < 25; i++) {
|
||||
WebDavMessage message = WebDavMessage.createWebDavMessage("message" + i, folder);
|
||||
WebDavMessage message = new WebDavMessage("message" + i, folder);
|
||||
message.setUrl("http://example.org/Exchange/user/Inbox/message" + i + ".EML");
|
||||
messages.add(message);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class WebDavMessageTest {
|
|||
MockitoAnnotations.initMocks(this);
|
||||
when(mockFolder.getName()).thenReturn("Inbox");
|
||||
when(mockFolder.getUrl()).thenReturn("http://example.org/Inbox");
|
||||
message = WebDavMessage.createWebDavMessage("message1", mockFolder);
|
||||
message = new WebDavMessage("message1", mockFolder);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -95,7 +95,7 @@ public class ReconstructMessageFromDatabaseTest extends ApplicationTestCase<K9>
|
|||
public void testAddMissingPart() throws MessagingException, IOException {
|
||||
LocalFolder folder = createFolderInDatabase();
|
||||
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
message.addHeader("To", "to@example.com");
|
||||
message.addHeader("MIME-Version", "1.0");
|
||||
message.addHeader("Content-Type", "text/plain");
|
||||
|
|
|
@ -33,22 +33,22 @@ public class EmailProviderTest extends ProviderTestCase2<EmailProvider> {
|
|||
}
|
||||
|
||||
private void buildMessages() throws MessagingException {
|
||||
message = MimeMessage.createMimeMessage();
|
||||
message = new MimeMessage();
|
||||
message.setSubject("Test Subject");
|
||||
message.setSentDate(new GregorianCalendar(2016, 1, 2).getTime(), false);
|
||||
message.setMessageId("<uid001@email.com>");
|
||||
|
||||
laterMessage = MimeMessage.createMimeMessage();
|
||||
laterMessage = new MimeMessage();
|
||||
laterMessage.setSubject("Test Subject2");
|
||||
laterMessage.setSentDate(new GregorianCalendar(2016, 1, 3).getTime(), false);
|
||||
|
||||
reply = MimeMessage.createMimeMessage();
|
||||
reply = new MimeMessage();
|
||||
reply.setSubject("Re: Test Subject");
|
||||
reply.setSentDate(new GregorianCalendar(2016, 1, 3).getTime(), false);
|
||||
reply.setMessageId("<uid002@email.com>");
|
||||
reply.setInReplyTo("<uid001@email.com>");
|
||||
|
||||
replyAtSameTime = MimeMessage.createMimeMessage();
|
||||
replyAtSameTime = new MimeMessage();
|
||||
replyAtSameTime.setSubject("Re: Test Subject");
|
||||
replyAtSameTime.setSentDate(new GregorianCalendar(2016, 1, 2).getTime(), false);
|
||||
replyAtSameTime.setMessageId("<uid002@email.com>");
|
||||
|
@ -301,7 +301,7 @@ public class EmailProviderTest extends ProviderTestCase2<EmailProvider> {
|
|||
Account account = Preferences.getPreferences(getContext()).newAccount();
|
||||
account.getUuid();
|
||||
|
||||
Message message = MimeMessage.createMimeMessage();
|
||||
Message message = new MimeMessage();
|
||||
message.setSubject("Test Subject");
|
||||
message.setSentDate(new GregorianCalendar(2016, 1, 2).getTime(), false);
|
||||
|
||||
|
|
|
@ -2413,7 +2413,7 @@ public class MessagingController {
|
|||
|
||||
Store localStore = account.getLocalStore();
|
||||
LocalFolder localFolder = (LocalFolder)localStore.getFolder(account.getErrorFolderName());
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
|
||||
MimeMessageHelper.setBody(message, new TextBody(body));
|
||||
message.setFlag(Flag.X_DOWNLOADED_FULL, true);
|
||||
|
|
|
@ -739,7 +739,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
((Multipart) parentPart.getBody()).addBodyPart(bodyPart);
|
||||
part = bodyPart;
|
||||
} else if (MimeUtility.isMessage(parentMimeType)) {
|
||||
Message innerMessage = MimeMessage.createMimeMessage();
|
||||
Message innerMessage = new MimeMessage();
|
||||
parentPart.setBody(innerMessage);
|
||||
part = innerMessage;
|
||||
} else {
|
||||
|
@ -833,8 +833,7 @@ public class LocalFolder extends Folder<LocalMessage> implements Serializable {
|
|||
public LocalMessage doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
|
||||
try {
|
||||
open(OPEN_MODE_RW);
|
||||
LocalMessage message =
|
||||
LocalMessage.createLocalMessage(LocalFolder.this.localStore, uid, LocalFolder.this);
|
||||
LocalMessage message = new LocalMessage(LocalFolder.this.localStore, uid, LocalFolder.this);
|
||||
Cursor cursor = null;
|
||||
|
||||
try {
|
||||
|
|
|
@ -41,15 +41,11 @@ public class LocalMessage extends MimeMessage {
|
|||
private PreviewType previewType;
|
||||
|
||||
|
||||
static LocalMessage createLocalMessage(LocalStore localStore, String uid, Folder folder) {
|
||||
return new LocalMessage(localStore, uid, folder);
|
||||
}
|
||||
|
||||
private LocalMessage(LocalStore localStore) {
|
||||
this.localStore = localStore;
|
||||
}
|
||||
|
||||
private LocalMessage(LocalStore localStore, String uid, Folder folder) {
|
||||
LocalMessage(LocalStore localStore, String uid, Folder folder) {
|
||||
this.localStore = localStore;
|
||||
this.mUid = uid;
|
||||
this.mFolder = folder;
|
||||
|
|
|
@ -602,7 +602,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
cursor = db.rawQuery(queryString + " LIMIT 10", placeHolders);
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
LocalMessage message = LocalMessage.createLocalMessage(LocalStore.this, null, folder);
|
||||
LocalMessage message = new LocalMessage(LocalStore.this, null, folder);
|
||||
message.populateFromGetMessageCursor(cursor);
|
||||
|
||||
messages.add(message);
|
||||
|
@ -615,7 +615,7 @@ public class LocalStore extends Store implements Serializable {
|
|||
cursor = db.rawQuery(queryString + " LIMIT -1 OFFSET 10", placeHolders);
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
LocalMessage message = LocalMessage.createLocalMessage(LocalStore.this, null, folder);
|
||||
LocalMessage message = new LocalMessage(LocalStore.this, null, folder);
|
||||
message.populateFromGetMessageCursor(cursor);
|
||||
|
||||
messages.add(message);
|
||||
|
|
|
@ -81,7 +81,7 @@ public class MimePartStreamParser {
|
|||
} else {
|
||||
Part part = (Part) stack.peek();
|
||||
|
||||
Message innerMessage = MimeMessage.createMimeMessage();
|
||||
Message innerMessage = new MimeMessage();
|
||||
part.setBody(innerMessage);
|
||||
|
||||
stack.push(innerMessage);
|
||||
|
|
|
@ -84,7 +84,7 @@ public abstract class MessageBuilder {
|
|||
protected MimeMessage build() throws MessagingException {
|
||||
//FIXME: check arguments
|
||||
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
|
||||
buildHeader(message);
|
||||
buildBody(message);
|
||||
|
|
|
@ -35,7 +35,7 @@ public class MessageDecryptVerifierTest {
|
|||
|
||||
@Test
|
||||
public void findEncryptedPartsShouldReturnEmptyListForEmptyMessage() throws Exception {
|
||||
MimeMessage emptyMessage = MimeMessage.createMimeMessage();
|
||||
MimeMessage emptyMessage = new MimeMessage();
|
||||
|
||||
List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(emptyMessage);
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class MessageDecryptVerifierTest {
|
|||
|
||||
@Test
|
||||
public void findEncryptedPartsShouldReturnEmptyListForSimpleMessage() throws Exception {
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
message.setBody(new TextBody("message text"));
|
||||
|
||||
List<Part> encryptedParts = MessageDecryptVerifier.findEncryptedParts(message);
|
||||
|
@ -54,7 +54,7 @@ public class MessageDecryptVerifierTest {
|
|||
|
||||
@Test
|
||||
public void findEncryptedPartsShouldReturnEmptyEncryptedPart() throws Exception {
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
MimeMultipart multipartEncrypted = MimeMultipart.createMimeMultipart();
|
||||
multipartEncrypted.setSubType("encrypted");
|
||||
MimeMessageHelper.setBody(message, multipartEncrypted);
|
||||
|
@ -68,7 +68,7 @@ public class MessageDecryptVerifierTest {
|
|||
|
||||
@Test
|
||||
public void findEncryptedPartsShouldReturnMultipleEncryptedParts() throws Exception {
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
MimeMultipart multipartMixed = MimeMultipart.createMimeMultipart();
|
||||
multipartMixed.setSubType("mixed");
|
||||
MimeMessageHelper.setBody(message, multipartMixed);
|
||||
|
@ -273,7 +273,7 @@ public class MessageDecryptVerifierTest {
|
|||
}
|
||||
|
||||
MimeMessage messageFromBody(BodyPart bodyPart) throws MessagingException {
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
MimeMessageHelper.setBody(message, bodyPart.getBody());
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class MessageViewInfoExtractorTest {
|
|||
TextBody body = new TextBody(BODY_TEXT);
|
||||
|
||||
// Create message
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
MimeMessageHelper.setBody(message, body);
|
||||
|
||||
// Prepare fixture
|
||||
|
@ -95,7 +95,7 @@ public class MessageViewInfoExtractorTest {
|
|||
TextBody body = new TextBody(BODY_TEXT);
|
||||
|
||||
// Create message
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
message.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/plain");
|
||||
MimeMessageHelper.setBody(message, body);
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class MessageViewInfoExtractorTest {
|
|||
TextBody body = new TextBody(bodyText);
|
||||
|
||||
// Create message
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
message.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/html");
|
||||
MimeMessageHelper.setBody(message, body);
|
||||
|
||||
|
@ -158,7 +158,7 @@ public class MessageViewInfoExtractorTest {
|
|||
multipart.addBodyPart(bodyPart2);
|
||||
|
||||
// Create message
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
MimeMessageHelper.setBody(message, multipart);
|
||||
|
||||
// Extract text
|
||||
|
@ -201,7 +201,7 @@ public class MessageViewInfoExtractorTest {
|
|||
TextBody innerBody = new TextBody(innerBodyText);
|
||||
|
||||
// Create message/rfc822 body
|
||||
MimeMessage innerMessage = MimeMessage.createMimeMessage();
|
||||
MimeMessage innerMessage = new MimeMessage();
|
||||
innerMessage.addSentDate(new Date(112, 02, 17), false);
|
||||
innerMessage.setRecipients(RecipientType.TO, new Address[] { new Address("to@example.com") });
|
||||
innerMessage.setSubject("Subject");
|
||||
|
@ -217,7 +217,7 @@ public class MessageViewInfoExtractorTest {
|
|||
multipart.addBodyPart(bodyPart2);
|
||||
|
||||
// Create message
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
MimeMessageHelper.setBody(message, multipart);
|
||||
|
||||
// Extract text
|
||||
|
|
|
@ -52,7 +52,7 @@ public class MessageCreationHelper {
|
|||
}
|
||||
|
||||
private static Message createMessage(String mimeType, Body body) throws MessagingException {
|
||||
MimeMessage message = MimeMessage.createMimeMessage();
|
||||
MimeMessage message = new MimeMessage();
|
||||
message.setBody(body);
|
||||
message.setHeader(MimeHeader.HEADER_CONTENT_TYPE, mimeType);
|
||||
|
||||
|
|
|
@ -103,6 +103,6 @@ public class MessagePreviewCreatorTest {
|
|||
}
|
||||
|
||||
private Message createDummyMessage() {
|
||||
return MimeMessage.createMimeMessage();
|
||||
return new MimeMessage();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue