You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by js...@apache.org on 2005/05/26 23:25:02 UTC
svn commit: r178693 - in /incubator/beehive/trunk/controls/test:
infra/milton/milton.jar tools/milton/build.xml
tools/milton/src/org/apache/beehive/test/tools/milton/common/Report.java
tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java
Author: jsong
Date: Thu May 26 14:25:01 2005
New Revision: 178693
URL: http://svn.apache.org/viewcvs?rev=178693&view=rev
Log:
Update milton's SOAPReportTestCase and associated files.
Ran checkin tests.
Contributed by Jacob Danner
Modified:
incubator/beehive/trunk/controls/test/infra/milton/milton.jar
incubator/beehive/trunk/controls/test/tools/milton/build.xml
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common/Report.java
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java
Modified: incubator/beehive/trunk/controls/test/infra/milton/milton.jar
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/infra/milton/milton.jar?rev=178693&r1=178692&r2=178693&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/beehive/trunk/controls/test/tools/milton/build.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/tools/milton/build.xml?rev=178693&r1=178692&r2=178693&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/test/tools/milton/build.xml (original)
+++ incubator/beehive/trunk/controls/test/tools/milton/build.xml Thu May 26 14:25:01 2005
@@ -12,6 +12,8 @@
<path refid="junit.dependency.path"/>
<pathelement location="${httpunit.jar}"/>
<pathelement location="../../../../wsm/external/axis.jar"/>
+ <pathelement location="../../../../wsm/external/jaxrpc.jar"/>
+ <pathelement location="../../../../wsm/external/saaj.jar"/>
<pathelement location="${mantis.jar}"/>
<path refid="controls.dependency.path"/>
<fileset refid="velocity.fileset"/>
Modified: incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common/Report.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common/Report.java?rev=178693&r1=178692&r2=178693&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common/Report.java (original)
+++ incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common/Report.java Thu May 26 14:25:01 2005
@@ -3,19 +3,20 @@
import java.io.PrintStream;
import java.io.ByteArrayOutputStream;
-/**
-* Report class used for storing the results of a test. This object is
-* referenced by testResults.jsp (or custom report page) which can displays
-* the results stored in the Result object.
-*/
+/**
+ * Report class used for storing the results of a test. This object is
+ * referenced by testResults.jsp (or custom report page) which can displays
+ * the results stored in the Result object.
+ * @author jacobd@bea.com 5/20/2005 Added 'Axis' de/serializer methods
+ */
public class Report implements java.io.Serializable
{
static final long serialVersionUID = 1L;
-
+
public static final String PASS = "PASS";
public static final String FAIL = "FAIL";
public static final String ABORT = "ABORT";
-
+
// For PageFlow action annotations
public static final String KEY = "milton";
public static final String RESULTS = "miltonResults";
@@ -45,6 +46,7 @@
{
this(p_status == true ? Report.PASS : Report.FAIL);
}
+
public Report(String p_status, String p_message)
{
this(p_status, p_message, null);
@@ -55,74 +57,68 @@
setStatus(p_status);
setMessage(p_message);
setExceptionStack(p_stack);
- }
-
- public String getStatus()
- {
- return this.status;
}
public boolean getStatusAsBoolean()
{
return this.status == Report.PASS ? true : false;
}
-
- public String getMessage()
- {
- return this.message;
- }
-
- public String getExceptionStack()
- {
- return this.exceptionStack;
- }
-
+
+ /**
+ * Sets the status value for this Report.
+ *
+ * @param p_status
+ */
public void setStatus(String p_status)
{
if (null == p_status)
throw new IllegalArgumentException("Cannot set status to null");
- if (! Report.PASS.equals(p_status) &&
- ! Report.FAIL.equals(p_status) &&
- ! Report.ABORT.equals(p_status))
+ if (!Report.PASS.equals(p_status) &&
+ !Report.FAIL.equals(p_status) &&
+ !Report.ABORT.equals(p_status))
throw new IllegalArgumentException("Invalid Status: " + p_status +
- " Valid Status: PASS|FAIL|ABORT");
+ " Valid Status: PASS|FAIL|ABORT");
this.status = p_status;
}
-
+
+ /**
+ * Sets the status value for this Report.
+ *
+ * @param p_status
+ */
public void setStatus(boolean p_status)
{
setStatus(p_status == true ? Report.PASS : Report.FAIL);
}
-
+
+ /**
+ * Sets the message value for this Report.
+ *
+ * @param p_message
+ */
public void setMessage(String p_message)
{
this.message = p_message == null ? "" : p_message;
}
-
+
public void addMessage(String p_message)
{
this.message += "[( " + p_message + " )]";
}
-
+
public void setExceptionStack(Throwable e)
{
if (null == e) {
this.exceptionStack = "";
- }
- else {
+ } else {
ByteArrayOutputStream ostr = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(ostr));
-
+
setExceptionStack(ostr.toString());
}
}
-
- public void setExceptionStack(String es)
- {
- this.exceptionStack = es;
- }
-
+
public String toString()
{
String returnVal;
@@ -144,4 +140,156 @@
return returnVal;
}
+
+ /**
+ * Gets the status value for this Report.
+ *
+ * @return status
+ */
+ public java.lang.String getStatus()
+ {
+ return status;
+ }
+
+ /**
+ * Gets the message value for this Report.
+ *
+ * @return message
+ */
+ public java.lang.String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * Gets the exceptionStack value for this Report.
+ *
+ * @return exceptionStack
+ */
+ public java.lang.String getExceptionStack()
+ {
+ return exceptionStack;
+ }
+
+
+ /**
+ * Sets the exceptionStack value for this Report.
+ *
+ * @param exceptionStack
+ */
+ public void setExceptionStack(java.lang.String exceptionStack)
+ {
+ this.exceptionStack = exceptionStack;
+ }
+
+ private java.lang.Object __equalsCalc = null;
+
+ public synchronized boolean equals(java.lang.Object obj)
+ {
+ if (!(obj instanceof Report)) return false;
+ Report other = (Report) obj;
+ if (obj == null) return false;
+ if (this == obj) return true;
+ if (__equalsCalc != null) {
+ return (__equalsCalc == obj);
+ }
+ __equalsCalc = obj;
+ boolean _equals;
+ _equals = true &&
+ ((this.status == null && other.getStatus() == null) ||
+ (this.status != null &&
+ this.status.equals(other.getStatus()))) &&
+ ((this.message == null && other.getMessage() == null) ||
+ (this.message != null &&
+ this.message.equals(other.getMessage()))) &&
+ ((this.exceptionStack == null && other.getExceptionStack() == null) ||
+ (this.exceptionStack != null &&
+ this.exceptionStack.equals(other.getExceptionStack())));
+ __equalsCalc = null;
+ return _equals;
+ }
+
+ private boolean __hashCodeCalc = false;
+
+ public synchronized int hashCode()
+ {
+ if (__hashCodeCalc) {
+ return 0;
+ }
+ __hashCodeCalc = true;
+ int _hashCode = 1;
+ if (getStatus() != null) {
+ _hashCode += getStatus().hashCode();
+ }
+ if (getMessage() != null) {
+ _hashCode += getMessage().hashCode();
+ }
+ if (getExceptionStack() != null) {
+ _hashCode += getExceptionStack().hashCode();
+ }
+ __hashCodeCalc = false;
+ return _hashCode;
+ }
+
+ // Type metadata
+ private static org.apache.axis.description.TypeDesc typeDesc =
+ new org.apache.axis.description.TypeDesc(Report.class, true);
+
+ static
+ {
+ //NOTE: will need to update these values when and if package name of report changes
+ typeDesc.setXmlType(new javax.xml.namespace.QName("java:org.apache.beehive.test.tools.milton.common", "Report"));
+ org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("status");
+ elemField.setXmlName(new javax.xml.namespace.QName("java:org.apache.beehive.test.tools.milton.common", "Status"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(true);
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("message");
+ elemField.setXmlName(new javax.xml.namespace.QName("java:org.apache.beehive.test.tools.milton.common", "Message"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(true);
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("exceptionStack");
+ elemField.setXmlName(new javax.xml.namespace.QName("java:org.apache.beehive.test.tools.milton.common", "ExceptionStack"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(true);
+ typeDesc.addFieldDesc(elemField);
+ }
+
+ /**
+ * Return type metadata object
+ */
+ public static org.apache.axis.description.TypeDesc getTypeDesc()
+ {
+ return typeDesc;
+ }
+
+ /**
+ * Get Custom Serializer
+ */
+ public static org.apache.axis.encoding.Serializer getSerializer(java.lang.String mechType,
+ java.lang.Class _javaType,
+ javax.xml.namespace.QName _xmlType)
+ {
+ return
+ new org.apache.axis.encoding.ser.BeanSerializer(_javaType, _xmlType, typeDesc);
+ }
+
+ /**
+ * Get Custom Deserializer
+ */
+ public static org.apache.axis.encoding.Deserializer getDeserializer(java.lang.String mechType,
+ java.lang.Class _javaType,
+ javax.xml.namespace.QName _xmlType)
+ {
+ return
+ new org.apache.axis.encoding.ser.BeanDeserializer(_javaType, _xmlType, typeDesc);
+ }
+
}
Modified: incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java?rev=178693&r1=178692&r2=178693&view=diff
==============================================================================
--- incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java (original)
+++ incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/SOAPReportTestCase.java Thu May 26 14:25:01 2005
@@ -8,40 +8,231 @@
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
+import org.apache.axis.description.OperationDesc;
import javax.xml.namespace.QName;
+import java.net.MalformedURLException;
+/**
+ * @author jacobd@bea.com 5/20/2005 Cleaned up SOAP payload creation, created methods for doc/literal payloads
+ *
+ */
public abstract class SOAPReportTestCase extends ReportTestCase
{
public SOAPReportTestCase(String name)
{
super(name);
+ hostName = this.getUrlPrefix();
}
- private Call createCall(String p_uri, String p_method) throws java.net.MalformedURLException
+ private static String hostName;
+ private static String endpoint;
+
+ /**
+ * Gets the endpoint, the URL the message will be sent to
+ * @return
+ */
+ public static String getEndpoint()
+ {
+ return endpoint;
+ }
+
+
+ /**
+ * This method is used to set where soap requests will be sent
+ * the value can be one of relative or full path
+ *
+ * @param end How value is set \n
+ * '/foobaz/foobar.jws' - A relative path to the endpoint given a server context
+ * The currently set hostname will be prepended to this value
+ * or if URI does not start with '/' we expected a full endpoint
+ * something like http://localhost:7001
+ */
+ public static void setEndpoint(String end)
+ {
+
+ if (end == null)
+ throw new IllegalArgumentException("Endpoint cannot be null");
+ else if(end.startsWith("/")) //the passed in a webapp relative path
+ SOAPReportTestCase.endpoint = getHostName()+ end;
+ else //user included full http path
+ SOAPReportTestCase.endpoint = end;
+ }
+
+ /**
+ * Get the currently set hostname
+ *
+ * @return
+ */
+ public static String getHostName()
+ {
+ return hostName;
+ }
+
+ /**
+ * Unless set, this is ReportTestCase.getUrlPrefix()
+ * This should be set to something like http://foobaz:7001 if needed
+ *
+ * @param hostName
+ */
+ public static void setHostName(String hostName)
+ {
+ SOAPReportTestCase.hostName = hostName;
+ }
+
+
+ public static class Constants
+ {
+ //work around for future WS-interop problems
+ //change when issue gets fixed
+ private static String RESP_NAME = "return";
+
+ public static String getRESP_NAME()
+ {
+ return RESP_NAME;
+ }
+
+ public static void setRESP_NAME(String RESPONSE_ELEMENT_NAME)
+ {
+ RESP_NAME = RESPONSE_ELEMENT_NAME;
+ }
+
+ }
+
+ /**
+ * useful for manually building a Call Object
+ * should not be used for test purposes, unless you know what you are doing
+ *
+ * @param endpoint - see setEndpointAbove
+ * @param p_uri - the URI or targetNamespace of the WebService
+ * @param p_method - the method you want to invoke
+ * @return isRPC - send message in RPC format
+ */
+ protected Call getCall(String endpoint, String p_uri, String p_method, boolean isRPC) throws MalformedURLException {
+ if( endpoint == null)
+ setEndpoint(p_uri);
+ else
+ setEndpoint(endpoint);
+
+ if(isRPC)
+ return createCall_RpcStyle(endpoint, p_uri, p_method);
+ else
+ return createCall_DocLitWrappedStyle( endpoint, p_uri, p_method);
+
+ }
+
+ private Call createCall_DocLitWrappedStyle(String endpoint, String p_uri, String p_method)
+ throws java.net.MalformedURLException
+ {
+ // BUGBUG: -- WAS test case return type
+ //new QName("http://common.milton.tools.test.beehive.apache.org", "Report");
+ QName l_qname = new javax.xml.namespace.QName("java:org.apache.beehive.test.tools.milton.common", "Report");
+
+ Call l_call = new Call(createUrl(endpoint));
+ OperationDesc oper = l_call.getOperation();
+
+ oper = new org.apache.axis.description.OperationDesc();
+ oper.setName(p_method);
+ oper.setReturnType(l_qname);
+ oper.setReturnClass(Report.class);
+ oper.setReturnQName(new javax.xml.namespace.QName(p_uri, Constants.getRESP_NAME()));
+ oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
+ oper.setUse(org.apache.axis.constants.Use.LITERAL);
+
+
+ l_call.setOperation(p_method);
+ //TODO: do we need soapAction value to be sent?
+ l_call.setUseSOAPAction(true);
+ l_call.setSOAPActionURI(p_uri + p_method);
+
+ l_call.setEncodingStyle(null);
+ l_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
+ Boolean.FALSE);
+ l_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
+ Boolean.FALSE);
+ l_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
+ l_call.setOperationName(new javax.xml.namespace.QName(p_uri, p_method));
+ l_call.setReturnType(l_qname, Report.class);
+ l_call.registerTypeMapping(Report.class, l_qname,
+ new BeanSerializerFactory(Report.class, l_qname),
+ new BeanDeserializerFactory(Report.class, l_qname), true);
+ l_call.setOperation(oper);
+ return l_call;
+ }
+
+
+ //BUGBUG: Test this for RPC calls
+ private Call createCall_RpcStyle(String endpoint, String p_uri, String p_method) throws java.net.MalformedURLException
{
- Call l_call = new Call(createUrl(p_uri));
- QName l_qname = new QName("http://common.milton.tools.test.beehive.apache.org", "Report");
+ Call l_call = new Call(createUrl(endpoint));
+ //?BUGBUG? -- Figure this one out
+ //Should this be
+ QName l_qname = new javax.xml.namespace.QName("java:org.apache.beehive.test.tools.milton.common", "Report");
+ //since thats how its defined in the WSDL??
+ //QName l_qname = new QName("http://common.milton.tools.test.beehive.apache.org", "Report");
l_call.setOperationName(new javax.xml.namespace.QName(p_method));
l_call.setReturnType(l_qname, Report.class);
l_call.registerTypeMapping(Report.class, l_qname,
- new BeanSerializerFactory(Report.class, l_qname),
- new BeanDeserializerFactory(Report.class, l_qname), true);
+ new BeanSerializerFactory(Report.class, l_qname),
+ new BeanDeserializerFactory(Report.class, l_qname), true);
return l_call;
}
- protected void assertReport(String p_uri, String p_method) throws Exception
+ /**
+ * Convenience method for invoking a test method. This method works for
+ * doc/literal wrapped web services. If you are testing against an RPC/Encoded
+ * WS please call assertReport(p_uri, p_method, true) directly
+ *
+ * @param p_uri
+ * @param p_method
+ * @throws Exception
+ */
+ protected void assertReport(String p_uri, String p_method)
+ throws Exception
{
+ setEndpoint(p_uri);
+ assertReport(getEndpoint(), p_uri, p_method, false);
+ }
+
+
+ /**
+ * Convenience method for invoking a test method. This method works for
+ * doc/literal wrapped web services. If you are testing against an RPC/Encoded
+ * WS please call assertReport(p_uri, p_method, true) directly
+ *
+ * @param p_uri
+ * @param p_method
+ * @throws Exception
+ */
+ protected void assertReport(String endpoint, String p_uri, String p_method)
+ throws Exception
+ {
+ setEndpoint(endpoint);
+ assertReport(getEndpoint(), p_uri, p_method, false);
+ }
+
+ protected void assertReport(String endpoint, String p_uri, String p_method, boolean isRpcMethod) throws Exception
+ {
+ //Assumption, URI should be endpoint
+ if(getEndpoint() == null)
+ setEndpoint(p_uri);
+
if (null == p_uri || null == p_method)
throw new IllegalArgumentException("URI and Method cannot be Null");
- Object l_resp = createCall(p_uri, p_method).invoke(new Object[] {});
-
+ Object l_resp;
+ if (isRpcMethod) //rpc method
+ l_resp = createCall_RpcStyle(getEndpoint(), p_uri, p_method).invoke(new Object[]{});
+ else // default to doc literal
+ l_resp = createCall_DocLitWrappedStyle(getEndpoint(),
+ p_uri, p_method).invoke(new Object[]{});
+
+
if (l_resp instanceof java.rmi.RemoteException)
- throw (java.rmi.RemoteException)l_resp;
+ throw (java.rmi.RemoteException) l_resp;
- Report l_report = (Report)l_resp;
+ Report l_report = (Report) l_resp;
String l_status = l_report.getStatus();
String l_message = l_report.getMessage();
@@ -49,19 +240,19 @@
if (Report.ABORT.equals(l_status))
throw new AbortTestException("Abort Status Dectected: \n" +
- l_report.toString());
+ l_report.toString());
else if (Report.FAIL.equals(l_status))
throw new junit.framework.AssertionFailedError("FAILURE: \n" +
- l_report.toString());
+ l_report.toString());
- else if (! Report.PASS.equals(l_status))
+ else if (!Report.PASS.equals(l_status))
throw new AbortTestException("Unknown Status Detected: \n" +
- l_report.toString());
+ l_report.toString());
- if (null != l_message && ! "".equals(l_message))
+ if (null != l_message && !"".equals(l_message))
System.out.println("\n[MESSAGES]\n\t" + l_message);
- if (null != l_exceptionStack && ! "".equals(l_exceptionStack))
+ if (null != l_exceptionStack && !"".equals(l_exceptionStack))
System.out.println("\n[EXCEPTION]\n\t" + l_exceptionStack);
}
-}
+}
\ No newline at end of file