Source Code Cross Referenced for SubelementCreatorActionTest.java in  » Testing » DDTUnit » junitx » ddtunit » data » processing » 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 » DDTUnit » junitx.ddtunit.data.processing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$Id: SubelementCreatorActionTest.java 198 2005-11-06 23:15:52Z jg_hamburg $
002:        /********************************************************************************
003:         * DDTUnit, a Datadriven Approach to Unit- and Moduletesting
004:         * Copyright (c) 2004, Joerg and Kai Gellien
005:         * All rights reserved.
006:         *
007:         * The Software is provided under the terms of the Common Public License 1.0
008:         * as provided with the distribution of DDTUnit in the file cpl-v10.html.
009:         * Redistribution and use in source and binary forms, with or without
010:         * modification, are permitted provided that the following conditions
011:         * are met:
012:         *
013:         *     + Redistributions of source code must retain the above copyright
014:         *       notice, this list of conditions and the following disclaimer.
015:         *
016:         *     + Redistributions in binary form must reproduce the above
017:         *       copyright notice, this list of conditions and the following
018:         *       disclaimer in the documentation and/or other materials provided
019:         *       with the distribution.
020:         *
021:         *     + Neither the name of the authors or DDTUnit, nor the
022:         *       names of its contributors may be used to endorse or promote
023:         *       products derived from this software without specific prior
024:         *       written permission.
025:         *
026:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
027:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
028:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
029:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
030:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
031:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
032:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
033:         * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
034:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
035:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
036:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
037:         ********************************************************************************/package junitx.ddtunit.data.processing;
038:
039:        import java.util.HashMap;
040:        import java.util.Map;
041:
042:        import junit.framework.Test;
043:        import junit.framework.TestCase;
044:        import junit.framework.TestSuite;
045:        import junitx.ddtunit.data.TypedObject;
046:
047:        /**
048:         * Test to check functionallity of {@link SubelementCreatorAction}.<br/>
049:         * Contract of Action class: <br/>
050:         * <ul>
051:         * <li>Subelement action are not allowed to be first in list. There must be a
052:         * root action.</li>
053:         * <li>Subelement action will create a {@link CollectionCreatorAction}action
054:         * containing all field data processed for basic root element from xml
055:         * resource..</li>
056:         * <li>&nbsp;</li>
057:         * </ul>
058:         * 
059:         * @author jg
060:         */
061:        public class SubelementCreatorActionTest extends TestCase {
062:            private ActionStack actionStack;
063:
064:            private String testContent;
065:
066:            /**
067:             * Instanciate test providing method to test
068:             * 
069:             * @param name of method to execute
070:             */
071:            public SubelementCreatorActionTest(String name) {
072:                super (name);
073:            }
074:
075:            /**
076:             * @return suite of tests to execute
077:             */
078:            public static Test suite() {
079:                return new TestSuite(SubelementCreatorActionTest.class);
080:            }
081:
082:            public void setUp() {
083:                this .actionStack = new ActionStack();
084:                // prepare object element to use subelement on
085:                Map rootAttrbs = new HashMap();
086:                rootAttrbs.put(ParserConstants.XML_ATTR_ID, "object");
087:                rootAttrbs.put(ParserConstants.XML_ATTR_TYPE,
088:                        "junitx.ddtunit.resources.SimpleVO");
089:                ActionBase rootAction = new SubelementCreatorAction(rootAttrbs);
090:                rootAction.inject();
091:                this .actionStack.push(rootAction);
092:                // prepare subelement to use content on
093:                Map subAttrbs = new HashMap();
094:                subAttrbs.put(ParserConstants.XML_ATTR_ID, "stringValue");
095:                subAttrbs
096:                        .put(ParserConstants.XML_ATTR_TYPE, "java.lang.String");
097:                ActionBase subAction = new SubelementCreatorAction(subAttrbs);
098:                subAction.inject();
099:                this .actionStack.push(subAction);
100:                this .testContent = "Hallo World";
101:                Map attribs = new HashMap();
102:                attribs.put("id", "content");
103:                attribs.put("hint", "content");
104:                attribs.put("type", "java.lang.StringBuffer");
105:                attribs.put("content", new StringBuffer(testContent));
106:                ActionBase action = new ContentCreatorAction(attribs);
107:                assertNull("Internal object should be null", action.getObject());
108:                action.inject();
109:                this .actionStack.push(action);
110:            }
111:
112:            /**
113:             * Test processing operation of {@link SubelementCreatorAction}
114:             */
115:            public void testActionSubelementCreator() {
116:                // start with content processing on field element
117:                TypedObject obj = this .actionStack.peek().getObject();
118:                assertNotNull("Internal object should not be null", obj);
119:                assertEquals("Wrong type of internal object",
120:                        "java.lang.StringBuffer", obj.getType());
121:                this .actionStack.process();
122:                assertNotNull("Internal object should not be null",
123:                        this .actionStack.peek().getValue());
124:                assertEquals("Wrong class of internal object",
125:                        "java.util.Vector", this .actionStack.peek().getType());
126:                assertEquals("Wrong id of internal object", "attrlist",
127:                        this .actionStack.peek().getId());
128:                // process implicite field container on object element
129:                IAction base = this .actionStack.process();
130:                assertEquals(
131:                        "Wrong Action type",
132:                        "junitx.ddtunit.data.processing.SubelementCreatorAction",
133:                        base.getClass().getName());
134:                assertEquals("Wrong type of created object",
135:                        "junitx.ddtunit.resources.SimpleVO", base.getType());
136:            }
137:
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.