Author: nthaker
Date: Mon Jul 12 22:16:54 2010
New Revision: 963508
URL: http://svn.apache.org/viewvc?rev=963508&view=rev
Log:
AXIS2-4775
This change ensures that we will use Request and Response wrapper Bean packaged
by customer or we will Generate Wrappers if they are not packaged.
Added:
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersException.java
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersService.java
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/WrapperBeanMarshallTests.java
axis/axis2/java/core/trunk/modules/jaxws/wsgen-tests.xml
Modified:
axis/axis2/java/core/trunk/modules/jaxws/pom.xml
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/ArtifactProcessor.java
Modified: axis/axis2/java/core/trunk/modules/jaxws/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/pom.xml?rev=963508&r1=963507&r2=963508&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/jaxws/pom.xml Mon Jul 12 22:16:54 2010
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
@@ -20,7 +19,7 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.axis2</groupId>
@@ -98,7 +97,25 @@
<version>${version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>jaxws-tools</artifactId>
+ <version>2.1.3</version>
+ </dependency>
+ <!-- If we dont include tools.jar as dependency, maven throws
NoClassDefFound on wsGen run -->
+ <dependency>
+ <groupId>java</groupId>
+ <artifactId>tools</artifactId>
+ <version>$version</version>
+ <scope>system</scope>
+ <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
+ </dependency>
</dependencies>
+
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
@@ -203,34 +220,39 @@
<compilerVersion>1.5</compilerVersion>
<source>1.5</source>
<target>1.5</target>
+
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
+
<executions>
<execution>
<id>gen-ts</id>
<phase>generate-test-sources</phase>
<configuration>
- <tasks unless="maven.test.skip">
+ <tasks unless="maven.test.skip">
<!-- Theres got to be a better way to do this
-->
<property name="schema.source.dir"
value="test-resources/xsd"/>
<property name="wsdl.source.dir"
value="test-resources/wsdl"/>
- <property name="schema.output.base.dir"
value="target/schema"/>
+ <property name="schema.output.base.dir"
value="target/schema"/>
<property name="schema.generated.src.dir"
value="${schema.output.base.dir}/src"/>
<property name="schema.generated.classes.dir"
value="${schema.output.base.dir}/classes"/>
+
<!-- make the dirs -->
<mkdir dir="${schema.output.base.dir}"/>
<mkdir dir="${schema.generated.src.dir}"/>
<mkdir dir="${schema.generated.classes.dir}"/>
+
<!-- Run JAXB schema compiler with designated
schemas -->
<echo>Generating JAX-B classes from XSDs</echo>
<echo>Generating java from echo.xsd</echo>
<java classname="com.sun.tools.xjc.Driver"
fork="true">
<classpath
refid="maven.runtime.classpath"/>
+
<classpath
location="${compiled.classes.dir}"/>
<arg line="-d ${schema.generated.src.dir}
-quiet ${schema.source.dir}/echo.xsd"/>
</java>
@@ -266,7 +288,7 @@
<classpath
refid="maven.runtime.classpath"/>
<classpath
location="${compiled.classes.dir}"/>
<arg line="-d ${schema.generated.src.dir}
-quiet -wsdl ${wsdl.source.dir}/AddNumbers.wsdl"/>
- </java>
+ </java>
</tasks>
</configuration>
<goals>
@@ -287,6 +309,22 @@
<property name="addressing_version"
value="${version}"/>
<ant antfile="build.xml" inheritall="true"
inheritrefs="true"
dir="." target="build-repo"/>
+
+ <property
name="compile_classpath" refid="maven.compile.classpath" />
+ <property
name="runtime_classpath" refid="maven.runtime.classpath" />
+ <property
name="test_classpath" refid="maven.test.classpath" />
+ <property
name="plugin_classpath" refid="maven.plugin.classpath" />
+
+ <!-- Defining wsGen task -->
+ <taskdef
name="wsgen" loaderRef="refwsgen" classname="com.sun.tools.ws.ant.WsGen">
+
<classpath>
+
<path refid="maven.runtime.classpath" />
+
<path refid="maven.compile.classpath" />
+
</classpath>
+ </taskdef>
+ <!-- Invoking
test cases that need to generate artifacts using wsGen -->
+ <ant antfile="wsgen-tests.xml"
inheritall="true" inheritrefs="true"
+ dir="." target="run-wsgen-tests"/>
</tasks>
</configuration>
<goals>
@@ -374,6 +412,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>report-only</report>
+ </reports>
+ </reportSet>
+ </reportSets>
</plugin>
</plugins>
</reporting>
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/ArtifactProcessor.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/ArtifactProcessor.java?rev=963508&r1=963507&r2=963508&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/ArtifactProcessor.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/ArtifactProcessor.java
Mon Jul 12 22:16:54 2010
@@ -238,12 +238,27 @@ class ArtifactProcessor {
wrapperClass = newValue;
}
}
- if(cls==null && (type.equals("@WebFault")||
type.equals("faultInfo"))){
+
+ if(cls==null &&
+ (type.equals("@RequestWrapper")||
type.equals("@ResponseWrapper")||type.equals("@WebFault")||
type.equals("faultInfo"))){
+
+ //Support for Fault Bean Generation
//As per JAX-WS 2.2 Specification section 3.7 an
application programmer can choose not to
//package the faultBeans, if we have reached this
point in the code then user has choosen
//not to package the fault bean. If there is a
cache of generated artifacts available then
//lets look for the missing faultBean there.
-
+
+ //Support for Wrapper Bean Generation
+ //As per JAX-WS 2.2 Specificaiton section 3.6.2.1
pg 41 an application programmer does not use
+ //the wrapper bean classes, so the application
need not package these classes. If we have reached
+ //this point in the code then user has choosen not
to package these beans.
+
+ //NOTE:If we find Generated artifacts from cache
this guarantees that we will not use
+ //DocLitWrappedMinimum marshaller code. The
advantage of normal DocLitWrappedMarshaller is
+ //that it is very robust and has support of lot
more datatypes than in DocLitWrappedMinimum.
+ if(log.isDebugEnabled()){
+ log.debug("Adding cache to classpath");
+ }
ClassFinderFactory cff =
(ClassFinderFactory)FactoryRegistry.getFactory(ClassFinderFactory.class);
ClassFinder cf = cff.getClassFinder();
@@ -317,11 +332,26 @@ class ArtifactProcessor {
if (cls2 == null) {
cls2 = loadClassOrNull(defaultValue,
altClassLoader);
}
- if(cls2==null && (type.equals("faultInfo")||
type.equals("@WebFault"))){
- //As per JAX-WS 2.2 Specification section 3.7 an
application programmer can choose not to
- //package the faultBeans, if we have reached this
point in the code then user has choosen
- //not to package the fault bean. If there is a
cache of generated artifacts available then
- //lets look for the missing faultBean there.
+ if(cls2==null &&
+ (type.equals("@RequestWrapper")||
type.equals("@ResponseWrapper")||type.equals("@WebFault")||
type.equals("faultInfo"))){
+
+ //Support for Fault Bean Generation
+ //As per JAX-WS 2.2 Specification section 3.7
an application programmer can choose not to
+ //package the faultBeans, if we have reached
this point in the code then user has choosen
+ //not to package the fault bean. If there is a
cache of generated artifacts available then
+ //lets look for the missing faultBean there.
+
+ //Support for Wrapper Bean Generation
+ //As per JAX-WS 2.2 Specificaiton section
3.6.2.1 pg 41 an application programmer does not use
+ //the wrapper bean classes, so the application
need not package these classes. If we have reached
+ //this point in the code then user has choosen
not to package these beans.
+
+ //NOTE:If we find Generated artifacts from
cache this guarantees that we will not use
+ //DocLitWrappedMinimum marshaller code. The
advantage of normal DocLitWrappedMarshaller is
+ //that it is very robust and has support of lot
more datatypes than in DocLitWrappedMinimum.
+ if(log.isDebugEnabled()){
+ log.debug("Adding cache to classpath");
+ }
if(log.isDebugEnabled()){
log.debug("Adding cache to classpath");
}
Added:
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersException.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersException.java?rev=963508&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersException.java
(added)
+++
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersException.java
Mon Jul 12 22:16:54 2010
@@ -0,0 +1,18 @@
+
+package org.apache.axis2.jaxws.wrapper.beans;
+
+import javax.xml.ws.WebFault;
+
+...@webfault(name = "AddNumbersFault", targetNamespace =
"http://org/test/addnumbers")
+public class AddNumbersException extends Exception
+{
+
+ private String message = null;
+ public AddNumbersException(){}
+ public AddNumbersException(String message){
+ this.message = message;
+ }
+ public String getInfo(){
+ return message;
+ }
+}
Added:
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersService.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersService.java?rev=963508&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersService.java
(added)
+++
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/AddNumbersService.java
Mon Jul 12 22:16:54 2010
@@ -0,0 +1,15 @@
+package org.apache.axis2.jaxws.wrapper.beans;
+
+
+
[email protected] (targetNamespace="http://org/test/addnumbers",
serviceName="AddNumbersService", portName="AddNumbersPort")
+public class AddNumbersService{
+
+ public int addNumbers(int arg0, int arg1) throws AddNumbersException {
+ if(arg0+arg1<0){
+ throw new AddNumbersException("sum is less than 0");
+ }
+ return arg0+arg1;
+ }
+
+}
\ No newline at end of file
Added:
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/WrapperBeanMarshallTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/WrapperBeanMarshallTests.java?rev=963508&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/WrapperBeanMarshallTests.java
(added)
+++
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/wrapper/beans/WrapperBeanMarshallTests.java
Mon Jul 12 22:16:54 2010
@@ -0,0 +1,114 @@
+/**
+ *
+ */
+package org.apache.axis2.jaxws.wrapper.beans;
+
+
+import org.apache.axis2.jaxws.Constants;
+import org.apache.axis2.jaxws.description.DescriptionFactory;
+import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.EndpointDescriptionJava;
+import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
+import org.apache.axis2.jaxws.marshaller.factory.MethodMarshallerFactory;
+import
org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMinimalMethodMarshaller;
+import org.apache.axis2.jaxws.unitTest.TestLogger;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+public class WrapperBeanMarshallTests extends TestCase {
+ /**
+ * This is the negative test case, when we do not use generated artifacts
from cache
+ * and user did not package wrapper beans, we should see use of
DocLitWrappedMinumumMarshaller.
+ */
+ public void testGetMarshallerOperationDescriptionBooleanNegative() {
+ TestLogger.logger.debug("---------------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ String cache_location = "/target/wscache/classes";
+ try{
+ String baseDir = new
File(System.getProperty("basedir",".")).getCanonicalPath();
+ cache_location = new
File(baseDir+cache_location).getAbsolutePath();
+ TestLogger.logger.debug("cache location ="+cache_location);
+
+ //Get EndpointDescription.
+ //Set location on AxisConfiguraiton.
+ Class sei = AddNumbersService.class;
+ EndpointDescription description = getEndpointDesc(sei);
+ TestLogger.logger.debug("description objects where created
successfully");
+ OperationDescription[] ops
=description.getEndpointInterfaceDescription().getOperations();
+ assertNotNull( "OperationDescriptions where null", ops);
+ assertTrue("No Operation Descriptions where found", ops.length>0);
+ OperationDescription op = ops[0];
+ TestLogger.logger.debug("operation found, java
methodName="+op.getJavaMethodName());
+ //Don not Set cache on AxisConfiguration.
+ //get Marshaller, verify its not DoclitWrappedMinimum.
+ TestLogger.logger.debug("ws_cache location NOT set on
AxisConfigContext, location="+cache_location);
+ MethodMarshaller mm = MethodMarshallerFactory.getMarshaller(op,
false);
+ assertNotNull("getMarshaller returned null", mm );
+ TestLogger.logger.debug("MethodMarshaller was created,
type="+mm.getClass().getName());
+ assertTrue("Generated artifacts not found, Method marshaller
should be DocLitWrappedMinimumMarshaller", (mm instanceof
DocLitWrappedMinimalMethodMarshaller));
+ }catch(Exception e){
+ TestLogger.logger.debug("Exception ="+e.getMessage());
+ fail(e.getMessage());
+ }
+
+ }
+ /**
+ * In this test case user did not package wrapper beans but we add
generated artifacts from cache, we should see use of
+ * DocLitWrappedMarshaller.
+ * Test method for {...@link
org.apache.axis2.jaxws.marshaller.factory.MethodMarshallerFactory#getMarshaller(org.apache.axis2.jaxws.description.OperationDescription,
boolean)}.
+ */
+ public void testGetMarshallerOperationDescriptionBoolean() {
+ TestLogger.logger.debug("---------------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ String cache_location = "/target/wscache/classes";
+ try{
+ String baseDir = new
File(System.getProperty("basedir",".")).getCanonicalPath();
+ cache_location = new
File(baseDir+cache_location).getAbsolutePath();
+ TestLogger.logger.debug("cache location ="+cache_location);
+
+ //Get EndpointDescription.
+ //Set location on AxisConfiguraiton.
+ Class sei = AddNumbersService.class;
+ EndpointDescription description = getEndpointDesc(sei);
+ TestLogger.logger.debug("description objects where created
successfully");
+ OperationDescription[] ops
=description.getEndpointInterfaceDescription().getOperations();
+ assertNotNull( "OperationDescriptions where null", ops);
+ assertTrue("No Operation Descriptions where found", ops.length>0);
+ OperationDescription op = ops[0];
+ TestLogger.logger.debug("operation found, java
methodName="+op.getJavaMethodName());
+ //Set cache on AxisConfiguration.
+ //get Marshaller, verify its not DoclitWrappedMinimum.
+
description.getServiceDescription().getAxisConfigContext().setProperty(Constants.WS_CACHE,
cache_location);
+ TestLogger.logger.debug("ws_cache location set on
AxisConfigContext, location="+cache_location);
+ MethodMarshaller mm = MethodMarshallerFactory.getMarshaller(op,
false);
+ assertNotNull("getMarshaller returned null", mm );
+ TestLogger.logger.debug("MethodMarshaller was created,
type="+mm.getClass().getName());
+ assertTrue("Generated artifacts are in cache, Method marshaller
should not be DocLitWrappedMinimumMarshaller", !(mm instanceof
DocLitWrappedMinimalMethodMarshaller));
+ }catch(Exception e){
+ TestLogger.logger.debug("Exception ="+e.getMessage());
+ fail(e.getMessage());
+ }
+
+ }
+
+ private EndpointDescription getEndpointDesc(Class implementationClass) {
+ // Use the description factory directly; this will be done within the
JAX-WS runtime
+ ServiceDescription serviceDesc =
+
DescriptionFactory.createServiceDescription(implementationClass);
+ assertNotNull(serviceDesc);
+
+ EndpointDescription[] endpointDesc =
serviceDesc.getEndpointDescriptions();
+ assertNotNull(endpointDesc);
+ assertEquals(1, endpointDesc.length);
+
+ // TODO: How will the JAX-WS dispatcher get the appropriate port (i.e.
endpoint)? Currently assumes [0]
+ EndpointDescription testEndpointDesc = endpointDesc[0];
+ return testEndpointDesc;
+ }
+}
Added: axis/axis2/java/core/trunk/modules/jaxws/wsgen-tests.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/wsgen-tests.xml?rev=963508&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws/wsgen-tests.xml (added)
+++ axis/axis2/java/core/trunk/modules/jaxws/wsgen-tests.xml Mon Jul 12
22:16:54 2010
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project basedir="." default="run-wsgen-tests" name="wsgen-tests">
+
+ <property name="wscache.output.base.dir" value="target/wscache" />
+ <property name="wscache.generated.src.dir"
value="${wscache.output.base.dir}/src" />
+ <property name="wscache.generated.classes.dir"
value="${wscache.output.base.dir}/classes" />
+ <property name="compile.test.classes" value="target/test-classes" />
+
+
+ <target name="run-wsgen-tests" depends="wrapper-beans"/>
+
+
+ <target name="create-cache">
+ <mkdir dir="${wscache.output.base.dir}" />
+ <mkdir dir="${wscache.generated.src.dir}" />
+ <mkdir dir="${wscache.generated.classes.dir}" />
+ </target>
+
+ <target name="wrapper-beans" depends="create-cache">
+ <echo>Generating artifacts for
org.apache.axis2.jaxws.wrapper.beans.AddNumbersService </echo>
+ <wsgen
+ sei="org.apache.axis2.jaxws.wrapper.beans.AddNumbersService"
+ destdir="${wscache.generated.classes.dir}"
+ resourcedestdir="${wscache.generated.src.dir}"
+ keep="false"
+ verbose="false"
+ genwsdl="true">
+ <classpath>
+ <pathelement path="${compile.test.classes}" />
+ </classpath>
+ </wsgen>
+ </target>
+</project>
\ No newline at end of file