Source Code Cross Referenced for LocalTestCase.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » 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 » kernal » org.apache.axis2 
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;
020:
021:        import junit.framework.TestCase;
022:        import org.apache.axis2.engine.AxisConfiguration;
023:        import org.apache.axis2.engine.Phase;
024:        import org.apache.axis2.engine.DispatchPhase;
025:        import org.apache.axis2.context.ConfigurationContext;
026:        import org.apache.axis2.context.ConfigurationContextFactory;
027:        import org.apache.axis2.transport.local.LocalTransportSender;
028:        import org.apache.axis2.transport.local.LocalTransportReceiver;
029:        import org.apache.axis2.description.TransportOutDescription;
030:        import org.apache.axis2.description.WSDL2Constants;
031:        import org.apache.axis2.description.AxisService;
032:        import org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver;
033:        import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
034:        import org.apache.axis2.deployment.util.Utils;
035:        import org.apache.axis2.client.ServiceClient;
036:        import org.apache.axis2.client.Options;
037:        import org.apache.axis2.addressing.EndpointReference;
038:        import org.apache.axiom.soap.SOAP12Constants;
039:
040:        import java.util.ArrayList;
041:
042:        /**
043:         * LocalTestCase is an extendable base class which provides common functionality
044:         * for building JUnit tests which exercise Axis2 using the (fast, in-process)
045:         * "local" transport.
046:         */
047:        public class LocalTestCase extends TestCase {
048:            /** Our server AxisConfiguration */
049:            protected ConfigurationContext serverCtx;
050:            protected AxisConfiguration serverConfig;
051:
052:            /** Our client ConfigurationContext */
053:            protected ConfigurationContext clientCtx;
054:
055:            LocalTransportSender sender = new LocalTransportSender();
056:
057:            protected void setUp() throws Exception {
058:                // Configuration - server side
059:                serverCtx = ConfigurationContextFactory
060:                        .createConfigurationContextFromFileSystem(null);
061:                serverConfig = serverCtx.getAxisConfiguration();
062:                LocalTransportReceiver.CONFIG_CONTEXT = new ConfigurationContext(
063:                        serverConfig);
064:                LocalTransportReceiver.CONFIG_CONTEXT
065:                        .setServicePath("services");
066:                LocalTransportReceiver.CONFIG_CONTEXT.setContextRoot("local:/");
067:                TransportOutDescription tOut = new TransportOutDescription(
068:                        Constants.TRANSPORT_LOCAL);
069:                tOut.setSender(new LocalTransportSender());
070:                serverConfig.addTransportOut(tOut);
071:
072:                //        addInPhases(serverConfig.getInFlowPhases());
073:                //        DispatchPhase dp = (DispatchPhase)serverConfig.getInFlowPhases().get(1);
074:                //        dp.addHandler(new AddressingBasedDispatcher());
075:                //
076:                //        addInPhases(serverConfig.getInFaultFlowPhases());
077:                //
078:                //        addOutPhases(serverConfig.getOutFlowPhases());
079:                //        addOutPhases(serverConfig.getOutFaultFlowPhases());
080:
081:                ///////////////////////////////////////////////////////////////////////
082:                // Set up raw message receivers for OMElement based tests
083:
084:                serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_ONLY,
085:                        new RawXMLINOnlyMessageReceiver());
086:                serverConfig.addMessageReceiver(WSDL2Constants.MEP_URI_IN_OUT,
087:                        new RawXMLINOutMessageReceiver());
088:                serverConfig.addMessageReceiver(
089:                        WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
090:                        new RawXMLINOutMessageReceiver());
091:
092:                ///////////////////////////////////////////////////////////////////////
093:                // And client side
094:                clientCtx = ConfigurationContextFactory
095:                        .createConfigurationContextFromFileSystem(null);
096:            }
097:
098:            /**
099:             * Add well-known Phases on the in side
100:             *
101:             * @param flow the Flow in which to add these Phases
102:             */
103:            private void addInPhases(ArrayList flow) {
104:                flow.add(new Phase("PreDispatch"));
105:                Phase dispatchPhase = new DispatchPhase("Dispatch");
106:                flow.add(dispatchPhase);
107:            }
108:
109:            /**
110:             * Add well-known Phases on the out side
111:             *
112:             * @param flow the Flow in which to add these Phases
113:             */
114:            private void addOutPhases(ArrayList flow) {
115:                flow.add(new Phase("MessageOut"));
116:            }
117:
118:            /**
119:             * Deploy a class as a service.
120:             *
121:             * @param name the service name
122:             * @param myClass the Java class to deploy (all methods exposed by default)
123:             * @return a fully configured AxisService, already deployed into the server
124:             * @throws Exception in case of problems
125:             */
126:            protected AxisService deployClassAsService(String name,
127:                    Class myClass) throws Exception {
128:                return deployClassAsService(name, myClass, null);
129:            }
130:
131:            /**
132:             * Deploy a class as a service.
133:             *
134:             * @param name the service name
135:             * @param myClass the Java class to deploy (all methods exposed by default)
136:             * @param scope the service scope
137:             * @return a fully configured AxisService, already deployed into the server
138:             * @throws Exception in case of problems
139:             */
140:            protected AxisService deployClassAsService(String name,
141:                    Class myClass, String scope) throws Exception {
142:                AxisService service = new AxisService(name);
143:                if (scope != null)
144:                    service.setScope(scope);
145:
146:                service
147:                        .addParameter(Constants.SERVICE_CLASS, myClass
148:                                .getName());
149:
150:                Utils.fillAxisService(service, serverConfig, null, null);
151:
152:                serverCtx.deployService(service);
153:                return service;
154:            }
155:
156:            /**
157:             * Get a pre-initialized ServiceClient set up to talk to our local
158:             * server.  If you want to set options, call this and then use getOptions()
159:             * on the return.
160:             *
161:             * @return a ServiceClient, pre-initialized to talk using our local sender
162:             * @throws org.apache.axis2.AxisFault if there's a problem
163:             */
164:            protected ServiceClient getClient() throws AxisFault {
165:                Options opts = getOptions();
166:                ServiceClient client = new ServiceClient(clientCtx, null);
167:                client.setOptions(opts);
168:                return client;
169:            }
170:
171:            /**
172:             * Get a pre-initialized ServiceClient set up to talk to our local
173:             * server.  If you want to set options, call this and then use getOptions()
174:             * on the return. Clients created using this method have their To EPR
175:             * preset to include the address for the service+operation.
176:             *
177:             * @return a ServiceClient, pre-initialized to talk using our local sender
178:             * @throws org.apache.axis2.AxisFault if there's a problem
179:             */
180:            protected ServiceClient getClient(String serviceName,
181:                    String operationName) throws AxisFault {
182:                String url = LocalTransportReceiver.CONFIG_CONTEXT
183:                        .getServiceContextPath()
184:                        + "/" + serviceName;
185:
186:                Options opts = getOptions();
187:                opts.setTo(new EndpointReference(url));
188:                opts.setAction(operationName);
189:                ServiceClient client = new ServiceClient(clientCtx, null);
190:                client.setOptions(opts);
191:                return client;
192:            }
193:
194:            /**
195:             * Get an Options object initialized with the right transport info, defaulting to SOAP 1.2
196:             *
197:             * @return pre-initialized Options object
198:             */
199:            protected Options getOptions() {
200:                TransportOutDescription td = new TransportOutDescription(
201:                        "local");
202:                td.setSender(sender);
203:
204:                Options opts = new Options();
205:                opts.setTransportOut(td);
206:                opts
207:                        .setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
208:                return opts;
209:            }
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.