List of usage examples for javax.mail Flags Flags
public Flags()
From source file:org.apache.james.pop3server.POP3ServerTest.java
@Test public void testDeadlockOnRetr() throws Exception { finishSetUp(pop3Configuration); pop3Client = new POP3Client(); pop3Client.connect("127.0.0.1", pop3Port); usersRepository.addUser("foo6", "bar6"); MailboxSession session = mailboxManager.login("foo6", "bar6", LoggerFactory.getLogger("Test")); MailboxPath mailboxPath = MailboxPath.inbox(session); mailboxManager.startProcessingRequest(session); if (!mailboxManager.mailboxExists(mailboxPath, session)) { mailboxManager.createMailbox(mailboxPath, session); }/*from www .j ava2s . com*/ ByteArrayOutputStream out = new ByteArrayOutputStream(); out.write(content); byte[] bigMail = new byte[1024 * 1024 * 10]; int c = 0; for (int i = 0; i < bigMail.length; i++) { bigMail[i] = 'X'; c++; if (c == 1000 || i + 3 == bigMail.length) { c = 0; bigMail[++i] = '\r'; bigMail[++i] = '\n'; } } out.write(bigMail); bigMail = null; mailboxManager.getMailbox(mailboxPath, session).appendMessage(new ByteArrayInputStream(out.toByteArray()), new Date(), session, false, new Flags()); mailboxManager.startProcessingRequest(session); pop3Client.login("foo6", "bar6"); assertEquals(1, pop3Client.getState()); POP3MessageInfo[] entries = pop3Client.listMessages(); assertNotNull(entries); assertEquals(1, entries.length); assertEquals(1, pop3Client.getState()); Reader r = pop3Client.retrieveMessage(entries[0].number); assertNotNull(r); r.close(); mailboxManager.deleteMailbox(mailboxPath, session); }
From source file:org.apache.james.imap.processor.base.MailboxEventAnalyserTest.java
@Test public void testShouldNotSetUidWhenSystemFlagChangeSameSessionInSilentMode() throws Exception { MyMailboxSession mSession = new MyMailboxSession(BASE_SESSION_ID); MyImapSession imapsession = new MyImapSession(mSession); SelectedMailboxImpl analyser = new SelectedMailboxImpl(mockManager, imapsession, mailboxPath); final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(mSession, Arrays.asList(345L), Arrays.asList(new UpdatedFlags(345, -1, new Flags(), new Flags())), mailboxPath);//w ww .j a v a2 s . c om analyser.event(update); analyser.setSilentFlagChanges(true); analyser.event(update); final Iterator<Long> iterator = analyser.flagUpdateUids().iterator(); assertNotNull(iterator); assertFalse(iterator.hasNext()); }
From source file:org.apache.james.imap.processor.base.MailboxEventAnalyserTest.java
@Test public void testShouldNotSetUidWhenOnlyRecentFlagUpdated() throws Exception { MyMailboxSession mSession = new MyMailboxSession(BASE_SESSION_ID); MyImapSession imapsession = new MyImapSession(mSession); SelectedMailboxImpl analyser = new SelectedMailboxImpl(mockManager, imapsession, mailboxPath); final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(mSession, Arrays.asList(886L),//w w w . j a v a 2s . co m Arrays.asList(new UpdatedFlags(886, -1, new Flags(), new Flags(Flags.Flag.RECENT))), mailboxPath); analyser.event(update); final Iterator<Long> iterator = analyser.flagUpdateUids().iterator(); assertNotNull(iterator); assertFalse(iterator.hasNext()); }
From source file:org.apache.james.jmap.methods.integration.SetMessagesMethodTest.java
@Test @Ignore("Jackson json deserializer stops after first error found") public void setMessagesShouldRejectUpdateWhenPropertiesHaveWrongTypes() throws MailboxException { jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), new Date(), false, new Flags()); await();/* ww w .j a v a 2 s . c om*/ String messageId = username + "|mailbox|1"; given().header("Authorization", accessToken.serialize()).body(String.format( "[[\"setMessages\", {\"update\": {\"%s\" : { \"isUnread\" : \"123\", \"isFlagged\" : 456 } } }, \"#0\"]]", messageId)).when().post("/jmap").then().log().ifValidationFails().statusCode(200) .body(NAME, equalTo("messagesSet")).body(NOT_UPDATED, hasKey(messageId)) .body(NOT_UPDATED + "[\"" + messageId + "\"].type", equalTo("invalidProperties")) .body(NOT_UPDATED + "[\"" + messageId + "\"].properties", hasSize(2)) .body(NOT_UPDATED + "[\"" + messageId + "\"].properties[0]", equalTo("isUnread")) .body(NOT_UPDATED + "[\"" + messageId + "\"].properties[1]", equalTo("isFlagged")) .body(ARGUMENTS + ".updated", hasSize(0)); }
From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java
@Test public void getMessageListShouldSupportHasAttachmentSetToTrue() throws Exception { mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(), false, new Flags()); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(), false, new Flags()); await();//ww w . j a v a 2 s. c om given().header("Authorization", accessToken.serialize()) .body("[[\"getMessageList\", {\"filter\":{\"hasAttachment\":\"true\"}}, \"#0\"]]").when() .post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList")) .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize())); }
From source file:org.apache.james.jmap.methods.integration.SetMessagesMethodTest.java
@Test public void setMessagesShouldMarkMessageAsAnsweredWhenIsAnsweredPassed() throws MailboxException { // Given//from ww w. j ava 2 s.co m jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), new Date(), false, new Flags()); await(); String presumedMessageId = username + "|mailbox|1"; // When given().header("Authorization", accessToken.serialize()) .body(String.format( "[[\"setMessages\", {\"update\": {\"%s\" : { \"isAnswered\" : true } } }, \"#0\"]]", presumedMessageId)) .when().post("/jmap") // Then .then().log().ifValidationFails().spec(getSetMessagesUpdateOKResponseAssertions(presumedMessageId)); }
From source file:org.apache.james.pop3server.POP3ServerTest.java
private void setupTestMails(MailboxSession session, MessageManager mailbox) throws MailboxException { mailbox.appendMessage(new ByteArrayInputStream(content), new Date(), session, true, new Flags()); byte[] content2 = ("EMPTY").getBytes(); mailbox.appendMessage(new ByteArrayInputStream(content2), new Date(), session, true, new Flags()); }
From source file:org.apache.james.jmap.methods.integration.SetMessagesMethodTest.java
@Test public void setMessagesShouldMarkAsAnsweredWhenIsAnsweredPassed() throws MailboxException { // Given// w ww . j ava2s . c om jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), new Date(), false, new Flags()); await(); String presumedMessageId = username + "|mailbox|1"; given().header("Authorization", accessToken.serialize()) .body(String.format( "[[\"setMessages\", {\"update\": {\"%s\" : { \"isAnswered\" : true } } }, \"#0\"]]", presumedMessageId)) // When .when().post("/jmap"); // Then with().header("Authorization", accessToken.serialize()) .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]").post("/jmap") .then().log().ifValidationFails().body(NAME, equalTo("messages")) .body(ARGUMENTS + ".list", hasSize(1)).body(ARGUMENTS + ".list[0].isAnswered", equalTo(true)); }
From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java
@Test public void getMessageListShouldSupportHasAttachmentSetToFalse() throws Exception { mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(), false, new Flags()); ComposedMessageId message3 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(), false, new Flags()); await();//from w w w .j a v a 2 s . c om given().header("Authorization", accessToken.serialize()) .body("[[\"getMessageList\", {\"filter\":{\"hasAttachment\":\"false\"}}, \"#0\"]]").when() .post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList")) .body(ARGUMENTS + ".messageIds", contains(message1.getMessageId().serialize(), message3.getMessageId().serialize())); }
From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java
@Test public void getMessageListShouldReturnAllMessagesWhenSingleMailboxNoParameters() throws Exception { mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); await();//from w w w . j a v a 2s . c o m given().header("Authorization", accessToken.serialize()).body("[[\"getMessageList\", {}, \"#0\"]]").when() .post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList")) .body(ARGUMENTS + ".messageIds", containsInAnyOrder(message1.getMessageId().serialize(), message2.getMessageId().serialize())); }