Source Code Cross Referenced for DefaultValueTest.java in  » Web-Services-apache-cxf-2.0.1 » common » org » apache » cxf » xjc » dv » 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 » Web Services apache cxf 2.0.1 » common » org.apache.cxf.xjc.dv 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */package org.apache.cxf.xjc.dv;
019:
020:        import java.math.BigDecimal;
021:        import java.math.BigInteger;
022:
023:        import javax.xml.bind.DatatypeConverter;
024:        import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
025:        import javax.xml.namespace.QName;
026:
027:        import org.apache.cxf.configuration.foo.Foo;
028:        import org.apache.ws.jaxme.impl.DatatypeConverterImpl;
029:        import org.junit.Assert;
030:        import org.junit.Test;
031:
032:        public class DefaultValueTest extends Assert {
033:
034:            @Test
035:            public void testFooDefaultValues() throws Exception {
036:
037:                DatatypeConverter
038:                        .setDatatypeConverter(new DatatypeConverterImpl());
039:
040:                Foo foo = new org.apache.cxf.configuration.foo.ObjectFactory()
041:                        .createFoo();
042:
043:                // verify default values
044:
045:                assertAttributeValuesWithoutDefault(foo);
046:                assertDefaultAttributeValues(foo);
047:                assertDefaultElementValues(foo);
048:            }
049:
050:            private void assertDefaultAttributeValues(Foo foo) {
051:                assertEquals("Unexpected value for attribute stringAttr",
052:                        "hello", foo.getStringAttr());
053:                assertTrue("Unexpected value for attribute booleanAttr", foo
054:                        .isBooleanAttr());
055:                assertEquals("Unexpected value for attribute integerAttr",
056:                        new BigInteger("111"), foo.getIntegerAttr());
057:                assertEquals("Unexpected value for attribute intAttr", 112, foo
058:                        .getIntAttr());
059:                assertEquals("Unexpected value for attribute longAttr", 113L,
060:                        foo.getLongAttr());
061:                assertEquals("Unexpected value for attribute shortAttr", 114,
062:                        foo.getShortAttr());
063:                assertEquals("Unexpected value for attribute decimalAttr",
064:                        new BigDecimal("115"), foo.getDecimalAttr());
065:                assertEquals("Unexpected value for attribute floatAttr",
066:                        new Float(116F), foo.getFloatAttr());
067:                assertEquals("Unexpected value for attribute doubleAttr",
068:                        new Double(117D), foo.getDoubleAttr());
069:                assertEquals("Unexpected value for attribute byteAttr", 118,
070:                        foo.getByteAttr());
071:
072:                byte[] expected = DatatypeConverter.parseBase64Binary("wxyz");
073:                byte[] effective = foo.getBase64BinaryAttr();
074:
075:                assertEquals("Unexpected value for attribute base64BinaryAttr",
076:                        expected.length, effective.length);
077:                for (int i = 0; i < expected.length; i++) {
078:                    assertEquals(
079:                            "Unexpected value for attribute base64BinaryAttr",
080:                            expected[i], effective[i]);
081:                }
082:
083:                expected = new HexBinaryAdapter().unmarshal("aaaa");
084:                effective = foo.getHexBinaryAttr();
085:                assertEquals("Unexpected value for attribute hexBinaryAttr",
086:                        expected.length, effective.length);
087:                for (int i = 0; i < expected.length; i++) {
088:                    assertEquals(
089:                            "Unexpected value for attribute hexBinaryAttr",
090:                            expected[i], effective[i]);
091:                }
092:
093:                QName qn = foo.getQnameAttr();
094:                assertEquals("Unexpected value for attribute qnameAttr",
095:                        "http://www.w3.org/2001/XMLSchema", qn
096:                                .getNamespaceURI());
097:                assertEquals("Unexpected value for attribute qnameAttr",
098:                        "schema", qn.getLocalPart());
099:
100:                assertEquals("Unexpected value for attribute unsignedIntAttr",
101:                        119L, foo.getUnsignedIntAttr());
102:                assertEquals(
103:                        "Unexpected value for attribute unsignedShortAttr",
104:                        120, foo.getUnsignedShortAttr());
105:                assertEquals("Unexpected value for attribute unsignedByteAttr",
106:                        121, foo.getUnsignedByteAttr());
107:
108:                assertEquals("Unexpected value for attribute durationAttr", 3,
109:                        foo.getDurationAttr().getSeconds());
110:                assertEquals("Unexpected value for attribute durationAttr", 0,
111:                        foo.getDurationAttr().getHours());
112:            }
113:
114:            /**
115:             * @param foo
116:             */
117:            private void assertAttributeValuesWithoutDefault(Foo foo) {
118:                assertNull(
119:                        "Unexpected value for attribute stringAttrNoDefault",
120:                        foo.getStringAttrNoDefault());
121:                assertNull(
122:                        "Unexpected value for attribute booleanAttrNoDefault",
123:                        foo.isBooleanAttrNoDefault());
124:                assertNull(
125:                        "Unexpected value for attribute integerAttrNoDefault",
126:                        foo.getIntegerAttrNoDefault());
127:                assertNull("Unexpected value for attribute intAttrNoDefault",
128:                        foo.getIntAttrNoDefault());
129:                assertNull("Unexpected value for attribute longAttrNoDefault",
130:                        foo.getLongAttrNoDefault());
131:                assertNull("Unexpected value for attribute shortAttrNoDefault",
132:                        foo.getShortAttrNoDefault());
133:                assertNull(
134:                        "Unexpected value for attribute decimalAttrNoDefault",
135:                        foo.getDecimalAttrNoDefault());
136:                assertNull("Unexpected value for attribute floatAttrNoDefault",
137:                        foo.getFloatAttrNoDefault());
138:                assertNull(
139:                        "Unexpected value for attribute doubleAttrNoDefault",
140:                        foo.getDoubleAttrNoDefault());
141:                assertNull("Unexpected value for attribute byteAttrNoDefault",
142:                        foo.getByteAttrNoDefault());
143:
144:                assertNull(
145:                        "Unexpected value for attribute base64BinaryAttrNoDefault",
146:                        foo.getBase64BinaryAttrNoDefault());
147:                assertNull(
148:                        "Unexpected value for attribute hexBinaryAttrNoDefault",
149:                        foo.getHexBinaryAttrNoDefault());
150:
151:                assertNull("Unexpected value for attribute qnameAttrNoDefault",
152:                        foo.getQnameAttrNoDefault());
153:
154:                assertNull(
155:                        "Unexpected value for attribute unsignedIntAttrNoDefault",
156:                        foo.getUnsignedIntAttrNoDefault());
157:                assertNull(
158:                        "Unexpected value for attribute unsignedShortAttrNoDefault",
159:                        foo.getUnsignedShortAttrNoDefault());
160:                assertNull(
161:                        "Unexpected value for attribute unsignedByteAttrNoDefault",
162:                        foo.getUnsignedByteAttrNoDefault());
163:                assertNull(
164:                        "Unexpected value for attribute durationAttrNoDefault",
165:                        foo.getDurationAttrNoDefault());
166:            }
167:
168:            private void assertDefaultElementValues(Foo foo) {
169:                assertEquals("Unexpected value for element stringElem",
170:                        "hello", foo.getStringElem());
171:                assertTrue("Unexpected value for element booleanElem", foo
172:                        .isBooleanElem());
173:                assertEquals("Unexpected value for element integerElem",
174:                        new BigInteger("11"), foo.getIntegerElem());
175:                assertEquals("Unexpected value for element intElem",
176:                        new Integer(12), foo.getIntElem());
177:                assertEquals("Unexpected value for element longElem", new Long(
178:                        13L), foo.getLongElem());
179:                assertEquals("Unexpected value for element shortElem",
180:                        new Short((short) 14), foo.getShortElem());
181:                assertEquals("Unexpected value for element decimalElem",
182:                        new BigDecimal("15"), foo.getDecimalElem());
183:                assertEquals("Unexpected value for element floatElem",
184:                        new Float(16F), foo.getFloatElem());
185:                assertEquals("Unexpected value for element doubleElem",
186:                        new Double(17D), foo.getDoubleElem());
187:                assertEquals("Unexpected value for element byteElem", new Byte(
188:                        (byte) 18), foo.getByteElem());
189:
190:                byte[] expected = DatatypeConverter
191:                        .parseBase64Binary("abcdefgh");
192:                byte[] effective = foo.getBase64BinaryElem();
193:
194:                assertEquals("Unexpected value for element base64BinaryElem",
195:                        expected.length, effective.length);
196:                for (int i = 0; i < expected.length; i++) {
197:                    assertEquals(
198:                            "Unexpected value for element base64BinaryElem",
199:                            expected[i], effective[i]);
200:                }
201:
202:                expected = new HexBinaryAdapter().unmarshal("ffff");
203:                effective = foo.getHexBinaryElem();
204:                assertEquals("Unexpected value for element hexBinaryElem",
205:                        expected.length, effective.length);
206:                for (int i = 0; i < expected.length; i++) {
207:                    assertEquals("Unexpected value for element hexBinaryElem",
208:                            expected[i], effective[i]);
209:                }
210:
211:                QName qn = foo.getQnameElem();
212:                assertEquals("Unexpected value for element qnameElem",
213:                        "http://www.w3.org/2001/XMLSchema", qn
214:                                .getNamespaceURI());
215:                assertEquals("Unexpected value for element qnameElem",
216:                        "string", qn.getLocalPart());
217:
218:                assertEquals("Unexpected value for element unsignedIntElem",
219:                        new Long(19L), foo.getUnsignedIntElem());
220:                assertEquals("Unexpected value for element unsignedShortElem",
221:                        new Integer(20), foo.getUnsignedShortElem());
222:                assertEquals("Unexpected value for element unsignedByteElem",
223:                        new Short((short) 21), foo.getUnsignedByteElem());
224:
225:                assertEquals("Unexpected value for element durationElem", 0,
226:                        foo.getDurationElem().getSeconds());
227:                assertEquals("Unexpected value for element durationElem", 3,
228:                        foo.getDurationElem().getHours());
229:            }
230:
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.