Source Code Cross Referenced for EmailStorePartCountTest.java in  » Testing » webtest » com » canoo » webtest » plugins » emailtest » 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 » Testing » webtest » com.canoo.webtest.plugins.emailtest 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright © 2006-2007 ASERT. Released under the Canoo Webtest license.
002:        package com.canoo.webtest.plugins.emailtest;
003:
004:        import java.io.IOException;
005:
006:        import javax.mail.Message;
007:        import javax.mail.Multipart;
008:        import javax.mail.MessagingException;
009:
010:        import com.canoo.webtest.self.TestBlock;
011:        import com.canoo.webtest.steps.Step;
012:
013:        /**
014:         * Test for {@link EmailStorePartCount}.
015:         *
016:         * @author Paul King, ASERT
017:         */
018:        public class EmailStorePartCountTest extends BaseEmailTestCase {
019:            private static final String PROPERTY_NAME = "dummyProperty";
020:            private static final String MESSAGE_ID = "123";
021:            private static final boolean DELETE_ON_EXIT = false;
022:            private static final String LS = System
023:                    .getProperty("line.separator");
024:
025:            protected Step createStep() {
026:                return new EmailStorePartCount();
027:            }
028:
029:            public void testMandatoryParams() {
030:                final EmailStorePartCount step = (EmailStorePartCount) getStep();
031:                step.getContext().put("EmailConfigInfo", null);
032:                assertStepRejectsNullParam("property", new TestBlock() {
033:                    public void call() throws Throwable {
034:                        executeStep(step);
035:                    }
036:                });
037:            }
038:
039:            public void testInvalidMessageId() {
040:                final EmailStorePartCount step = (EmailStorePartCount) getStep();
041:                step.getContext().put("EmailConfigInfo", null);
042:                step.setProperty(PROPERTY_NAME);
043:                step.setMessageId("non-integer");
044:                assertErrorOnExecute(step, "invalid messageId",
045:                        "Can't parse messageId parameter with value 'non-integer' as an integer.");
046:            }
047:
048:            public void testSimpleNoAttachments() throws Exception {
049:                checkSimpleAttachments("Simple Message with no attachments "
050:                        + LS, 0);
051:            }
052:
053:            public void testSimpleAttachment() throws Exception {
054:                checkSimpleAttachments("Message" + LS + "begin 123 " + LS, 1);
055:            }
056:
057:            public void testSimpleAttachments() throws Exception {
058:                checkSimpleAttachments("Message" + LS + "begin 123 " + LS
059:                        + "begin 345 " + LS, 2);
060:            }
061:
062:            private void checkSimpleAttachments(final String messageBody,
063:                    final int numAttachments) throws Exception {
064:                final EmailStorePartCount step = (EmailStorePartCount) getStep();
065:                final EmailHelper helper = prepareHelper(step);
066:                final Message mockMessage = setUpGetMessageExpectations(step,
067:                        helper, DELETE_ON_EXIT);
068:                mockMessage.getContent();
069:                modify().returnValue(messageBody);
070:                setUpMessageOperationFinaliseExpectations(helper,
071:                        DELETE_ON_EXIT);
072:                startVerification();
073:                executeStep(step);
074:                assertEquals(numAttachments, Integer.parseInt(step
075:                        .getWebtestProperty(PROPERTY_NAME)));
076:            }
077:
078:            public void testMultipart1() throws Exception {
079:                checkMultipart(1);
080:            }
081:
082:            public void testMultipart2() throws Exception {
083:                checkMultipart(2);
084:            }
085:
086:            private void checkMultipart(final int partCount) throws Exception {
087:                final EmailStorePartCount step = (EmailStorePartCount) getStep();
088:                final EmailHelper helper = prepareHelper(step);
089:                final Message mockMessage = setUpGetMessageExpectations(step,
090:                        helper, DELETE_ON_EXIT);
091:                final Multipart multipart = setUpMultipart(partCount);
092:                mockMessage.getContent();
093:                modify().returnValue(multipart);
094:                setUpMessageOperationFinaliseExpectations(helper,
095:                        DELETE_ON_EXIT);
096:                startVerification();
097:                executeStep(step);
098:                assertEquals(partCount, Integer.parseInt(step
099:                        .getWebtestProperty(PROPERTY_NAME)));
100:            }
101:
102:            public void testIoException() throws Exception {
103:                final EmailStorePartCount step = (EmailStorePartCount) getStep();
104:                final EmailHelper helper = prepareHelper(step);
105:                final Message mockMessage = setUpGetMessageExpectations(step,
106:                        helper, DELETE_ON_EXIT);
107:                mockMessage.getContent();
108:                modify().throwException(new IOException("dummyIoException"));
109:                setUpMessageOperationFinaliseExpectations(helper,
110:                        DELETE_ON_EXIT);
111:                startVerification();
112:                assertFailOnExecute(step, "expected to fail",
113:                        "Error processing content: Error processing email message: dummyIoException");
114:            }
115:
116:            private Multipart setUpMultipart(int partCount)
117:                    throws MessagingException {
118:                Multipart mockMultipart = (Multipart) intercept(
119:                        Multipart.class, "mockMultipart");
120:                mockMultipart.getCount();
121:                modify().returnValue(partCount);
122:                return mockMultipart;
123:            }
124:
125:            private EmailHelper prepareHelper(final EmailStorePartCount step) {
126:                step.setProperty(PROPERTY_NAME);
127:                step.setMessageId(MESSAGE_ID);
128:                final EmailHelper helper = (EmailHelper) mock(
129:                        EmailHelper.class, "helper");
130:                step.setHelper(helper);
131:                return helper;
132:            }
133:
134:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.