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