Source Code Cross Referenced for CopyMessageCommandTest.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.InputStream;
020:
021:        import org.columba.core.command.NullWorkerStatusController;
022:        import org.columba.mail.command.MailFolderCommandReference;
023:        import org.columba.mail.folder.AbstractFolderTst;
024:        import org.columba.mail.folder.FolderTstHelper;
025:        import org.columba.mail.folder.IMailboxInfo;
026:        import org.columba.mail.folder.MailboxTstFactory;
027:        import org.columba.ristretto.message.Flags;
028:
029:        /**
030:         * @author fdietz
031:         *  
032:         */
033:        public class CopyMessageCommandTest extends AbstractFolderTst {
034:
035:            public CopyMessageCommandTest(String arg0) {
036:                super (arg0);
037:            }
038:
039:            /**
040:             * @param arg0
041:             */
042:            public CopyMessageCommandTest(MailboxTstFactory factory, String arg0) {
043:                super (factory, arg0);
044:            }
045:
046:            /**
047:             * Copy message using a {@link CopyMessageCommand}.
048:             * 
049:             * @throws Exception
050:             */
051:            public void testCopyMessage() throws Exception {
052:                // add message "0.eml" as inputstream to folder
053:                String input = FolderTstHelper.getString(0);
054:                System.out.println("input=" + input);
055:                // create stream from string
056:                ByteArrayInputStream inputStream = FolderTstHelper
057:                        .getByteArrayInputStream(input);
058:                // add stream to folder
059:                Object uid = getSourceFolder().addMessage(inputStream);
060:
061:                // create Command reference
062:                MailFolderCommandReference ref = new MailFolderCommandReference(
063:                        getSourceFolder(), getDestFolder(),
064:                        new Object[] { uid });
065:
066:                // create copy command
067:                CopyMessageCommand command = new CopyMessageCommand(ref);
068:
069:                // execute command -> use mock object class as worker which does
070:                // nothing
071:                command.execute(NullWorkerStatusController.getInstance());
072:
073:                // get inputstream of this message from folder
074:                InputStream outputStream = destFolder
075:                        .getMessageSourceStream(uid);
076:                // create string from inputstream
077:                String output = FolderTstHelper
078:                        .getStringFromInputStream(outputStream);
079:                // compare both messages
080:                assertEquals(input, output);
081:                Object[] uids = getDestFolder().getUids();
082:                assertEquals("one message should be in destination folder", 1,
083:                        uids.length);
084:                IMailboxInfo info = getDestFolder().getMessageFolderInfo();
085:                assertEquals("one message should be in destination folder", 1,
086:                        info.getExists());
087:                // close streams
088:                inputStream.close();
089:                outputStream.close();
090:            }
091:
092:            /**
093:             * Copy message using a {@link CopyMessageCommand}and check if attributes
094:             * are copied correctly.
095:             * 
096:             * @throws Exception
097:             */
098:            public void testCopyMessageAttribute() throws Exception {
099:                //  add message "0.eml" as inputstream to folder
100:                String input = FolderTstHelper.getString(0);
101:                System.out.println("input=" + input);
102:                // create stream from string
103:                ByteArrayInputStream inputStream = FolderTstHelper
104:                        .getByteArrayInputStream(input);
105:                // add stream to folder
106:                Object uid = getSourceFolder().addMessage(inputStream);
107:                // get flags of message
108:                Flags oldFlags = getSourceFolder().getFlags(uid);
109:                // set flags
110:                oldFlags.setSeen(false);
111:                /*
112:                 * oldFlags.setRecent(true); oldFlags.setFlagged(true);
113:                 * oldFlags.setExpunged(false);
114:                 */
115:
116:                // create Command reference
117:                MailFolderCommandReference ref = new MailFolderCommandReference(
118:                        getSourceFolder(), getDestFolder(),
119:                        new Object[] { uid });
120:
121:                // create copy command
122:                CopyMessageCommand command = new CopyMessageCommand(ref);
123:
124:                // execute command -> use mock object class as worker which does
125:                // nothing
126:                command.execute(NullWorkerStatusController.getInstance());
127:
128:                Flags flags = getDestFolder().getFlags(uid);
129:
130:                assertEquals("copied message should be marked as not seen",
131:                        false, flags.getSeen());
132:                /*
133:                 * assertEquals("copied message should be marked as recent", true, flags
134:                 * .getRecent()); assertEquals("copied message should be marked as
135:                 * flagged", true, flags .getFlagged()); assertEquals("copied message
136:                 * should be marked as not expunged", false, flags.getExpunged());
137:                 */
138:                // close streams
139:                inputStream.close();
140:
141:            }
142:
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.