You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/12/24 04:35:50 UTC
svn commit: r358916 - in
/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl:
codegen/emitter/MultiLanguageClientEmitter.java
template/java/TestClassTemplate.xsl
Author: dims
Date: Fri Dec 23 19:35:46 2005
New Revision: 358916
URL: http://svn.apache.org/viewcvs?rev=358916&view=rev
Log:
Trying to get a clean test case automatically generated using the following command line
java org.apache.axis2.wsdl.WSDL2Java -d adb -o work -s -p samples.perf -t -ss -sd -uri \APACHE\axis2\modules\samples\wsdl\perf.wsdl
TODO:
- Need to find a better spot for the getParamInitializer method.
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=358916&r1=358915&r2=358916&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java Fri Dec 23 19:35:46 2005
@@ -618,6 +618,8 @@
addAttribute(doc, "default", "yes", param);
}
+ addAttribute(doc, "value", getParamInitializer(typeMapping), param);
+
//add this as a body parameter
addAttribute(doc, "location", "body", param);
Iterator iter = inputMessage.getExtensibilityAttributes().iterator();
@@ -1334,6 +1336,49 @@
}
}
+ /** Field constructorMap */
+ private static HashMap constructorMap = new HashMap(50);
+ static {
+
+ // Type maps to a valid initialization value for that type
+ // Type var = new Type(arg)
+ // Where "Type" is the key and "new Type(arg)" is the string stored
+ // Used in emitting test cases and server skeletons.
+ constructorMap.put("int", "0");
+ constructorMap.put("float", "0");
+ constructorMap.put("boolean", "true");
+ constructorMap.put("double", "0");
+ constructorMap.put("byte", "(byte)0");
+ constructorMap.put("short", "(short)0");
+ constructorMap.put("long", "0");
+ constructorMap.put("java.lang.Boolean", "new java.lang.Boolean(false)");
+ constructorMap.put("java.lang.Byte", "new java.lang.Byte((byte)0)");
+ constructorMap.put("java.lang.Double", "new java.lang.Double(0)");
+ constructorMap.put("java.lang.Float", "new java.lang.Float(0)");
+ constructorMap.put("java.lang.Integer", "new java.lang.Integer(0)");
+ constructorMap.put("java.lang.Long", "new java.lang.Long(0)");
+ constructorMap.put("java.lang.Short", "new java.lang.Short((short)0)");
+ constructorMap.put("java.math.BigDecimal",
+ "new java.math.BigDecimal(0)");
+ constructorMap.put("java.math.BigInteger",
+ "new java.math.BigInteger(\"0\")");
+ constructorMap.put("java.lang.Object", "new java.lang.String()");
+ constructorMap.put("byte[]", "new byte[0]");
+ constructorMap.put("java.util.Calendar",
+ "java.util.Calendar.getInstance()");
+ constructorMap.put(
+ "javax.xml.namespace.QName",
+ "new javax.xml.namespace.QName(\"http://double-double\", \"toil-and-trouble\")");
+ }
+
+ String getParamInitializer(String paramType) {
+ // Look up paramType in the table
+ String out = (String) constructorMap.get(paramType);
+ if(out == null) {
+ out = "null";
+ }
+ return out;
+ }
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl?rev=358916&r1=358915&r2=358916&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl Fri Dec 23 19:35:46 2005
@@ -17,23 +17,6 @@
*/
package <xsl:value-of select="$package"/>;
- import java.io.InputStream;
- import java.net.ServerSocket;
-
- import javax.xml.namespace.QName;
-
- import org.apache.axis2.context.ConfigurationContext;
- import org.apache.axis2.deployment.DeploymentEngine;
- import org.apache.axis2.description.AxisService;
- import org.apache.axis2.engine.AxisConfiguration;
- import org.apache.axis2.wsdl.codegen.Constants;
- import org.apache.axis2.om.OMAbstractFactory;
- import org.apache.axis2.om.OMElement;
- import org.apache.axis2.om.OMFactory;
- import org.apache.axis2.om.impl.llom.OMTextImpl;
- import org.apache.axis2.transport.http.SimpleHTTPServer;
-
-
/*
* <xsl:value-of select="@name"/> Junit test case
*/
@@ -52,27 +35,27 @@
<xsl:value-of select="$package"/>.<xsl:value-of select="$stubname"/> stub =
new <xsl:value-of select="$package"/>.<xsl:value-of select="$stubname"/>();//the default implementation should point to the right endpoint
- //create a new databinder
- <xsl:variable name="fullsupporterclassname"><xsl:value-of select="$dbpackage"/>.<xsl:value-of select="$dbsupportclassname"/></xsl:variable>
- <xsl:value-of select="$fullsupporterclassname"/> databindSupporter = new <xsl:value-of select="$fullsupporterclassname"/>();
<xsl:choose>
<xsl:when test="count(input/param)>0">
-<!-- //<xsl:variable name="firstInput"><xsl:value-of select="input/param[1]"/></xsl:variable> -->
+ <xsl:for-each select="input/param[@type!='']">
+ <xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@name"/><xsl:text> = </xsl:text><xsl:value-of select="@value"/><xsl:text>;</xsl:text>
+ </xsl:for-each>
+
<xsl:choose>
<xsl:when test="$outputtype=''">
<!-- for now think there is only one input element -->
//There is no output to be tested!
stub.<xsl:value-of select="@name"/>(
<xsl:for-each select="input/param">
- <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if>(<xsl:value-of select="@type"/>)databindSupporter.getTestObject(<xsl:value-of select="@type"/>.class)
+ <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@name"/>
</xsl:if>
</xsl:for-each>);
</xsl:when>
<xsl:otherwise>
assertNotNull(stub.<xsl:value-of select="@name"/>(
<xsl:for-each select="input/param">
- <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if>(<xsl:value-of select="@type"/>)databindSupporter.getTestObject(<xsl:value-of select="@type"/>.class)
+ <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@name"/>
</xsl:if>
</xsl:for-each>));
</xsl:otherwise>