Source Code Cross Referenced for MarkFolderAsReadCommandTest.java in  » Mail-Clients » columba-1.4 » org » columba » mail » folder » command » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » columba 1.4 » org.columba.mail.folder.command 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //The contents of this file are subject to the Mozilla Public License Version 1.1
002:        //(the "License"); you may not use this file except in compliance with the
003:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004:        //
005:        //Software distributed under the License is distributed on an "AS IS" basis,
006:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007:        //for the specific language governing rights and
008:        //limitations under the License.
009:        //
010:        //The Original Code is "The Columba Project"
011:        //
012:        //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014:        //
015:        //All Rights Reserved.
016:        package org.columba.mail.folder.command;
017:
018:        import java.io.ByteArrayInputStream;
019:        import java.io.ByteArrayOutputStream;
020:        import java.io.IOException;
021:        import java.io.InputStream;
022:        import java.io.OutputStreamWriter;
023:
024:        import org.columba.core.command.NullWorkerStatusController;
025:        import org.columba.mail.command.MailFolderCommandReference;
026:        import org.columba.mail.folder.AbstractFolderTst;
027:        import org.columba.mail.folder.AbstractMessageFolder;
028:        import org.columba.mail.folder.MailboxTstFactory;
029:
030:        /**
031:         * @author redsolo
032:         */
033:        public class MarkFolderAsReadCommandTest extends AbstractFolderTst {
034:
035:            public MarkFolderAsReadCommandTest(String arg0) {
036:                super (arg0);
037:            }
038:
039:            /**
040:             * @param factory folder factory
041:             * @param test the name of the test
042:             */
043:            public MarkFolderAsReadCommandTest(MailboxTstFactory factory,
044:                    String test) {
045:                super (factory, test);
046:            }
047:
048:            /**
049:             * Test to mark a folder as read.
050:             * @throws Exception thrown by the command itself.
051:             */
052:            public void testExecute() throws Exception {
053:                AbstractMessageFolder folder = getSourceFolder();
054:
055:                Object uid1 = folder.addMessage(createMessageStream("sub1",
056:                        "body1"));
057:                Object uid2 = folder.addMessage(createMessageStream("sub2",
058:                        "body2"));
059:                Object uid3 = folder.addMessage(createMessageStream("sub3",
060:                        "body3"));
061:                Object uid4 = folder.addMessage(createMessageStream("sub4",
062:                        "body4"));
063:                Object uid5 = folder.addMessage(createMessageStream("sub5",
064:                        "body5"));
065:
066:                assertNotNull("Msg 1's uid was null", uid1);
067:                assertNotNull("Msg 2's uid was null", uid2);
068:                assertNotNull("Msg 3's uid was null", uid3);
069:
070:                folder.markMessage(new Object[] { uid1, uid3, uid5 },
071:                        MarkMessageCommand.MARK_AS_UNREAD);
072:                folder.markMessage(new Object[] { uid2, uid4 },
073:                        MarkMessageCommand.MARK_AS_READ);
074:
075:                assertNotNull("Flags for msg 1 was null", folder.getFlags(uid1));
076:                assertFalse("Msg 1 is read", folder.getFlags(uid1).getSeen());
077:                assertNotNull("Flags for msg 2 was null", folder.getFlags(uid2));
078:                assertTrue("Msg 2 is read", folder.getFlags(uid2).getSeen());
079:                assertNotNull("Flags for msg 3 was null", folder.getFlags(uid3));
080:                assertFalse("Msg 3 is read", folder.getFlags(uid3).getSeen());
081:
082:                MailFolderCommandReference references = new MailFolderCommandReference(
083:                        folder);
084:                MarkFolderAsReadCommand command = new MarkFolderAsReadCommand(
085:                        references);
086:                command.execute(NullWorkerStatusController.getInstance());
087:
088:                assertEquals("Message 1 isnt read", true, folder.getFlags(uid1)
089:                        .getSeen());
090:                assertEquals("Message 2 isnt read", true, folder.getFlags(uid2)
091:                        .getSeen());
092:                assertEquals("Message 3 isnt read", true, folder.getFlags(uid3)
093:                        .getSeen());
094:                assertEquals("Message 4 isnt read", true, folder.getFlags(uid4)
095:                        .getSeen());
096:                assertEquals("Message 5 isnt read", true, folder.getFlags(uid5)
097:                        .getSeen());
098:            }
099:
100:            /**
101:             * Creates a inputstream as a valid email
102:             * @param subject the subject of email
103:             * @param body the body
104:             * @return an input stream
105:             * @throws IOException thrown if there is some real strange things with the writers
106:             */
107:            private InputStream createMessageStream(String subject, String body)
108:                    throws IOException {
109:                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
110:                OutputStreamWriter writer = new OutputStreamWriter(outputStream);
111:
112:                writer.write("Subject: " + subject + "\n");
113:                writer.write("\n");
114:                writer.write(body);
115:
116:                return new ByteArrayInputStream(outputStream.toByteArray());
117:            }
118:
119:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.