[jbossws-commits] JBossWS SVN: r3505 - branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/jbws1093.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Fri Jun 8 09:54:07 EDT 2007
Author: thomas.diesler at jboss.com
Date: 2007-06-08 09:54:07 -0400 (Fri, 08 Jun 2007)
New Revision: 3505
Modified:
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/jbws1093/JBWS1093TestCase.java
branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/jbws1093/ServletTest.java
Log:
Add test [JBWS-1706] SOAPConnection.get fails with ProtocolException
Modified: branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/jbws1093/JBWS1093TestCase.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/jbws1093/JBWS1093TestCase.java 2007-06-08 09:31:38 UTC (rev 3504)
+++ branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/jbws1093/JBWS1093TestCase.java 2007-06-08 13:54:07 UTC (rev 3505)
@@ -28,11 +28,16 @@
import javax.naming.InitialContext;
import javax.xml.rpc.Service;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPMessage;
import junit.framework.Test;
import org.jboss.wsf.spi.test.JBossWSTest;
import org.jboss.wsf.spi.test.JBossWSTestSetup;
+import org.jboss.wsf.spi.utils.DOMWriter;
/**
* Deploying a war that also contains normal servlets the web.xml is modified as if they are all endpoints
@@ -63,14 +68,14 @@
}
}
- public void testAccessEnpoint() throws Exception
+ public void testEnpointAccess() throws Exception
{
assertEquals(ServletTest.MESSAGE, port.echoString(ServletTest.MESSAGE));
}
- public void testAccessServlet() throws Exception
+ public void testServletAccess() throws Exception
{
- URL servletURL = new URL("http://" + getServerHost() + ":8080" + "/jaxrpc-jbws1093/ServletTest");
+ URL servletURL = new URL("http://" + getServerHost() + ":8080" + "/jaxrpc-jbws1093/ServletTest?type=txtMessage");
InputStream is = servletURL.openStream();
InputStreamReader isr = new InputStreamReader(is);
@@ -80,4 +85,27 @@
assertEquals(ServletTest.MESSAGE, line);
}
+
+ /**
+ * [JBWS-1706] SOAPConnection.get fails with ProtocolException
+ *
+ * Gets a SOAP response message from a specific endpoint
+ * and blocks until it has received the response. HTTP-GET
+ * from a valid endpoint that contains a valid webservice
+ * resource should succeed. The endpoint tested contains
+ * a valid webservice resource that must return a SOAP
+ * response. HTTP-GET must succeed.
+ *
+ */
+ public void testSOAPConnectionGet() throws Exception
+ {
+ URL servletURL = new URL("http://" + getServerHost() + ":8080" + "/jaxrpc-jbws1093/ServletTest?type=soapMessage");
+
+ SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
+ SOAPMessage resMessage = con.get(servletURL);
+ SOAPEnvelope env = resMessage.getSOAPPart().getEnvelope();
+
+ String envStr = DOMWriter.printNode(env, false);
+ System.out.println(envStr);
+ }
}
Modified: branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/jbws1093/ServletTest.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/jbws1093/ServletTest.java 2007-06-08 09:31:38 UTC (rev 3504)
+++ branches/jbossws-2.0/jbossws-core/src/test/java/org/jboss/test/ws/jaxrpc/jbws1093/ServletTest.java 2007-06-08 13:54:07 UTC (rev 3505)
@@ -22,12 +22,21 @@
package org.jboss.test.ws.jaxrpc.jbws1093;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
/**
* JBWS-1093 - This servlet is called ServletTest to check that we are
@@ -40,10 +49,44 @@
{
public static final String MESSAGE = "Success!!";
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
- PrintWriter writer = response.getWriter();
- writer.println(MESSAGE);
+ String reqType = req.getParameter("type");
+ if ("txtMessage".equals(reqType))
+ {
+ PrintWriter writer = res.getWriter();
+ writer.println(MESSAGE);
+ }
+ else if ("soapMessage".equals(reqType))
+ {
+ try
+ {
+ // Create a SOAPMessage
+ MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ SOAPMessage msg = msgFactory.createMessage();
+
+ SOAPPart sp = msg.getSOAPPart();
+
+ SOAPEnvelope env = sp.getEnvelope();
+
+ SOAPBody body = env.getBody();
+
+ Name elName = env.createName("GetLastTradePriceResponse", "ztrade", "http://wombat.ztrade.com");
+ body.addBodyElement(elName).addChildElement("Price").addTextNode("95.12");
+
+ msg.saveChanges();
+
+ res.setStatus(HttpServletResponse.SC_OK);
+
+ // Write out the message on the response stream.
+ OutputStream os = res.getOutputStream();
+ msg.writeTo(os);
+ os.flush();
+ }
+ catch (SOAPException e)
+ {
+ throw new ServletException(e);
+ }
+ }
}
-
}
More information about the jbossws-commits
mailing list