Source Code Cross Referenced for TestDescriptors.java in  » Library » Apache-commons-betwixt-0.8-src » org » apache » commons » betwixt » 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 » Library » Apache commons betwixt 0.8 src » org.apache.commons.betwixt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.commons.betwixt;
018:
019:        import junit.framework.Test;
020:        import junit.framework.TestSuite;
021:        import junit.textui.TestRunner;
022:
023:        /** Test harness for the Descriptors (ElementDescriptor and so on).
024:         *
025:         * @author Robert Burrell Donkin
026:         * @version $Revision: 438373 $
027:         */
028:        public class TestDescriptors extends AbstractTestCase {
029:
030:            public static void main(String[] args) {
031:                TestRunner.run(suite());
032:            }
033:
034:            public static Test suite() {
035:                return new TestSuite(TestDescriptors.class);
036:            }
037:
038:            public TestDescriptors(String testName) {
039:                super (testName);
040:            }
041:
042:            public void testElementDescriptorLazyInit() {
043:                ElementDescriptor descriptor = new ElementDescriptor();
044:
045:                // check for NPEs
046:                assertTrue("Empty descriptor has no children", !descriptor
047:                        .hasChildren());
048:                assertTrue("Empty descriptor has no content", !descriptor
049:                        .hasContent());
050:                assertTrue("Empty descriptor has no attributes", !descriptor
051:                        .hasAttributes());
052:
053:                // add an attribute and make sure everything works
054:                descriptor.addAttributeDescriptor(new AttributeDescriptor(
055:                        "test:one"));
056:                assertTrue("Empty descriptor has no children", !descriptor
057:                        .hasChildren());
058:                assertTrue("Empty descriptor has no content", !descriptor
059:                        .hasContent());
060:                assertTrue("Descriptor has attributes (1)", descriptor
061:                        .hasAttributes());
062:
063:                // add an element and make sure everything works
064:                descriptor.addElementDescriptor(new ElementDescriptor(
065:                        "test:two"));
066:                assertTrue("Descriptor has children (1)", descriptor
067:                        .hasChildren());
068:                assertTrue("Descriptor has content (1)", descriptor
069:                        .hasContent());
070:                assertTrue("Descriptor has attributes (2)", descriptor
071:                        .hasAttributes());
072:
073:                // start again and test in reverse order
074:                descriptor = new ElementDescriptor();
075:
076:                // add an element and make sure everything works
077:                descriptor.addElementDescriptor(new ElementDescriptor(
078:                        "test:one"));
079:                assertTrue("Descriptor has children (2)", descriptor
080:                        .hasChildren());
081:                assertTrue("Descriptor has content (2)", descriptor
082:                        .hasContent());
083:                assertTrue("Descriptor has no attributes (1)", !descriptor
084:                        .hasAttributes());
085:
086:                // add an attribute and make sure everything works
087:                descriptor.addAttributeDescriptor(new AttributeDescriptor(
088:                        "test:two"));
089:                assertTrue("Descriptor has children (3)", descriptor
090:                        .hasChildren());
091:                assertTrue("Descriptor has content (3)", descriptor
092:                        .hasContent());
093:                assertTrue("Descriptor has attributes (2)", descriptor
094:                        .hasAttributes());
095:
096:                // try adding content
097:                descriptor = new ElementDescriptor();
098:                descriptor.addContentDescriptor(new AttributeDescriptor(
099:                        "test:one"));
100:                assertTrue("Descriptor has no children (1)", !descriptor
101:                        .hasChildren());
102:                assertTrue("Descriptor has content (3)", descriptor
103:                        .hasContent());
104:                assertTrue("Descriptor has no attributes (2)", !descriptor
105:                        .hasAttributes());
106:
107:                // add an element and make sure everything works
108:                descriptor.addElementDescriptor(new ElementDescriptor(
109:                        "test:two"));
110:                assertTrue("Descriptor has children (4)", descriptor
111:                        .hasChildren());
112:                assertTrue("Descriptor has content (4)", descriptor
113:                        .hasContent());
114:                assertTrue("Descriptor has no attributes (3)", !descriptor
115:                        .hasAttributes());
116:
117:                // add an attribute and make sure everything works
118:                descriptor.addAttributeDescriptor(new AttributeDescriptor(
119:                        "test:three"));
120:                assertTrue("Descriptor has children (5)", descriptor
121:                        .hasChildren());
122:                assertTrue("Descriptor has content (5)", descriptor
123:                        .hasContent());
124:                assertTrue("Descriptor has attributes (3)", descriptor
125:                        .hasAttributes());
126:            }
127:
128:            public void testGetElementDescriptorByName() {
129:                ElementDescriptor descriptor = new ElementDescriptor(
130:                        "Flintstones");
131:                descriptor
132:                        .addElementDescriptor(new ElementDescriptor("Freddy"));
133:                descriptor.addElementDescriptor(new ElementDescriptor("Wilma"));
134:                descriptor
135:                        .addElementDescriptor(new ElementDescriptor("Pebbles"));
136:
137:                ElementDescriptor returned = descriptor
138:                        .getElementDescriptor("Freddy");
139:                assertTrue("Freddy is a Flintstone", returned != null);
140:                assertEquals("Freddy is the right flintstone", "Freddy",
141:                        returned.getLocalName());
142:
143:                returned = descriptor.getElementDescriptor("Wilma");
144:                assertTrue("Wilma is a Flintstone", returned != null);
145:                assertEquals("Wilma is the right flintstone", "Wilma", returned
146:                        .getLocalName());
147:
148:                returned = descriptor.getElementDescriptor("Barney");
149:                assertTrue("Barney is not a Flintstone", returned == null);
150:            }
151:
152:            public void testGetElementDescriptorByNameNullMatch() {
153:                ElementDescriptor descriptor = new ElementDescriptor(
154:                        "Flintstones");
155:                descriptor
156:                        .addElementDescriptor(new ElementDescriptor("Freddy"));
157:                descriptor.addElementDescriptor(new ElementDescriptor("Wilma"));
158:                descriptor
159:                        .addElementDescriptor(new ElementDescriptor("Pebbles"));
160:                descriptor.addElementDescriptor(new ElementDescriptor());
161:
162:                ElementDescriptor returned = descriptor
163:                        .getElementDescriptor("NotFreddy");
164:                assertTrue("NotFreddy matched", returned != null);
165:                assertEquals("NotFreddy match by null descriptor", null,
166:                        returned.getLocalName());
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.