Source Code Cross Referenced for JAXBProviderTests.java in  » Web-Services-AXIS2 » jax-ws » org » apache » axis2 » jaxws » provider » 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 AXIS2 » jax ws » org.apache.axis2.jaxws.provider 
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:         */
019:        package org.apache.axis2.jaxws.provider;
020:
021:        import java.awt.*;
022:        import java.io.File;
023:
024:        import javax.activation.DataHandler;
025:        import javax.activation.DataSource;
026:        import javax.imageio.ImageIO;
027:        import javax.imageio.stream.FileImageInputStream;
028:        import javax.imageio.stream.ImageInputStream;
029:        import javax.xml.bind.JAXBContext;
030:        import javax.xml.namespace.QName;
031:        import javax.xml.ws.Dispatch;
032:        import javax.xml.ws.Service;
033:
034:        import org.apache.axiom.attachments.ByteArrayDataSource;
035:        import org.apache.axis2.jaxws.TestLogger;
036:        import org.test.mtom.ImageDepot;
037:        import org.test.mtom.ObjectFactory;
038:        import org.test.mtom.SendImage;
039:        import org.test.mtom.SendImageResponse;
040:
041:        /**
042:         * The intended purpose of this testcase is to test the MTOM functions in Axis2. 
043:         * It demostrate an alternative way of sending an attachment using DataHandler.
044:         * 
045:         * This testcase uses a JAXWS Dispatch invocation with JAXB generated request object
046:         * as parameter. The endpoint for these testcase is a JAXWS Source Provider.
047:         * 
048:         * These JAXB generated artifacts is based on jaxws\test-resources\xsd\samplemtom.xsd
049:         * schema.
050:         * 
051:         * Available Content types are:
052:         *       "image/gif"
053:         *       "image/jpeg"
054:         *       "text/plain"
055:         *       "multipart/*"
056:         *       "text/xml"
057:         *       "application/xml"
058:         * This initial testcase only covers the "multipart/*" and  "text/plain" mime types.
059:         * The ultimate goal is to provide testcases for the remaining mime types. 
060:         *
061:         */
062:        public class JAXBProviderTests extends ProviderTestCase {
063:
064:            String endpointUrl = "http://localhost:8080/axis2/services/JAXBProviderService";
065:            private QName serviceName = new QName("http://ws.apache.org/axis2",
066:                    "JAXBProviderService");
067:            DataSource stringDS, imageDS;
068:
069:            protected void setUp() throws Exception {
070:                super .setUp();
071:
072:                //Create a DataSource from a String
073:                String string = "Sending a JAXB generated string object to Source Provider endpoint";
074:                stringDS = new ByteArrayDataSource(string.getBytes(),
075:                        "text/plain");
076:
077:                //Create a DataSource from an image 
078:                File file = new File(imageResourceDir + File.separator
079:                        + "test.jpg");
080:                ImageInputStream fiis = new FileImageInputStream(file);
081:                Image image = ImageIO.read(fiis);
082:                imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
083:
084:            }
085:
086:            protected void tearDown() throws Exception {
087:                super .tearDown();
088:            }
089:
090:            public JAXBProviderTests(String name) {
091:                super (name);
092:            }
093:
094:            /**
095:             * test String
096:             * @throws Exception
097:             */
098:            public void testMTOMAttachmentString() throws Exception {
099:                TestLogger.logger
100:                        .debug("---------------------------------------");
101:                TestLogger.logger.debug("test: " + getName());
102:
103:                //Create a DataHandler with the String DataSource object
104:                DataHandler dataHandler = new DataHandler(stringDS);
105:
106:                //Store the data handler in ImageDepot bean
107:                ImageDepot imageDepot = new ObjectFactory().createImageDepot();
108:                imageDepot.setImageData(dataHandler);
109:
110:                Service svc = Service.create(serviceName);
111:                svc.addPort(portName, null, endpointUrl);
112:
113:                JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
114:
115:                Dispatch<Object> dispatch = svc.createDispatch(portName, jbc,
116:                        Service.Mode.PAYLOAD);
117:
118:                //Create a request bean with imagedepot bean as value
119:                ObjectFactory factory = new ObjectFactory();
120:                SendImage request = factory.createSendImage();
121:                request.setInput(imageDepot);
122:
123:                TestLogger.logger
124:                        .debug(">> Invoking Dispatch<Object> JAXBProviderService");
125:
126:                SendImageResponse response = (SendImageResponse) dispatch
127:                        .invoke(request);
128:
129:                TestLogger.logger.debug(">> Response [" + response.toString()
130:                        + "]");
131:            }
132:
133:            /**
134:             * test Image
135:             * @throws Exception
136:             */
137:            public void testMTOMAttachmentImage() throws Exception {
138:                TestLogger.logger
139:                        .debug("---------------------------------------");
140:                TestLogger.logger.debug("test: " + getName());
141:
142:                //Create a DataHandler with the String DataSource object
143:                DataHandler dataHandler = new DataHandler(imageDS);
144:
145:                //Store the data handler in ImageDepot bean
146:                ImageDepot imageDepot = new ObjectFactory().createImageDepot();
147:                imageDepot.setImageData(dataHandler);
148:
149:                Service svc = Service.create(serviceName);
150:                svc.addPort(portName, null, endpointUrl);
151:
152:                JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
153:
154:                Dispatch<Object> dispatch = svc.createDispatch(portName, jbc,
155:                        Service.Mode.PAYLOAD);
156:
157:                //Create a request bean with imagedepot bean as value
158:                ObjectFactory factory = new ObjectFactory();
159:                SendImage request = factory.createSendImage();
160:                request.setInput(imageDepot);
161:
162:                TestLogger.logger
163:                        .debug(">> Invoking Dispatch<Object> JAXBProviderService");
164:
165:                SendImageResponse response = (SendImageResponse) dispatch
166:                        .invoke(request);
167:
168:                TestLogger.logger.debug(">> Response [" + response.toString()
169:                        + "]");
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.