Author: heiko.braun(a)jboss.com
Date: 2007-05-29 10:57:26 -0400 (Tue, 29 May 2007)
New Revision: 3288
Modified:
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/DHResponse.java
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMProtocolHandler.java
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPBase.java
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.java
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPTestCase.java
Log:
Fix xop test cases
Modified:
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/DHResponse.java
===================================================================
---
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/DHResponse.java 2007-05-29
14:57:05 UTC (rev 3287)
+++
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/DHResponse.java 2007-05-29
14:57:26 UTC (rev 3288)
@@ -39,7 +39,7 @@
this.dataHandler = dataHandler;
}
- @XmlMimeType("image/jpeg")
+ @XmlMimeType("text/plain")
public DataHandler getDataHandler() {
return dataHandler;
}
Modified:
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java
===================================================================
---
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java 2007-05-29
14:57:05 UTC (rev 3287)
+++
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMEndpointBean.java 2007-05-29
14:57:26 UTC (rev 3288)
@@ -49,7 +49,8 @@
throw new WebServiceException(e);
}
- return new DHResponse(request.getDataHandler());
+ DataHandler responseData = new DataHandler("Server data",
"text/plain");
+ return new DHResponse(responseData);
}
public ImageResponse echoImage(ImageRequest request)
Modified:
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMProtocolHandler.java
===================================================================
---
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMProtocolHandler.java 2007-05-29
14:57:05 UTC (rev 3287)
+++
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/MTOMProtocolHandler.java 2007-05-29
14:57:26 UTC (rev 3288)
@@ -21,6 +21,12 @@
*/
package org.jboss.test.ws.jaxws.samples.xop.doclit;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.handler.GenericSOAPHandler;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
@@ -28,13 +34,10 @@
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPMessageContext;
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.handler.GenericSOAPHandler;
-import org.jboss.wsf.spi.utils.DOMWriter;
-
/**
* A MTOM handler should see the conceptual payload,
* which means an inlined representation of the binary data.
+ * It checks existence of the xop:Include element.
*/
public class MTOMProtocolHandler extends GenericSOAPHandler
{
@@ -42,22 +45,26 @@
protected boolean handleOutbound(MessageContext msgContext)
{
- return dumpMessage(msgContext);
+ return verifyXOPPackage(msgContext);
}
protected boolean handleInbound(MessageContext msgContext)
{
- return dumpMessage(msgContext);
+ return verifyXOPPackage(msgContext);
}
- private boolean dumpMessage(MessageContext context)
+ private boolean verifyXOPPackage(MessageContext context)
{
try
{
SOAPMessageContext msgContext = (SOAPMessageContext)context;
SOAPMessage soapMsg = msgContext.getMessage();
SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
- log.info(DOMWriter.printNode(soapEnv, true));
+ SOAPBody body = soapEnv.getBody();
+ boolean found = scanNodes(body.getChildNodes());
+
+ if(found) throw new IllegalStateException("XOP request not properly
inlined");
+
}
catch (SOAPException ex)
{
@@ -66,4 +73,24 @@
return true;
}
+
+ private boolean scanNodes(NodeList nodes)
+ {
+ boolean found = false;
+ for(int i = 0; i<nodes.getLength(); i++)
+ {
+ Node n = nodes.item(i);
+ if("Include".equals(n.getLocalName()))
+ {
+ found = true;
+ break;
+ }
+ else
+ {
+ found = scanNodes(n.getChildNodes());
+ }
+ }
+
+ return found;
+ }
}
\ No newline at end of file
Modified:
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPBase.java
===================================================================
---
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPBase.java 2007-05-29
14:57:05 UTC (rev 3287)
+++
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPBase.java 2007-05-29
14:57:26 UTC (rev 3288)
@@ -54,28 +54,20 @@
return binding;
}
- public void testDHRoundtrip() throws Exception
- {
- getBinding().setMTOMEnabled(true);
+ /**
+ * Marshalling/Unmarshalling of DataHandler types is different
+ * when handlers are in place.
+ * @throws Exception
+ */
+ public abstract void testDHRoundtrip() throws Exception;
- DataHandler dh = new DataHandler(imgFile.toURL());
- DHResponse response = getPort().echoDataHandler(new DHRequest(dh));
- assertNotNull(response);
- assertEquals("image/jpeg", response.getDataHandler().getContentType());
- assertTrue(response.getDataHandler().getContent() instanceof BufferedImage);
- }
+ /**
+ * Marshalling/Unmarshalling of DataHandler types is different
+ * when handlers are in place.
+ * @throws Exception
+ */
+ public abstract void testDHResponseOptimzed() throws Exception;
- public void testDHResponseOptimzed() throws Exception
- {
- getBinding().setMTOMEnabled(false);
-
- DataHandler dh = new DataHandler(imgFile.toURL());
- DHResponse response = getPort().echoDataHandler(new DHRequest(dh));
- assertNotNull(response);
- assertEquals("application/octet-stream",
response.getDataHandler().getContentType());
- assertTrue("Wrong java type returned",
response.getDataHandler().getContent() instanceof InputStream);
- }
-
public void testImgRoundtrip() throws Exception
{
getBinding().setMTOMEnabled(true);
Modified:
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.java
===================================================================
---
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.java 2007-05-29
14:57:05 UTC (rev 3287)
+++
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.java 2007-05-29
14:57:26 UTC (rev 3288)
@@ -21,21 +21,22 @@
*/
package org.jboss.test.ws.jaxws.samples.xop.doclit;
-// $Id: $
+// $Revision: $
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
+import junit.framework.Test;
+import org.jboss.test.ws.JBossWSTestSetup;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.soap.SOAPBinding;
+import javax.activation.DataHandler;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.io.InputStream;
-import junit.framework.Test;
-
-import org.jboss.test.ws.JBossWSTestSetup;
-
/**
* Test service endpoint capability to process inlined and optimized
* requests transparently. Both client and service endpoint do have handlers in place.
@@ -51,7 +52,7 @@
*/
public class XOPHandlerTestCase extends XOPBase
{
- public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-samples-xop-doclit/MTOMService";
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-samples-xop-doclit/bare";
public static Test suite()
{
@@ -64,7 +65,7 @@
QName serviceName = new
QName("http://doclit.xop.samples.jaxws.ws.test.jboss.org/",
"MTOMService");
URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
- javax.xml.ws.Service service = javax.xml.ws.Service.create(wsdlURL, serviceName);
+ Service service = Service.create(wsdlURL, serviceName);
port = service.getPort(MTOMEndpoint.class);
// enable MTOM
@@ -76,4 +77,34 @@
handlerChain.add(new MTOMProtocolHandler());
binding.setHandlerChain(handlerChain);
}
+
+ /**
+ * Consumption of inlined data should will always result on
'application/octet-stream'
+ * @throws Exception
+ */
+ public void testDHRoundtrip() throws Exception
+ {
+ getBinding().setMTOMEnabled(true);
+
+ DataHandler dh = new DataHandler("Client Data", "text/plain");
+ DHResponse response = getPort().echoDataHandler(new DHRequest(dh));
+ assertNotNull(response);
+ assertEquals("application/octet-stream",
response.getDataHandler().getContentType());
+ assertTrue("Wrong java type returned",
response.getDataHandler().getContent() instanceof InputStream);
+ }
+
+ /**
+ * Consumption of inlined data should will always result on
'application/octet-stream'
+ * @throws Exception
+ */
+ public void testDHResponseOptimzed() throws Exception
+ {
+ getBinding().setMTOMEnabled(false);
+
+ DataHandler dh = new DataHandler("Client data", "text/plain");
+ DHResponse response = getPort().echoDataHandler(new DHRequest(dh));
+ assertNotNull(response);
+ assertEquals("application/octet-stream",
response.getDataHandler().getContentType());
+ assertTrue("Wrong java type returned",
response.getDataHandler().getContent() instanceof InputStream);
+ }
}
\ No newline at end of file
Modified:
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPTestCase.java
===================================================================
---
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPTestCase.java 2007-05-29
14:57:05 UTC (rev 3287)
+++
trunk/testsuite/src/java/org/jboss/test/ws/jaxws/samples/xop/doclit/XOPTestCase.java 2007-05-29
14:57:26 UTC (rev 3288)
@@ -22,11 +22,13 @@
package org.jboss.test.ws.jaxws.samples.xop.doclit;
import java.net.URL;
+import java.io.InputStream;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;
+import javax.activation.DataHandler;
import junit.framework.Test;
@@ -47,7 +49,7 @@
public class XOPTestCase extends XOPBase
{
- public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-samples-xop-doclit/MTOMService";
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-samples-xop-doclit/bare";
public static Test suite()
{
@@ -68,4 +70,34 @@
binding.setMTOMEnabled(true);
}
+
+ /**
+ * Consumption of XOP packages (not inlined) should reslve the correct java type.
+ * @throws Exception
+ */
+ public void testDHRoundtrip() throws Exception
+ {
+ getBinding().setMTOMEnabled(true);
+
+ DataHandler dh = new DataHandler("Client Data", "text/plain");
+ DHResponse response = getPort().echoDataHandler(new DHRequest(dh));
+ assertNotNull(response);
+ assertEquals("text/plain", response.getDataHandler().getContentType());
+ assertTrue("Server data".equals( response.getDataHandler().getContent()
));
+ }
+
+ /**
+ * Consumption of XOP packages (not inlined) should reslve the correct java type.
+ * @throws Exception
+ */
+ public void testDHResponseOptimzed() throws Exception
+ {
+ getBinding().setMTOMEnabled(false);
+
+ DataHandler dh = new DataHandler("Client data", "text/plain");
+ DHResponse response = getPort().echoDataHandler(new DHRequest(dh));
+ assertNotNull(response);
+ assertEquals("text/plain", response.getDataHandler().getContentType());
+ assertTrue("Server data".equals( response.getDataHandler().getContent()
));
+ }
}
\ No newline at end of file