Source Code Cross Referenced for CeltixClientEchoTest.java in  » ESB » celtix-1.0 » org » objectweb » celtix » axisinterop » 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 » ESB » celtix 1.0 » org.objectweb.celtix.axisinterop 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.axisinterop;
002:
003:        import java.math.BigDecimal;
004:        import java.math.BigInteger;
005:        import java.net.URL;
006:        import java.util.Arrays; //import java.util.List;
007:
008:        import javax.xml.datatype.DatatypeConstants;
009:        import javax.xml.datatype.XMLGregorianCalendar;
010:        import javax.xml.namespace.QName;
011:
012:        import junit.framework.Test;
013:        import junit.framework.TestCase;
014:        import junit.framework.TestSuite;
015:
016:        import org.objectweb.celtix.bus.jaxws.spi.ProviderImpl;
017:        import org.objectweb.celtix.testutil.common.AbstractClientServerSetupBase;
018:
019:        import org.soapinterop.celtix.AxisEchoService;
020:        import org.soapinterop.celtix.InteropTestPortType;
021:        import org.soapinterop.celtix.SOAPStruct;
022:
023:        public class CeltixClientEchoTest extends TestCase {
024:
025:            private final QName serviceName = new QName(
026:                    "http://soapinterop.org/celtix", "AxisEchoService");
027:            private final QName portName = new QName(
028:                    "http://soapinterop.org/celtix", "Echo");
029:
030:            private InteropTestPortType port;
031:
032:            static {
033:                System.setProperty(ProviderImpl.JAXWSPROVIDER_PROPERTY,
034:                        ProviderImpl.JAXWS_PROVIDER);
035:            }
036:
037:            public CeltixClientEchoTest() {
038:            }
039:
040:            public static Test suite() throws Exception {
041:                TestSuite suite = new TestSuite(CeltixClientEchoTest.class);
042:                return new AbstractClientServerSetupBase(suite) {
043:                    public void startServers() throws Exception {
044:                        boolean ok = launchServer(AxisServer.class);
045:                        if (!ok) {
046:                            fail("Failed to launch axis server.");
047:                        }
048:                    }
049:                };
050:            }
051:
052:            public void setUp() throws Exception {
053:                super .setUp();
054:                URL wsdl = getClass().getResource("/wsdl/axis_echo.wsdl");
055:                assertNotNull("Could not get axis_echo.wsdl resource.", wsdl);
056:
057:                AxisEchoService service = new AxisEchoService(wsdl, serviceName);
058:                assertNotNull("Failed to create AxisEchoService.", service);
059:
060:                port = service.getPort(portName, InteropTestPortType.class);
061:            }
062:
063:            protected boolean equalsDate(XMLGregorianCalendar orig,
064:                    XMLGregorianCalendar actual) {
065:                boolean result = false;
066:
067:                if ((orig.getYear() == actual.getYear())
068:                        && (orig.getMonth() == actual.getMonth())
069:                        && (orig.getDay() == actual.getDay())
070:                        && (actual.getHour() == DatatypeConstants.FIELD_UNDEFINED)
071:                        && (actual.getMinute() == DatatypeConstants.FIELD_UNDEFINED)
072:                        && (actual.getSecond() == DatatypeConstants.FIELD_UNDEFINED)
073:                        && (actual.getMillisecond() == DatatypeConstants.FIELD_UNDEFINED)) {
074:
075:                    result = orig.getTimezone() == actual.getTimezone();
076:                }
077:                return result;
078:            }
079:
080:            protected boolean equalsDateTime(XMLGregorianCalendar orig,
081:                    XMLGregorianCalendar actual) {
082:                if ((orig.getYear() == actual.getYear())
083:                        && (orig.getMonth() == actual.getMonth())
084:                        && (orig.getDay() == actual.getDay())
085:                        && (orig.getHour() == actual.getHour())
086:                        && (orig.getMinute() == actual.getMinute())
087:                        && (orig.getSecond() == actual.getSecond())) {
088:                    return (orig.getMillisecond() == DatatypeConstants.FIELD_UNDEFINED
089:                            || actual.getMillisecond() == DatatypeConstants.FIELD_UNDEFINED || orig
090:                            .getMillisecond() == actual.getMillisecond())
091:                            && (orig.getTimezone() == DatatypeConstants.FIELD_UNDEFINED
092:                                    || actual.getTimezone() == DatatypeConstants.FIELD_UNDEFINED || orig
093:                                    .getTimezone() == actual.getTimezone());
094:                }
095:                return false;
096:            }
097:
098:            protected boolean equals(SOAPStruct obj1, SOAPStruct obj2) {
099:                if (null == obj1) {
100:                    return null == obj2;
101:                } else {
102:                    return Float.floatToIntBits(obj1.getVarFloat()) == Float
103:                            .floatToIntBits(obj2.getVarFloat())
104:                            && obj1.getVarInt() == obj2.getVarInt()
105:                            && obj1.getVarString().equals(obj2.getVarString());
106:                }
107:            }
108:
109:            public void testBoolean() throws Exception {
110:                boolean in = true;
111:                boolean out = port.echoBoolean(in);
112:                assertEquals("echoBoolean : incorrect return value : " + out
113:                        + " expected : " + in, in, out);
114:            }
115:
116:            public void testFloat() throws Exception {
117:                float in = 3.7F;
118:                float out = port.echoFloat(in);
119:                assertEquals("echoFloat : incorrect return value : " + out
120:                        + " expected : " + in, in, out);
121:            }
122:
123:            public void testInteger() throws Exception {
124:                int in = 42;
125:                int out = port.echoInteger(in);
126:                assertEquals("echoInteger : incorrect return value : " + out
127:                        + " expected : " + in, in, out);
128:            }
129:
130:            public void testVoid() throws Exception {
131:                port.echoVoid();
132:            }
133:
134:            // TODO: Investigate why this fails.
135:            //public void testHexBinary() throws Exception {
136:            //    byte[] in = "1234".getBytes();
137:            //    byte[] out = port.echoHexBinary(in);
138:            //    assertTrue("echoHexBinary : incorrect return value : "
139:            //        + new String(out) + " expected : " + new String(in), Arrays.equals(in, out));
140:            //}
141:
142:            public void testNegativeInteger() throws Exception {
143:                // Test xsd:negativeInteger
144:                BigInteger in = new BigInteger("-12345678900987654321");
145:                BigInteger out = port.echoNegativeInteger(in);
146:                assertEquals("echoNegativeInteger : incorrect return value : "
147:                        + out + " expected : " + in, in, out);
148:            }
149:
150:            public void testNonNegativeInteger() throws Exception {
151:                // Test xsd:nonNegativeInteger
152:                BigInteger in = new BigInteger("12345678901234567890");
153:                BigInteger out = port.echoNonNegativeInteger(in);
154:                assertEquals(
155:                        "echoNonNegativeInteger : incorrect return value : "
156:                                + out + " expected : " + in, in, out);
157:            }
158:
159:            public void testNonPositiveInteger() throws Exception {
160:                // Test xsd:nonPositiveInteger
161:                BigInteger in = new BigInteger("-12345678901234567890");
162:                BigInteger out = port.echoNonPositiveInteger(in);
163:                assertEquals(
164:                        "echoNonPositiveInteger : incorrect return value : "
165:                                + out + " expected : " + in, in, out);
166:            }
167:
168:            public void testPositiveInteger() throws Exception {
169:                // Test xsd:positiveInteger
170:                BigInteger in = new BigInteger("12345678900987654321");
171:                BigInteger out = port.echoPositiveInteger(in);
172:                assertEquals("echoPositiveInteger : incorrect return value : "
173:                        + out + " expected : " + in, in, out);
174:            }
175:
176:            public void testNormalizedString() throws Exception {
177:                // Test xsd:normalizedString
178:                String in = "abc-Normalized-def";
179:                String out = port.echoNormalizedString(in);
180:                assertEquals("echoNormalizedString : incorrect return value : "
181:                        + out + " expected : " + in, in, out);
182:            }
183:
184:            public void testToken() throws Exception {
185:                // Test xsd:token
186:                String in = "abc-Token-def";
187:                String out = port.echoToken(in);
188:                assertEquals("echoToken : incorrect return value : " + out
189:                        + " expected : " + in, in, out);
190:            }
191:
192:            public void testUnsignedByte() throws Exception {
193:                // Test xsd:unsignedByte
194:                short in = 103;
195:                short out = port.echoUnsignedByte(in);
196:                assertEquals("echoUnsignedByte : incorrect return value : "
197:                        + out + " expected : " + in, in, out);
198:            }
199:
200:            public void testUnsignedInt() throws Exception {
201:                // Test xsd:unsignedInt
202:                long in = 101;
203:                long out = port.echoUnsignedInt(in);
204:                assertEquals("echoUnsignedInt : incorrect return value : "
205:                        + out + " expected : " + in, in, out);
206:            }
207:
208:            public void testUnsignedLong() throws Exception {
209:                // Test xsd:unsignedLong
210:                BigInteger in = new BigInteger("123456789");
211:                BigInteger out = port.echoUnsignedLong(in);
212:                assertEquals("echoUnsignedLong : incorrect return value : "
213:                        + out + " expected : " + in, in, out);
214:            }
215:
216:            public void testUnsignedShort() throws Exception {
217:                // Test xsd:unsignedShort
218:                int in = 102;
219:                int out = port.echoUnsignedShort(in);
220:                assertEquals("echoUnsignedShort : incorrect return value : "
221:                        + out + " expected : " + in, in, out);
222:            }
223:
224:            public void testString() throws Exception {
225:                String in = "abcdefg";
226:                String out = port.echoString(in);
227:                assertEquals("echoString : incorrect return value : " + out
228:                        + " expected : " + in, in, out);
229:            }
230:
231:            // TODO: Figure out why this hits an assertion in JAXBDataBindingCallback
232:            //public void testStringArray() throws Exception {
233:            //    List<String> in = Arrays.asList("abc", "def");
234:            //    List<String> out = port.echoStringArray(in);
235:            //    assertTrue("echoStringArray : incorrect return value : ", in.equals(out));
236:            //}
237:
238:            public void testStruct() throws Exception {
239:                SOAPStruct in = new SOAPStruct();
240:                in.setVarInt(6);
241:                in.setVarString("Rover");
242:                in.setVarFloat(1010F);
243:                SOAPStruct out = port.echoStruct(in);
244:                assertTrue("echoStruct : incorrect return value", equals(in,
245:                        out));
246:            }
247:
248:            public void testBase64() throws Exception {
249:                byte[] in = "Base64".getBytes();
250:                byte[] out = port.echoBase64(in);
251:                assertTrue("echoBase64 : incorrect return value : ", Arrays
252:                        .equals(in, out));
253:            }
254:
255:            // TODO: Figure out why this causes a NumberFormatException
256:            //public void testDate() throws Exception {
257:            //    javax.xml.datatype.DatatypeFactory factory = javax.xml.datatype.DatatypeFactory.newInstance();
258:            //    XMLGregorianCalendar in = factory.newXMLGregorianCalendar();
259:            //    in.setYear(1975);
260:            //    in.setMonth(5);
261:            //    in.setDay(5);
262:            //    XMLGregorianCalendar out = port.echoDate(in);
263:            //    assertTrue("echoDate : incorrect return value : "
264:            //        + out + " expected : " + in, equalsDate(in, out));
265:            //}
266:
267:            public void testDateTime() throws Exception {
268:                javax.xml.datatype.DatatypeFactory factory = javax.xml.datatype.DatatypeFactory
269:                        .newInstance();
270:                XMLGregorianCalendar in = factory.newXMLGregorianCalendar();
271:                in.setYear(1975);
272:                in.setMonth(5);
273:                in.setDay(5);
274:                in.setHour(12);
275:                in.setMinute(30);
276:                in.setSecond(15);
277:                XMLGregorianCalendar out = port.echoDateTime(in);
278:                assertTrue("echoDate : incorrect return value : " + out
279:                        + " expected : " + in, equalsDateTime(in, out));
280:            }
281:
282:            public void testDecimal() throws Exception {
283:                BigDecimal in = new BigDecimal("3.14159");
284:                BigDecimal out = port.echoDecimal(in);
285:                assertEquals("echoDecimal : incorrect return value : " + out
286:                        + " expected : " + in, in, out);
287:            }
288:
289:            public static void main(String[] args) {
290:                junit.textui.TestRunner.run(CeltixClientEchoTest.class);
291:            }
292:
293:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.