Author: darran.lofthouse(a)jboss.com
Date: 2008-08-19 14:16:36 -0400 (Tue, 19 Aug 2008)
New Revision: 8122
Removed:
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/resources/jaxws/samples/context/WEB-INF/wsdl/
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointEJB.java
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointJSE.java
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/TestEndpoint.java
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextEJBTestCase.java
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java
Log:
[JBPAPP-1089] Implement standard message context properties.
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointEJB.java
===================================================================
---
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointEJB.java 2008-08-19
18:16:23 UTC (rev 8121)
+++
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointEJB.java 2008-08-19
18:16:36 UTC (rev 8122)
@@ -23,6 +23,7 @@
// $Id$
+import java.io.IOException;
import java.security.Principal;
import javax.annotation.Resource;
@@ -32,10 +33,16 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
+import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.MessageContext;
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.spi.annotation.WebContext;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
@WebService(name = "TestEndpoint", serviceName="TestEndpointService",
targetNamespace = "http://org.jboss.ws/jaxws/context")
@SOAPBinding(style = Style.RPC)
@@ -54,11 +61,47 @@
@WebMethod
public String testGetMessageContext()
{
- MessageContext jaxwsContext = (MessageContext)wsCtx.getMessageContext();
- return jaxwsContext != null ? "pass" : "fail";
+ MessageContext msgContext = (MessageContext)wsCtx.getMessageContext();
+ return msgContext == null ? "fail" : "pass";
}
@WebMethod
+ public String testMessageContextProperties()
+ {
+ MessageContext msgContext = (MessageContext)wsCtx.getMessageContext();
+ if (msgContext == null)
+ return "fail";
+
+ // Check standard jaxws properties
+ InputSource wsdlSource =
(InputSource)msgContext.get(MessageContext.WSDL_DESCRIPTION);
+ QName service = (QName)msgContext.get(MessageContext.WSDL_SERVICE);
+ QName portType = (QName)msgContext.get(MessageContext.WSDL_INTERFACE);
+ QName port = (QName)msgContext.get(MessageContext.WSDL_PORT);
+ QName operation = (QName)msgContext.get(MessageContext.WSDL_OPERATION);
+
+ if (!service.equals(new QName("http://org.jboss.ws/jaxws/context",
"TestEndpointService")))
+ throw new WebServiceException("Invalid qname: " + service);
+ if (!portType.equals(new QName("http://org.jboss.ws/jaxws/context",
"TestEndpoint")))
+ throw new WebServiceException("Invalid qname: " + portType);
+ if (!port.equals(new QName("http://org.jboss.ws/jaxws/context",
"TestEndpointPort")))
+ throw new WebServiceException("Invalid qname: " + port);
+ if (!operation.equals(new QName("http://org.jboss.ws/jaxws/context",
"testMessageContextProperties")))
+ throw new WebServiceException("Invalid qname: " + operation);
+
+ try
+ {
+ Element root = DOMUtils.parse(wsdlSource);
+ new DOMWriter(System.out).setPrettyprint(true).print(root);
+ }
+ catch (IOException ex)
+ {
+ throw new WebServiceException("Cannot parse
MessageContext.WSDL_DESCRIPTION", ex);
+ }
+
+ return "pass";
+ }
+
+ @WebMethod
public String testGetUserPrincipal()
{
Principal principal = wsCtx.getUserPrincipal();
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointJSE.java
===================================================================
---
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointJSE.java 2008-08-19
18:16:23 UTC (rev 8121)
+++
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointJSE.java 2008-08-19
18:16:36 UTC (rev 8122)
@@ -23,6 +23,7 @@
// $Id: $
+import java.io.IOException;
import java.security.Principal;
import javax.annotation.Resource;
@@ -30,10 +31,17 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
+import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.MessageContext;
-@WebService(name = "TestEndpoint", serviceName =
"TestEndpointService", targetNamespace =
"http://org.jboss.ws/jaxws/context")
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.common.DOMWriter;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+@WebService(name = "Endpoint", serviceName = "EndpointService",
targetNamespace = "http://org.jboss.ws/jaxws/context")
@SOAPBinding(style = Style.RPC)
public class EndpointJSE
{
@@ -43,11 +51,47 @@
@WebMethod
public String testGetMessageContext()
{
- MessageContext jaxwsContext = (MessageContext)wsCtx.getMessageContext();
- return jaxwsContext != null ? "pass" : "fail";
+ MessageContext msgContext = (MessageContext)wsCtx.getMessageContext();
+ return msgContext == null ? "fail" : "pass";
}
@WebMethod
+ public String testMessageContextProperties()
+ {
+ MessageContext msgContext = (MessageContext)wsCtx.getMessageContext();
+ if (msgContext == null)
+ return "fail";
+
+ // Check standard jaxws properties
+ InputSource wsdlSource =
(InputSource)msgContext.get(MessageContext.WSDL_DESCRIPTION);
+ QName service = (QName)msgContext.get(MessageContext.WSDL_SERVICE);
+ QName portType = (QName)msgContext.get(MessageContext.WSDL_INTERFACE);
+ QName port = (QName)msgContext.get(MessageContext.WSDL_PORT);
+ QName operation = (QName)msgContext.get(MessageContext.WSDL_OPERATION);
+
+ if (!service.equals(new QName("http://org.jboss.ws/jaxws/context",
"EndpointService")))
+ throw new WebServiceException("Invalid qname: " + service);
+ if (!portType.equals(new QName("http://org.jboss.ws/jaxws/context",
"Endpoint")))
+ throw new WebServiceException("Invalid qname: " + portType);
+ if (!port.equals(new QName("http://org.jboss.ws/jaxws/context",
"EndpointPort")))
+ throw new WebServiceException("Invalid qname: " + port);
+ if (!operation.equals(new QName("http://org.jboss.ws/jaxws/context",
"testMessageContextProperties")))
+ throw new WebServiceException("Invalid qname: " + operation);
+
+ try
+ {
+ Element root = DOMUtils.parse(wsdlSource);
+ new DOMWriter(System.out).setPrettyprint(true).print(root);
+ }
+ catch (IOException ex)
+ {
+ throw new WebServiceException("Cannot parse
MessageContext.WSDL_DESCRIPTION", ex);
+ }
+
+ return "pass";
+ }
+
+ @WebMethod
public String testGetUserPrincipal()
{
Principal principal = wsCtx.getUserPrincipal();
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/TestEndpoint.java
===================================================================
---
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/TestEndpoint.java 2008-08-19
18:16:23 UTC (rev 8121)
+++
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/TestEndpoint.java 2008-08-19
18:16:36 UTC (rev 8122)
@@ -29,6 +29,10 @@
@WebResult(targetNamespace = "http://org.jboss.ws/jaxws/context", partName
= "return")
public String testGetMessageContext();
+ @WebMethod
+ @WebResult(targetNamespace = "http://org.jboss.ws/jaxws/context", partName
= "return")
+ public String testMessageContextProperties();
+
/**
*
* @return
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextEJBTestCase.java
===================================================================
---
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextEJBTestCase.java 2008-08-19
18:16:23 UTC (rev 8121)
+++
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextEJBTestCase.java 2008-08-19
18:16:36 UTC (rev 8122)
@@ -54,8 +54,9 @@
{
if (port == null)
{
- URL wsdlURL = new
File("resources/jaxws/samples/context/WEB-INF/wsdl/TestEndpoint.wsdl").toURL();
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-samples-context?wsdl");
QName qname = new QName("http://org.jboss.ws/jaxws/context",
"TestEndpointService");
+
Service service = Service.create(wsdlURL, qname);
port = (TestEndpoint)service.getPort(TestEndpoint.class);
@@ -71,6 +72,12 @@
assertEquals("pass", retStr);
}
+ public void testMessageContextProperties() throws Exception
+ {
+ String retStr = port.testMessageContextProperties();
+ assertEquals("pass", retStr);
+ }
+
public void testGetUserPrincipal() throws Exception
{
String retStr = port.testGetUserPrincipal();
Modified:
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java
===================================================================
---
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java 2008-08-19
18:16:23 UTC (rev 8121)
+++
framework/branches/jbossws-framework-2.0.1.GA_CP01_JBPAPP-1089/src/test/java/org/jboss/test/ws/jaxws/samples/context/WebServiceContextJSETestCase.java 2008-08-19
18:16:36 UTC (rev 8122)
@@ -54,8 +54,9 @@
{
if (port == null)
{
- URL wsdlURL = new
File("resources/jaxws/samples/context/WEB-INF/wsdl/TestEndpoint.wsdl").toURL();
- QName qname = new QName("http://org.jboss.ws/jaxws/context",
"TestEndpointService");
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-samples-context?wsdl");
+ QName qname = new QName("http://org.jboss.ws/jaxws/context",
"EndpointService");
+
Service service = Service.create(wsdlURL, qname);
port = (TestEndpoint)service.getPort(TestEndpoint.class);
@@ -71,6 +72,12 @@
assertEquals("pass", retStr);
}
+ public void testMessageContextProperties() throws Exception
+ {
+ String retStr = port.testMessageContextProperties();
+ assertEquals("pass", retStr);
+ }
+
public void testGetUserPrincipal() throws Exception
{
String retStr = port.testGetUserPrincipal();