Source Code Cross Referenced for CartridgeTest.java in  » UML » AndroMDA-3.2 » org » andromda » core » cartridge » 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 » UML » AndroMDA 3.2 » org.andromda.core.cartridge 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.andromda.core.cartridge;
002:
003:        import java.util.Collection;
004:        import java.util.Iterator;
005:        import java.util.Map;
006:
007:        import junit.framework.TestCase;
008:
009:        import org.andromda.core.cartridge.template.ModelElement;
010:        import org.andromda.core.cartridge.template.Template;
011:        import org.andromda.core.cartridge.template.Type;
012:        import org.andromda.core.common.ComponentContainer;
013:        import org.andromda.core.common.TemplateObject;
014:        import org.andromda.core.namespace.NamespaceComponents;
015:        import org.andromda.core.profile.Profile;
016:
017:        /**
018:         * Implements the JUnit test suit for
019:         * {@link org.andromda.core.cartridge.Cartridge}
020:         *
021:         * @see org.andromda.core.cartridge.Cartridge
022:         * @since 01.04.2003
023:         * @author <a href="http://www.mbohlen.de">Matthias Bohlen </a>
024:         * @author Chad Brandon
025:         */
026:        public class CartridgeTest extends TestCase {
027:            private Cartridge cartridge;
028:
029:            /**
030:             * Constructor for AndroMDATestCartridgeTest.
031:             *
032:             * @param name
033:             */
034:            public CartridgeTest(String name) {
035:                super (name);
036:            }
037:
038:            /**
039:             * @see TestCase#setUp()
040:             */
041:            protected void setUp() throws Exception {
042:                NamespaceComponents.instance().discover();
043:                Collection cartridges = ComponentContainer.instance()
044:                        .findComponentsOfType(Cartridge.class);
045:                assertNotNull(cartridges);
046:                this .cartridge = (Cartridge) cartridges.iterator().next();
047:                Profile.instance().setNamespace(this .cartridge.getNamespace());
048:                this .cartridge.initialize();
049:            }
050:
051:            /**
052:             * @see TestCase#tearDown()
053:             */
054:            protected void tearDown() throws Exception {
055:                this .cartridge = null;
056:            }
057:
058:            public void testGetNamespace() {
059:                assertEquals("test", this .cartridge.getNamespace());
060:            }
061:
062:            public void testGetResources() {
063:                Collection resources = this .cartridge.getResources();
064:                assertNotNull(resources);
065:                assertEquals(3, resources.size());
066:
067:                // first template
068:                final Iterator templateIterator = resources.iterator();
069:                Resource resource = (Resource) templateIterator.next();
070:                assertTrue(resource.isLastModifiedCheck());
071:
072:                Template template = (Template) templateIterator.next();
073:                assertEquals("EntityBean.vsl", template.getPath());
074:                assertEquals("{0}/{1}Bean.java", template.getOutputPattern());
075:                assertEquals("beans", template.getOutlet());
076:                assertTrue(template.isOverwrite());
077:                assertNotNull(template.getSupportedModeElements());
078:                assertEquals("entity", template.getSupportedModeElements()
079:                        .getVariable());
080:                Collection modelElements = template.getSupportedModeElements()
081:                        .getModelElements();
082:                assertNotNull(modelElements);
083:                assertEquals(1, modelElements.size());
084:                ModelElement element = (ModelElement) modelElements.iterator()
085:                        .next();
086:                assertEquals("Entity", element.getStereotype());
087:
088:                // second template
089:                template = (Template) templateIterator.next();
090:                assertEquals(
091:                        "templates/webservice/axis/server-config.wsdd.vsl",
092:                        template.getPath());
093:                assertEquals("WEB-INF/server-config.wsdd", template
094:                        .getOutputPattern());
095:                assertEquals("axis-configuration", template.getOutlet());
096:                assertEquals("$viewType.equals('jsp')", template
097:                        .getOutputCondition());
098:                assertTrue(template.isOverwrite());
099:                assertTrue(template.isOutputToSingleFile());
100:                assertFalse(template.isOutputOnEmptyElements());
101:                assertNotNull(template.getSupportedModeElements());
102:                assertEquals("services", template.getSupportedModeElements()
103:                        .getVariable());
104:                modelElements = template.getSupportedModeElements()
105:                        .getModelElements();
106:                assertNotNull(modelElements);
107:                assertEquals(1, modelElements.size());
108:                element = (ModelElement) modelElements.iterator().next();
109:                assertNull(element.getVariable());
110:                assertNull(element.getStereotype());
111:
112:                final Collection types = element.getTypes();
113:                assertNotNull(types);
114:                assertEquals(1, types.size());
115:                final Type type = (Type) types.iterator().next();
116:                final Collection properties = type.getProperties();
117:                assertEquals(2, properties.size());
118:                final Iterator propertyIterator = properties.iterator();
119:                Type.Property property1 = (Type.Property) propertyIterator
120:                        .next();
121:                assertEquals("propertyOne", property1.getName());
122:                assertEquals("", property1.getValue());
123:                Type.Property property2 = (Type.Property) propertyIterator
124:                        .next();
125:                assertEquals("propertyThree", property2.getName());
126:                assertEquals("Contents", property2.getValue());
127:
128:                final Map conditions = cartridge.getConditions();
129:                assertEquals(1, conditions.size());
130:                final String expressionName = (String) conditions.keySet()
131:                        .iterator().next();
132:                assertEquals("viewTypeIsJsp", expressionName);
133:                final String expressionValue = (String) conditions
134:                        .get(expressionName);
135:                assertEquals("$viewType.equalsIgnoreCase('jsp')",
136:                        expressionValue);
137:            }
138:
139:            public void testGetPropertyReferences() {
140:                String[] propertyRefs = this .cartridge.getPropertyReferences();
141:                assertNotNull(propertyRefs);
142:                assertEquals(2, propertyRefs.length);
143:
144:                String propertyReferenceOne = "propertyReferenceOne";
145:                String propertyReferenceTwo = "propertyReferenceTwo";
146:
147:                assertEquals(propertyReferenceOne, propertyRefs[0]);
148:                assertEquals(propertyReferenceTwo, propertyRefs[1]);
149:            }
150:
151:            public void testGetTemplateObjects() {
152:                final Collection templateObjects = this .cartridge
153:                        .getTemplateObjects();
154:                assertNotNull(templateObjects);
155:                assertEquals(1, templateObjects.size());
156:                TemplateObject templateObject = ((TemplateObject) templateObjects
157:                        .iterator().next());
158:                assertEquals("utils", templateObject.getName());
159:                assertEquals("test", templateObject.getNamespace());
160:                CartridgeTemplateObject object = (CartridgeTemplateObject) templateObject
161:                        .getObject();
162:                assertNotNull(object);
163:                assertEquals("3", object.getDefinitionOne());
164:
165:            }
166:
167:            public void testGetContents() {
168:                Collection contents = this .cartridge.getContents();
169:                assertNotNull(contents);
170:
171:                // make sure there's more than 0 contents listed
172:                TestCase.assertNotSame(new Integer(0), new Integer(contents
173:                        .size()));
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.