cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r552449 - in /incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing: HeaderVerifier.java MAPTestBase.java Server.java
Date Mon, 02 Jul 2007 09:51:34 GMT
Author: eglynn
Date: Mon Jul  2 02:51:33 2007
New Revision: 552449

URL: http://svn.apache.org/viewvc?view=rev&rev=552449
Log:
Extended MAPTest with reference parameters.

Modified:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTestBase.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java?view=diff&rev=552449&r1=552448&r2=552449
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java
Mon Jul  2 02:51:33 2007
@@ -87,7 +87,6 @@
     private void addPartialResponseHeader(SoapMessage message) {
         try {
             // add piggybacked wsa:From header to partial response
-//            Element header = message.getHeaders(Element.class);
             List<Header> header = message.getHeaders();
             Document doc = DOMUtils.createDocument();
             SoapVersion ver = message.getVersion();
@@ -125,11 +124,15 @@
                 recordWSAHeaders(headers,
                                  wsaHeaders,
                                  VersionTransformer.Names200408.WSA_NAMESPACE_NAME);
+                recordWSAHeaders(headers,
+                                 wsaHeaders,
+                                 MAPTestBase.CUSTOMER_NAME.getNamespaceURI());
             }
             boolean partialResponse = isIncomingPartialResponse(message)
                                       || outgoingPartialResponse;
             verificationCache.put(MAPTest.verifyHeaders(wsaHeaders, 
-                                                        partialResponse));
+                                                        partialResponse,
+                                                        isRequestLeg(message)));
         } catch (SOAPException se) {
             verificationCache.put("SOAP header verification failed: " + se);
         }
@@ -144,22 +147,24 @@
             if (obj instanceof Element) {
                 Element hdr = (Element) obj;
                 if (namespaceURI.equals(hdr.getNamespaceURI())) {
-                    currentNamespaceURI = namespaceURI;
-                    wsaHeaders.add(hdr.getLocalName());
+                    if (namespaceURI.endsWith("addressing")) {
+                        currentNamespaceURI = namespaceURI;
+                        wsaHeaders.add(hdr.getLocalName());
+                    } else if (MAPTestBase.CUSTOMER_NAME.getNamespaceURI().equals(namespaceURI))
{
+                        String headerText = hdr.getTextContent();
+                        if (MAPTestBase.CUSTOMER_KEY.equals(headerText)) {
+                            wsaHeaders.add(hdr.getLocalName());
+                        }
+                    }
                 }
             }
             
         }
-    
-//        NodeList headerElements =
-//            headers.getElementsByTagNameNS(namespaceURI, "*");
-//        for (int i = 0; i < headerElements.getLength(); i++) {
-//            Node headerElement = headerElements.item(i);
-//            if (namespaceURI.equals(headerElement.getNamespaceURI())) {
-//                currentNamespaceURI = namespaceURI;
-//                wsaHeaders.add(headerElement.getLocalName());
-//            }
-//        }
+    }
+
+    private boolean isRequestLeg(SoapMessage message) {
+        return (ContextUtils.isRequestor(message) && ContextUtils.isOutbound(message))
+               || (!ContextUtils.isRequestor(message) && !ContextUtils.isOutbound(message));
    
     }
 
     private boolean isOutgoingPartialResponse(SoapMessage message) {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTestBase.java?view=diff&rev=552449&r1=552448&r2=552449
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTestBase.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTestBase.java
Mon Jul  2 02:51:33 2007
@@ -26,6 +26,7 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.bind.JAXBElement;
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.ProtocolException;
@@ -34,12 +35,16 @@
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.ServiceImpl;
+import org.apache.cxf.jaxws.support.ServiceDelegateAccessor;
 import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.AddressingPropertiesImpl;
 import org.apache.cxf.ws.addressing.AttributedURIType;
 import org.apache.cxf.ws.addressing.ContextUtils;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.apache.cxf.ws.addressing.Names;
+import org.apache.cxf.ws.addressing.ReferenceParametersType;
 import org.apache.cxf.ws.addressing.soap.VersionTransformer;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
 import org.apache.hello_world_soap_http.BadRecordLitFault;
@@ -66,14 +71,15 @@
     static final String INBOUND_KEY = "inbound";
     static final String OUTBOUND_KEY = "outbound";
 
+    static final QName CUSTOMER_NAME =
+        new QName("http://example.org/customer", "CustomerKey", "customer");
+    static final String CUSTOMER_KEY = "Key#123456789";
 
     private static MAPVerifier mapVerifier;
     private static HeaderVerifier headerVerifier;
 
     private static final QName SERVICE_NAME = 
         new QName("http://apache.org/hello_world_soap_http", "SOAPServiceAddressing");
-    private static final QName PORT_NAME =
-        new QName("http://apache.org/hello_world_soap_http", "SoapPort");
     private static final String NOWHERE = "http://nowhere.nada.nothing.nought:5555";
     private static final String DECOUPLED = "http://localhost:9999/decoupled_endpoint";
     
@@ -133,9 +139,19 @@
         addInterceptors(staticBus.getOutFaultInterceptors(), interceptors);
         addInterceptors(staticBus.getInFaultInterceptors(), interceptors);
         
+        EndpointReferenceType target = 
+            EndpointReferenceUtils.getEndpointReference(Server.ADDRESS);
+        ReferenceParametersType params = 
+            ContextUtils.WSA_OBJECT_FACTORY.createReferenceParametersType();
+        JAXBElement<String> param =
+             new JAXBElement<String>(CUSTOMER_NAME, String.class, CUSTOMER_KEY);
+        params.getAny().add(param);
+        target.setReferenceParameters(params);
         URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
-        SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
-        greeter = (Greeter)service.getPort(PORT_NAME, Greeter.class);
+        ServiceImpl serviceImpl = 
+            ServiceDelegateAccessor.get(new SOAPService(wsdl, SERVICE_NAME));
+        greeter = serviceImpl.getPort(target, Greeter.class);
+
         mapVerifier.verificationCache = this;
         headerVerifier.verificationCache = this;
     }
@@ -300,6 +316,7 @@
             throw (Exception)ex.getCause();
         }
     }
+
     //--VerificationCache implementation
 
     public void put(String verification) {
@@ -364,7 +381,9 @@
      * @param parial true if partial response
      * @return null if all expected headers present, otherwise an error string.
      */
-    protected static String verifyHeaders(List<String> wsaHeaders, boolean partial)
{
+    protected static String verifyHeaders(List<String> wsaHeaders,
+                                          boolean partial,
+                                          boolean requestLeg) {
         //System.out.println("verifying headers: " + wsaHeaders);
         String ret = null;
         if (!wsaHeaders.contains(Names.WSA_MESSAGEID_NAME)) {
@@ -387,6 +406,9 @@
             //if (!wsaHeaders.contains(Names.WSA_ACTION_NAME)) {
             //    ret = "expected Action header";
             //}            
+        }
+        if (requestLeg && !(wsaHeaders.contains(CUSTOMER_NAME.getLocalPart()))) {
+            ret = "expected CustomerKey header";
         }
         return ret;
     }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java?view=diff&rev=552449&r1=552448&r2=552449
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java
Mon Jul  2 02:51:33 2007
@@ -33,7 +33,8 @@
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 
 public class Server extends AbstractBusTestServerBase implements VerificationCache {
-    
+    static final String ADDRESS = "http://localhost:9008/SoapContext/SoapPort";
+
     private String verified;
  
     protected void run()  {
@@ -46,9 +47,8 @@
         addVerifiers();
 
         GreeterImpl implementor = new GreeterImpl();
-        implementor.verificationCache = this;         
-        String address = "http://localhost:9008/SoapContext/SoapPort";
-        Endpoint.publish(address, implementor);
+        implementor.verificationCache = this;
+        Endpoint.publish(ADDRESS, implementor);
     }
 
     protected void addVerifiers() {
@@ -99,6 +99,7 @@
      */
     protected boolean verify(Logger log) {
         if (verified != null) {
+            System.out.println("MAP/Header verification failed: " + verified);
             log.log(Level.WARNING, 
                     "MAP/Header verification failed: {0}",
                     verified);



Mime
View raw message