Source Code Cross Referenced for ConfigurerImplTest.java in  » Web-Services-apache-cxf-2.0.1 » core » org » apache » cxf » configuration » spring » 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 » core » org.apache.cxf.configuration.spring 
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.configuration.spring;
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 com.sun.xml.bind.DatatypeConverterImpl;
028:
029:        import org.apache.cxf.configuration.Configurable;
030:        import org.junit.Assert;
031:        import org.junit.Test;
032:
033:        public class ConfigurerImplTest extends Assert {
034:
035:            static {
036:                DatatypeConverter
037:                        .setDatatypeConverter(DatatypeConverterImpl.theInstance);
038:            }
039:
040:            @Test
041:            public void testConfigureSimpleNoMatchingBean() {
042:                SimpleBean sb = new SimpleBean("unknown");
043:                ConfigurerImpl configurer = new ConfigurerImpl(
044:                        "/org/apache/cxf/configuration/spring/test-beans.xml");
045:                configurer.configureBean(sb);
046:                assertEquals("Unexpected value for attribute stringAttr",
047:                        "hello", sb.getStringAttr());
048:                assertTrue("Unexpected value for attribute booleanAttr", sb
049:                        .getBooleanAttr());
050:                assertEquals("Unexpected value for attribute integerAttr",
051:                        BigInteger.ONE, sb.getIntegerAttr());
052:                assertEquals("Unexpected value for attribute intAttr",
053:                        new Integer(2), sb.getIntAttr());
054:                assertEquals("Unexpected value for attribute longAttr",
055:                        new Long(3L), sb.getLongAttr());
056:                assertEquals("Unexpected value for attribute shortAttr",
057:                        new Short((short) 4), sb.getShortAttr());
058:                assertEquals("Unexpected value for attribute decimalAttr",
059:                        new BigDecimal("5"), sb.getDecimalAttr());
060:                assertEquals("Unexpected value for attribute floatAttr",
061:                        new Float(6F), sb.getFloatAttr());
062:                assertEquals("Unexpected value for attribute doubleAttr",
063:                        new Double(7D), sb.getDoubleAttr());
064:                assertEquals("Unexpected value for attribute byteAttr",
065:                        new Byte((byte) 8), sb.getByteAttr());
066:
067:                QName qn = sb.getQnameAttr();
068:                assertEquals(
069:                        "Unexpected value for attribute qnameAttrNoDefault",
070:                        "schema", qn.getLocalPart());
071:                assertEquals(
072:                        "Unexpected value for attribute qnameAttrNoDefault",
073:                        "http://www.w3.org/2001/XMLSchema", qn
074:                                .getNamespaceURI());
075:                byte[] expected = DatatypeConverter.parseBase64Binary("abcd");
076:                byte[] val = sb.getBase64BinaryAttr();
077:                assertEquals(
078:                        "Unexpected value for attribute base64BinaryAttrNoDefault",
079:                        expected.length, val.length);
080:                for (int i = 0; i < expected.length; i++) {
081:                    assertEquals(
082:                            "Unexpected value for attribute base64BinaryAttrNoDefault",
083:                            expected[i], val[i]);
084:                }
085:                expected = new HexBinaryAdapter().unmarshal("aaaa");
086:                val = sb.getHexBinaryAttr();
087:                assertEquals(
088:                        "Unexpected value for attribute hexBinaryAttrNoDefault",
089:                        expected.length, val.length);
090:                for (int i = 0; i < expected.length; i++) {
091:                    assertEquals(
092:                            "Unexpected value for attribute hexBinaryAttrNoDefault",
093:                            expected[i], val[i]);
094:                }
095:
096:                assertEquals(
097:                        "Unexpected value for attribute unsignedIntAttrNoDefault",
098:                        new Long(9L), sb.getUnsignedIntAttr());
099:                assertEquals(
100:                        "Unexpected value for attribute unsignedShortAttrNoDefault",
101:                        new Integer(10), sb.getUnsignedShortAttr());
102:                assertEquals(
103:                        "Unexpected value for attribute unsignedByteAttrNoDefault",
104:                        new Short((short) 11), sb.getUnsignedByteAttr());
105:            }
106:
107:            @Test
108:            public void testConfigureSimple() {
109:                SimpleBean sb = new SimpleBean("simple");
110:                ConfigurerImpl configurer = new ConfigurerImpl(
111:                        "/org/apache/cxf/configuration/spring/test-beans.xml");
112:                configurer.configureBean(sb);
113:                assertEquals("Unexpected value for attribute stringAttr",
114:                        "hallo", sb.getStringAttr());
115:                assertTrue("Unexpected value for attribute booleanAttr", !sb
116:                        .getBooleanAttr());
117:                assertEquals("Unexpected value for attribute integerAttr",
118:                        BigInteger.TEN, sb.getIntegerAttr());
119:                assertEquals("Unexpected value for attribute intAttr",
120:                        new Integer(12), sb.getIntAttr());
121:                assertEquals("Unexpected value for attribute longAttr",
122:                        new Long(13L), sb.getLongAttr());
123:                assertEquals("Unexpected value for attribute shortAttr",
124:                        new Short((short) 14), sb.getShortAttr());
125:                assertEquals("Unexpected value for attribute decimalAttr",
126:                        new BigDecimal("15"), sb.getDecimalAttr());
127:                assertEquals("Unexpected value for attribute floatAttr",
128:                        new Float(16F), sb.getFloatAttr());
129:                assertEquals("Unexpected value for attribute doubleAttr",
130:                        new Double(17D), sb.getDoubleAttr());
131:                assertEquals("Unexpected value for attribute byteAttr",
132:                        new Byte((byte) 18), sb.getByteAttr());
133:
134:                /*
135:                QName qn = sb.getQnameAttr();
136:                assertEquals("Unexpected value for attribute qnameAttrNoDefault", 
137:                             "string", qn.getLocalPart());
138:                assertEquals("Unexpected value for attribute qnameAttrNoDefault",
139:                             "http://www.w3.org/2001/XMLSchema", qn.getNamespaceURI());
140:                 */
141:
142:                /*
143:                byte[] expected = DatatypeConverter.parseBase64Binary("wxyz");
144:                byte[] val = sb.getBase64BinaryAttr(); 
145:                assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected.length, val.length);
146:                for (int i = 0; i < expected.length; i++) {
147:                    assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected[i], val[i]);
148:                }
149:
150:                expected = new HexBinaryAdapter().unmarshal("bbbb");
151:                val = sb.getHexBinaryAttr();
152:                assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected.length, val.length);
153:                for (int i = 0; i < expected.length; i++) {
154:                    assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected[i], val[i]);
155:                }
156:                 */
157:
158:                assertEquals(
159:                        "Unexpected value for attribute unsignedIntAttrNoDefault",
160:                        new Long(19L), sb.getUnsignedIntAttr());
161:                assertEquals(
162:                        "Unexpected value for attribute unsignedShortAttrNoDefault",
163:                        new Integer(20), sb.getUnsignedShortAttr());
164:                assertEquals(
165:                        "Unexpected value for attribute unsignedByteAttrNoDefault",
166:                        new Short((short) 21), sb.getUnsignedByteAttr());
167:            }
168:
169:            @Test
170:            public void testConfigureSimpleMatchingStarBeanId() {
171:                SimpleBean sb = new SimpleBean("simple2");
172:                ConfigurerImpl configurer = new ConfigurerImpl(
173:                        "/org/apache/cxf/configuration/spring/test-beans.xml");
174:                configurer.configureBean(sb);
175:                assertTrue("Unexpected value for attribute booleanAttr", !sb
176:                        .getBooleanAttr());
177:                assertEquals("Unexpected value for attribute integerAttr",
178:                        BigInteger.TEN, sb.getIntegerAttr());
179:                assertEquals("Unexpected value for attribute stringAttr",
180:                        "StarHallo", sb.getStringAttr());
181:            }
182:
183:            @Test
184:            public void testGetBeanName() {
185:                ConfigurerImpl configurer = new ConfigurerImpl((String) null);
186:                Object beanInstance = new Configurable() {
187:
188:                    public String getBeanName() {
189:                        return "a";
190:                    }
191:                };
192:                assertEquals("a", configurer.getBeanName(beanInstance));
193:                final class NamedBean {
194:                    @SuppressWarnings("unused")
195:                    public String getBeanName() {
196:                        return "b";
197:                    }
198:                }
199:                beanInstance = new NamedBean();
200:                assertEquals("b", configurer.getBeanName(beanInstance));
201:                beanInstance = this ;
202:                assertNull(configurer.getBeanName(beanInstance));
203:            }
204:
205:            final class SimpleBean implements  Configurable {
206:
207:                private String beanName;
208:
209:                private String stringAttr = "hello";
210:                private Boolean booleanAttr = Boolean.TRUE;
211:                private BigInteger integerAttr = BigInteger.ONE;
212:                private Integer intAttr = new Integer(2);
213:                private Long longAttr = new Long(3);
214:                private Short shortAttr = new Short((short) 4);
215:                private BigDecimal decimalAttr = new BigDecimal("5");
216:                private Float floatAttr = new Float(6F);
217:                private Double doubleAttr = new Double(7D);
218:                private Byte byteAttr = new Byte((byte) 8);
219:                private QName qnameAttr = new QName(
220:                        "http://www.w3.org/2001/XMLSchema", "schema", "xs");
221:                private byte[] base64BinaryAttr = DatatypeConverter
222:                        .parseBase64Binary("abcd");
223:                private byte[] hexBinaryAttr = new HexBinaryAdapter()
224:                        .unmarshal("aaaa");
225:                private Long unsignedIntAttr = new Long(9);
226:                private Integer unsignedShortAttr = new Integer(10);
227:                private Short unsignedByteAttr = new Short((short) 11);
228:
229:                public SimpleBean(String bn) {
230:                    beanName = bn;
231:                }
232:
233:                public String getBeanName() {
234:                    return beanName;
235:                }
236:
237:                public byte[] getBase64BinaryAttr() {
238:                    return base64BinaryAttr;
239:                }
240:
241:                public void setBase64BinaryAttr(byte[] base64BinaryAttr) {
242:                    this .base64BinaryAttr = base64BinaryAttr;
243:                }
244:
245:                public Boolean getBooleanAttr() {
246:                    return booleanAttr;
247:                }
248:
249:                public void setBooleanAttr(Boolean booleanAttr) {
250:                    this .booleanAttr = booleanAttr;
251:                }
252:
253:                public Byte getByteAttr() {
254:                    return byteAttr;
255:                }
256:
257:                public void setByteAttr(Byte byteAttr) {
258:                    this .byteAttr = byteAttr;
259:                }
260:
261:                public BigDecimal getDecimalAttr() {
262:                    return decimalAttr;
263:                }
264:
265:                public void setDecimalAttr(BigDecimal decimalAttr) {
266:                    this .decimalAttr = decimalAttr;
267:                }
268:
269:                public Double getDoubleAttr() {
270:                    return doubleAttr;
271:                }
272:
273:                public void setDoubleAttr(Double doubleAttr) {
274:                    this .doubleAttr = doubleAttr;
275:                }
276:
277:                public Float getFloatAttr() {
278:                    return floatAttr;
279:                }
280:
281:                public void setFloatAttr(Float floatAttr) {
282:                    this .floatAttr = floatAttr;
283:                }
284:
285:                public byte[] getHexBinaryAttr() {
286:                    return hexBinaryAttr;
287:                }
288:
289:                public void setHexBinaryAttr(byte[] hexBinaryAttr) {
290:                    this .hexBinaryAttr = hexBinaryAttr;
291:                }
292:
293:                public Integer getIntAttr() {
294:                    return intAttr;
295:                }
296:
297:                public void setIntAttr(Integer intAttr) {
298:                    this .intAttr = intAttr;
299:                }
300:
301:                public BigInteger getIntegerAttr() {
302:                    return integerAttr;
303:                }
304:
305:                public void setIntegerAttr(BigInteger integerAttr) {
306:                    this .integerAttr = integerAttr;
307:                }
308:
309:                public Long getLongAttr() {
310:                    return longAttr;
311:                }
312:
313:                public void setLongAttr(Long longAttr) {
314:                    this .longAttr = longAttr;
315:                }
316:
317:                public QName getQnameAttr() {
318:                    return qnameAttr;
319:                }
320:
321:                public void setQnameAttr(QName qnameAttr) {
322:                    this .qnameAttr = qnameAttr;
323:                }
324:
325:                public Short getShortAttr() {
326:                    return shortAttr;
327:                }
328:
329:                public void setShortAttr(Short shortAttr) {
330:                    this .shortAttr = shortAttr;
331:                }
332:
333:                public String getStringAttr() {
334:                    return stringAttr;
335:                }
336:
337:                public void setStringAttr(String stringAttr) {
338:                    this .stringAttr = stringAttr;
339:                }
340:
341:                public Short getUnsignedByteAttr() {
342:                    return unsignedByteAttr;
343:                }
344:
345:                public void setUnsignedByteAttr(Short unsignedByteAttr) {
346:                    this .unsignedByteAttr = unsignedByteAttr;
347:                }
348:
349:                public Long getUnsignedIntAttr() {
350:                    return unsignedIntAttr;
351:                }
352:
353:                public void setUnsignedIntAttr(Long unsignedIntAttr) {
354:                    this .unsignedIntAttr = unsignedIntAttr;
355:                }
356:
357:                public Integer getUnsignedShortAttr() {
358:                    return unsignedShortAttr;
359:                }
360:
361:                public void setUnsignedShortAttr(Integer unsignedShortAttr) {
362:                    this .unsignedShortAttr = unsignedShortAttr;
363:                }
364:
365:                public void setBeanName(String beanName) {
366:                    this.beanName = beanName;
367:                }
368:            }
369:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.