You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2008/07/12 12:54:59 UTC
svn commit: r676148 - in /ode/trunk/axis2-war/src/test:
java/org/apache/ode/axis2/httpbinding/ resources/TestHttpBindingExt_DELETE/
resources/TestHttpBindingExt_GET/ resources/TestHttpBindingExt_POST/
resources/TestHttpBindingExt_PUT/
Author: midon
Date: Sat Jul 12 03:54:58 2008
New Revision: 676148
URL: http://svn.apache.org/viewvc?rev=676148&view=rev
Log:
add more test for higher coverage score
Modified:
ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java
ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_DELETE/Blog.wsdl
ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/Blog.wsdl
ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel
ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_POST/Blog.wsdl
ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/Blog.wsdl
ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/http-binding-ext-PUT.bpel
Modified: ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java?rev=676148&r1=676147&r2=676148&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java (original)
+++ ode/trunk/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/JettyWrapper.java Sat Jul 12 03:54:58 2008
@@ -257,10 +257,43 @@
}
private void doGet(HttpServletRequest request, HttpServletResponse response, String articleId) throws IOException {
- // doGET must receive a custom header, just send it back and let the caller check the received value
- response.setHeader("TimestampHeader", request.getHeader("TimestampHeader"));
+ String faultType = request.getHeader("Fault-Type");
+ if ("400_not_found".equals(faultType)) {
+ response.setStatus(400);
+ } else if ("500_operation_with_no_fault_failed".equals(faultType)) {
+ response.setStatus(500);
+ } else if ("200_missing_part_in_header".equals(faultType)) {
+ // a part is bound to a custom header
+ // this test does not set it on purpose
+
+ response.setContentType("text/xml");
+ Element articleEl = createArticleDoc(articleId);
+
+ response.getOutputStream().print(DOMUtils.domToString(articleEl));
+ response.setStatus(200);
+ } else if ("200_malformed_body".equals(faultType)) {
+ // parts to http headers, just send them back and let the caller check the received values
+ response.setHeader("TimestampHeader", request.getHeader("TimestampHeader"));
+ response.setHeader("From", request.getHeader("From"));
+
+ response.setContentType("text/xml");
+ response.getOutputStream().print("<book><abstract>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</abstract>");
+ response.setStatus(200);
+ } else {
+ // some parts are bound to http headers
+ // just send them back and let the caller check the received values
+ response.setHeader("TimestampHeader", request.getHeader("TimestampHeader"));
+ response.setHeader("From", request.getHeader("From"));
- response.setContentType("text/xml");
+ response.setContentType("text/xml");
+ Element articleEl = createArticleDoc(articleId);
+
+ response.getOutputStream().print(DOMUtils.domToString(articleEl));
+ response.setStatus(200);
+ }
+ }
+
+ private Element createArticleDoc(String articleId) {
Document doc = DOMUtils.newDocument();
Element articleEl = doc.createElementNS("http://ode/bpel/test/blog", "article");
Element idEl = doc.createElementNS("http://ode/bpel/test/blog", "id");
@@ -271,9 +304,7 @@
idEl.setTextContent(articleId);
titleEl.setTextContent("A title with a random number " + System.currentTimeMillis());
-
- response.getOutputStream().print(DOMUtils.domToString(articleEl));
- response.setStatus(200);
+ return articleEl;
}
private void doPost(HttpServletRequest request, HttpServletResponse response, String articleId) {
@@ -290,6 +321,10 @@
response.setContentType("text");
response.getOutputStream().print("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.");
response.setStatus(500);
+ } else if ("500_malformed_xml_body".equals(faultType)) {
+ response.setContentType("text/xml");
+ response.getOutputStream().print("<book><abstract>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</abstract>");
+ response.setStatus(500);
} else if ("500_unknown_xml_body".equals(faultType)) {
response.setContentType("text/xml");
response.getOutputStream().print("<book><abstract>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</abstract></book>");
Modified: ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_DELETE/Blog.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_DELETE/Blog.wsdl?rev=676148&r1=676147&r2=676148&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_DELETE/Blog.wsdl (original)
+++ ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_DELETE/Blog.wsdl Sat Jul 12 03:54:58 2008
@@ -25,6 +25,7 @@
<xsd:element name="article" type="tns:ArticleType"/>
<xsd:element name="comment" type="tns:CommentType"/>
<xsd:element name="fault" type="tns:FaultType"/>
+ <xsd:element name="from" type="xsd:string"/>
<xsd:complexType name="ArticleType">
<xsd:sequence>
<xsd:element name="id" type="xsd:string"/>
@@ -48,6 +49,7 @@
<wsdl:message name="IdMessage">
<wsdl:part name="timestamp" type="xsd:string"/>
+ <wsdl:part name="from" element="tns:from"/>
<wsdl:part name="articleId" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="ArticleMessage">
@@ -96,6 +98,7 @@
<http:urlReplacement/>
<!-- a part mapped to a non-standard header -->
<odex:header name="TimestampHeader" part="timestamp"/>
+ <odex:header name="From" part="from"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="article"/>
Modified: ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/Blog.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/Blog.wsdl?rev=676148&r1=676147&r2=676148&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/Blog.wsdl (original)
+++ ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/Blog.wsdl Sat Jul 12 03:54:58 2008
@@ -25,6 +25,7 @@
<xsd:element name="article" type="tns:ArticleType"/>
<xsd:element name="comment" type="tns:CommentType"/>
<xsd:element name="fault" type="tns:FaultType"/>
+ <xsd:element name="from" type="xsd:string"/>
<xsd:complexType name="ArticleType">
<xsd:sequence>
<xsd:element name="id" type="xsd:string"/>
@@ -48,6 +49,7 @@
<wsdl:message name="IdMessage">
<wsdl:part name="timestamp" type="xsd:string"/>
+ <wsdl:part name="from" element="tns:from"/>
<wsdl:part name="articleId" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="ArticleMessage">
@@ -96,6 +98,7 @@
<http:urlReplacement/>
<!-- a part mapped to a non-standard header -->
<odex:header name="TimestampHeader" part="timestamp"/>
+ <odex:header name="From" part="from"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="article"/>
Modified: ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel?rev=676148&r1=676147&r2=676148&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel (original)
+++ ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_GET/http-binding-ext-GET.bpel Sat Jul 12 03:54:58 2008
@@ -23,6 +23,8 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://ode/bpel/unit-test.wsdl"
xmlns:dummy="http://ode/bpel/test/blog"
+ xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
+ xmlns:ext="http://ode.apache.org/activityRecovery"
queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
@@ -71,6 +73,10 @@
<to>$idMsg.timestamp</to>
</copy>
<copy>
+ <from>'alexis@test.com'</from>
+ <to>$idMsg.from</to>
+ </copy>
+ <copy>
<!-- generate a random number -->
<from>string(round(seconds-from-dateTime(current-dateTime()))+100)</from>
<to>$articleId</to>
@@ -97,6 +103,19 @@
</assign>
</else>
</if>
+
+<!-- <if>
+ <condition>fn:contains($articleMsg.from,'alexis@test.com')</condition>
+ <empty/>
+ <else>
+ <assign>
+ <copy>
+ <from>'Wrong From Header received. Check if the request header was properly set.'</from>
+ <to>$outputVar.TestPart</to>
+ </copy>
+ </assign>
+ </else>
+ </if>-->
<if>
<condition>$articleMsg.article/dummy:id = $articleId</condition>
<empty/>
@@ -110,7 +129,9 @@
</else>
</if>
+ <!-- ##################################################### -->
<!-- Check HTTP StatusLine information -->
+ <!-- ##################################################### -->
<!-- Every message must have a Status-Line element in headers -->
<assign>
<copy>
@@ -167,6 +188,158 @@
</else>
</if>
+
+ <!-- ############################################### -->
+ <!-- 200_malformed_body - failure expected -->
+ <!-- ############################################### -->
+ <scope>
+ <ext:failureHandling>
+ <ext:faultOnFailure>true</ext:faultOnFailure>
+ </ext:failureHandling>
+ <faultHandlers>
+ <catch faultName="ext:activityFailure">
+ <!-- expected result-->
+ <!--
+ Warning #1!! At this point what we know for sure is that a failure occured
+ but we don't know which failure exactly.
+ We would like to test if the the failure is really the one we triggered on purpose and not a TimeoutFailure for instance.
+ -->
+ <empty/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <assign>
+ <copy>
+ <from>'200_malformed_body'</from>
+ <to variable="idMsg" header="Fault-Type"/>
+ </copy>
+ </assign>
+ <invoke partnerLink="blogPartnerLink" portType="dummy:BlogPortType"
+ operation="doGET" inputVariable="idMsg" outputVariable="articleMsg"/>
+ <assign>
+ <copy>
+ <from>'200_malformed_body: A failure should have been thrown'</from>
+ <to>$outputVar.TestPart</to>
+ </copy>
+ </assign>
+ <reply name="end" partnerLink="helloPartnerLink" portType="test:HelloPortType"
+ operation="hello" variable="outputVar"/>
+ </sequence>
+ </scope>
+
+ <!-- ############################################### -->
+ <!-- 200_missing_part_in_header - failure expected -->
+ <!-- ############################################### -->
+ <scope>
+ <ext:failureHandling>
+ <ext:faultOnFailure>true</ext:faultOnFailure>
+ </ext:failureHandling>
+ <faultHandlers>
+ <catch faultName="ext:activityFailure">
+ <!-- expected result-->
+ <!--
+ Warning #1!! At this point what we know for sure is that a failure occured
+ but we don't know which failure exactly.
+ We would like to test if the the failure is really the one we triggered on purpose and not a TimeoutFailure for instance.
+ -->
+ <empty/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <assign>
+ <copy>
+ <from>'200_missing_part_in_header'</from>
+ <to variable="idMsg" header="Fault-Type"/>
+ </copy>
+ </assign>
+ <invoke partnerLink="blogPartnerLink" portType="dummy:BlogPortType"
+ operation="doGET" inputVariable="idMsg" outputVariable="articleMsg"/>
+ <assign>
+ <copy>
+ <from>'200_missing_part_in_header: A failure should have been thrown'</from>
+ <to>$outputVar.TestPart</to>
+ </copy>
+ </assign>
+ <reply name="end" partnerLink="helloPartnerLink" portType="test:HelloPortType"
+ operation="hello" variable="outputVar"/>
+ </sequence>
+ </scope>
+
+ <!-- ############################################### -->
+ <!-- 400_not_found - failure expected -->
+ <!-- ############################################### -->
+ <scope>
+ <ext:failureHandling>
+ <ext:faultOnFailure>true</ext:faultOnFailure>
+ </ext:failureHandling>
+ <faultHandlers>
+ <catch faultName="ext:activityFailure">
+ <!-- expected result-->
+ <!--
+ Warning #1!! At this point what we know for sure is that a failure occured
+ but we don't know which failure exactly.
+ We would like to test if the the failure is really the one we triggered on purpose and not a TimeoutFailure for instance.
+ -->
+ <empty/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <assign>
+ <copy>
+ <from>'400_not_found'</from>
+ <to variable="idMsg" header="Fault-Type"/>
+ </copy>
+ </assign>
+ <invoke partnerLink="blogPartnerLink" portType="dummy:BlogPortType"
+ operation="doGET" inputVariable="idMsg" outputVariable="articleMsg"/>
+ <assign>
+ <copy>
+ <from>'400_not_found: A failure should have been thrown'</from>
+ <to>$outputVar.TestPart</to>
+ </copy>
+ </assign>
+ <reply name="end" partnerLink="helloPartnerLink" portType="test:HelloPortType"
+ operation="hello" variable="outputVar"/>
+ </sequence>
+ </scope>
+
+ <!-- ############################################### -->
+ <!-- 500_operation_with_no_fault_failed - failure expected -->
+ <!-- ############################################### -->
+ <scope>
+ <ext:failureHandling>
+ <ext:faultOnFailure>true</ext:faultOnFailure>
+ </ext:failureHandling>
+ <faultHandlers>
+ <catch faultName="ext:activityFailure">
+ <!-- expected result-->
+ <!--
+ Warning #1!! At this point what we know for sure is that a failure occured
+ but we don't know which failure exactly.
+ We would like to test if the the failure is really the one we triggered on purpose and not a TimeoutFailure for instance.
+ -->
+ <empty/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <assign>
+ <copy>
+ <from>'500_operation_with_no_fault_failed'</from>
+ <to variable="idMsg" header="Fault-Type"/>
+ </copy>
+ </assign>
+ <invoke partnerLink="blogPartnerLink" portType="dummy:BlogPortType"
+ operation="doGET" inputVariable="idMsg" outputVariable="articleMsg"/>
+ <assign>
+ <copy>
+ <from>'500_operation_with_no_fault_failed: A failure should have been thrown'</from>
+ <to>$outputVar.TestPart</to>
+ </copy>
+ </assign>
+ <reply name="end" partnerLink="helloPartnerLink" portType="test:HelloPortType"
+ operation="hello" variable="outputVar"/>
+ </sequence>
+ </scope>
<reply name="end" partnerLink="helloPartnerLink" portType="test:HelloPortType"
operation="hello" variable="outputVar"/>
</sequence>
Modified: ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_POST/Blog.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_POST/Blog.wsdl?rev=676148&r1=676147&r2=676148&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_POST/Blog.wsdl (original)
+++ ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_POST/Blog.wsdl Sat Jul 12 03:54:58 2008
@@ -25,6 +25,7 @@
<xsd:element name="article" type="tns:ArticleType"/>
<xsd:element name="comment" type="tns:CommentType"/>
<xsd:element name="fault" type="tns:FaultType"/>
+ <xsd:element name="from" type="xsd:string"/>
<xsd:complexType name="ArticleType">
<xsd:sequence>
<xsd:element name="id" type="xsd:string"/>
@@ -48,6 +49,7 @@
<wsdl:message name="IdMessage">
<wsdl:part name="timestamp" type="xsd:string"/>
+ <wsdl:part name="from" element="tns:from"/>
<wsdl:part name="articleId" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="ArticleMessage">
@@ -96,6 +98,7 @@
<http:urlReplacement/>
<!-- a part mapped to a non-standard header -->
<odex:header name="TimestampHeader" part="timestamp"/>
+ <odex:header name="From" part="from"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="article"/>
Modified: ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/Blog.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/Blog.wsdl?rev=676148&r1=676147&r2=676148&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/Blog.wsdl (original)
+++ ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/Blog.wsdl Sat Jul 12 03:54:58 2008
@@ -25,6 +25,7 @@
<xsd:element name="article" type="tns:ArticleType"/>
<xsd:element name="comment" type="tns:CommentType"/>
<xsd:element name="fault" type="tns:FaultType"/>
+ <xsd:element name="from" type="xsd:string"/>
<xsd:complexType name="ArticleType">
<xsd:sequence>
<xsd:element name="id" type="xsd:string"/>
@@ -48,6 +49,7 @@
<wsdl:message name="IdMessage">
<wsdl:part name="timestamp" type="xsd:string"/>
+ <wsdl:part name="from" element="tns:from"/>
<wsdl:part name="articleId" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="ArticleMessage">
@@ -96,6 +98,7 @@
<http:urlReplacement/>
<!-- a part mapped to a non-standard header -->
<odex:header name="TimestampHeader" part="timestamp"/>
+ <odex:header name="From" part="from"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="article"/>
Modified: ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/http-binding-ext-PUT.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/http-binding-ext-PUT.bpel?rev=676148&r1=676147&r2=676148&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/http-binding-ext-PUT.bpel (original)
+++ ode/trunk/axis2-war/src/test/resources/TestHttpBindingExt_PUT/http-binding-ext-PUT.bpel Sat Jul 12 03:54:58 2008
@@ -208,6 +208,45 @@
</scope>
<!-- ############################################### -->
+ <!-- 500_malformed_xml_body - failure expected -->
+ <!-- ############################################### -->
+ <scope>
+ <ext:failureHandling>
+ <ext:faultOnFailure>true</ext:faultOnFailure>
+ </ext:failureHandling>
+ <faultHandlers>
+ <catch faultName="ext:activityFailure">
+ <!-- expected result-->
+ <!--
+ Warning #1!! At this point what we know for sure is that a failure occured
+ but we don't know which failure exactly.
+ We would like to test if the the failure is really the one we triggered on purpose and not a TimeoutFailure for instance.
+ -->
+ <empty/>
+ </catch>
+ </faultHandlers>
+ <sequence>
+ <assign>
+ <copy>
+ <from>'500_malformed_xml_body'</from>
+ <to variable="putMsg" header="Fault-Type"/>
+ </copy>
+ </assign>
+ <invoke partnerLink="blogPartnerLink" portType="dummy:BlogPortType"
+ operation="doPUT" inputVariable="putMsg" outputVariable="noPartMsg">
+ </invoke>
+ <assign>
+ <copy>
+ <from>'500_not-well-formed_xml_body: A failure should have been thrown'</from>
+ <to>$outputVar.TestPart</to>
+ </copy>
+ </assign>
+ <reply name="end" partnerLink="helloPartnerLink" portType="test:HelloPortType"
+ operation="hello" variable="outputVar"/>
+ </sequence>
+ </scope>
+
+ <!-- ############################################### -->
<!-- 500_expected_xml_body - Fault expected -->
<!-- ############################################### -->
<scope>