cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r991923 - in /cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ testutils/src/main/java/org/apache/locat...
Date Thu, 02 Sep 2010 13:00:11 GMT
Author: sergeyb
Date: Thu Sep  2 13:00:10 2010
New Revision: 991923

URL: http://svn.apache.org/viewvc?rev=991923&view=rev
Log:
Updating ProviderImpl to have wsdlLocation attribute contain a pair of values by default

Added:
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProviderImplTest.java
  (with props)
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorServiceImpl.java
  (with props)
Removed:
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProverImplTest.java
    cxf/trunk/testutils/src/main/java/org/apache/locator_test/LocatorServiceImpl.java
Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorClientServerTest.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java?rev=991923&r1=991922&r2=991923&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java Thu
Sep  2 13:00:10 2010
@@ -49,6 +49,8 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.jaxws.EndpointUtils;
 import org.apache.cxf.jaxws.ServiceImpl;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 import org.apache.cxf.ws.addressing.JAXWSAConstants;
@@ -62,7 +64,7 @@ public class ProviderImpl extends javax.
     static {
         boolean b = false;
         try {
-            //JAX-WS 2.2 would have the HttpContext class in the classloader
+            //JAX-WS 2.2 would have the HttpCoPhaseInterceptorChainntext class in the classloader
             Class<?> cls = ClassLoaderUtils.loadClass("javax.xml.ws.spi.http.HttpContext",

                                                       ProviderImpl.class);
             //In addition to that, the Endpoint class we pick up on the classloader
@@ -215,12 +217,21 @@ public class ProviderImpl extends javax.
             writer.writeNamespace(JAXWSAConstants.WSAW_PREFIX, JAXWSAConstants.NS_WSAW);
             writer.writeNamespace(JAXWSAConstants.WSAM_PREFIX, JAXWSAConstants.NS_WSAM);
             if (wsdlDocumentLocation != null) {
+                boolean includeLocationOnly = false;
+                org.apache.cxf.message.Message message = PhaseInterceptorChain.getCurrentMessage();
+                if (message != null) {
+                    includeLocationOnly = MessageUtils.isTrue(
+                        message.getContextualProperty("org.apache.cxf.wsa.metadata.wsdlLocationOnly"));
+                }
+                String attrubuteValue = serviceName != null && !includeLocationOnly

+                        ? serviceName.getNamespaceURI() + " " + wsdlDocumentLocation
+                        : wsdlDocumentLocation;
                 writer.writeNamespace(JAXWSAConstants.WSDLI_PFX,
                                       JAXWSAConstants.NS_WSDLI);
                 writer.writeAttribute(JAXWSAConstants.WSDLI_PFX,
                                       JAXWSAConstants.NS_WSDLI,
                                       JAXWSAConstants.WSDLI_WSDLLOCATION,
-                                      wsdlDocumentLocation);
+                                      attrubuteValue);
             }
             if (interfaceName != null) {
                 writer.writeStartElement(JAXWSAConstants.WSAM_PREFIX,

Added: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProviderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProviderImplTest.java?rev=991923&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProviderImplTest.java
(added)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProviderImplTest.java
Thu Sep  2 13:00:10 2010
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxws.spi;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.apache.cxf.BusFactory;
+import org.junit.After;
+
+
+public class ProviderImplTest extends org.junit.Assert {
+    @org.junit.Test
+    public void testCreateW3CEpr() throws Exception {
+        QName serviceName = new QName("http://cxf.apache.org", "ServiceName");
+        QName portName = new QName("http://cxf.apache.org", "PortName");
+        ProviderImpl impl = new ProviderImpl();
+        W3CEndpointReference w3Epr = impl.createW3CEndpointReference("http://myaddress",
serviceName,
+                                                                      portName, null, "wsdlLoc",
+                                                                      null);
+        
+        java.io.StringWriter sw = new java.io.StringWriter();
+        StreamResult result = new StreamResult(sw);
+        w3Epr.writeTo(result);
+        String expected = "<wsdl:definitions"; 
+        assertTrue("Embeded wsdl element is not generated", sw.toString().indexOf(expected)
> -1);
+        assertTrue("wsdlLocation attribute has the wrong value", 
+                   sw.toString().contains("wsdli:wsdlLocation=\"http://cxf.apache.org wsdlLoc\""));
+        System.out.println(sw.toString());
+
+    }
+    @After
+    public void tearDown() {
+        BusFactory.setDefaultBus(null);
+    }
+    
+    
+
+}

Propchange: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProviderImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spi/ProviderImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorClientServerTest.java?rev=991923&r1=991922&r2=991923&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorClientServerTest.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorClientServerTest.java
Thu Sep  2 13:00:10 2010
@@ -34,7 +34,7 @@ import org.apache.cxf.testutil.common.Ab
 import org.apache.locator.LocatorService;
 import org.apache.locator.LocatorService_Service;
 import org.apache.locator.types.QueryEndpoints;
-import org.apache.locator_test.LocatorServiceImpl;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -103,6 +103,34 @@ public class LocatorClientServerTest ext
         port.queryEndpoints(new QueryEndpoints());
 
     }
+    
+    @Test
+    public void testLookupEndpointAndVerifyWsdlLocationAndNamespace() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/locator.wsdl");
+        assertNotNull(wsdl);
+
+        LocatorService_Service ss = new LocatorService_Service(wsdl, serviceName);
+        LocatorService port = ss.getLocatorServicePort();
+        updateAddressPort(port, PORT);
+        
+        W3CEndpointReference epr = port.lookupEndpoint(new QName("http://service/1", "Number"));
+        String eprString = epr.toString();
+        assertTrue(eprString.contains("Metadata wsdli:wsdlLocation=\"http://service/1 wsdlLoc\""));
+    }
+    
+    @Test
+    public void testLookupEndpointAndVerifyWsdlLocationOnly() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/locator.wsdl");
+        assertNotNull(wsdl);
+
+        LocatorService_Service ss = new LocatorService_Service(wsdl, serviceName);
+        LocatorService port = ss.getLocatorServicePort();
+        updateAddressPort(port, PORT);
+        
+        W3CEndpointReference epr = port.lookupEndpoint(new QName("http://service/2", "Number"));
+        String eprString = epr.toString();
+        assertTrue(eprString.contains("Metadata wsdli:wsdlLocation=\"wsdlLoc\""));
+    }
 
     @Test
     public void testIllegalState() throws Exception {

Added: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorServiceImpl.java?rev=991923&view=auto
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorServiceImpl.java
(added)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorServiceImpl.java
Thu Sep  2 13:00:10 2010
@@ -0,0 +1,113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Please modify this class to meet your needs
+ * This class is not complete
+ */
+
+package org.apache.cxf.systest.jaxws;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.locator.EndpointNotExistFault;
+import org.apache.locator.LocatorService;
+import org.apache.locator.types.EndpointIdentity;
+import org.apache.locator.types.ListEndpointsResponse.Endpoint;
+import org.apache.locator.types.QueryEndpoints;
+import org.apache.locator.types.QueryEndpointsResponse;
+
+
+/**
+ * 
+ */
+
+@javax.jws.WebService(name = "LocatorService",  
+                      serviceName = "LocatorService", 
+                      portName = "LocatorServicePort", 
+                      targetNamespace = "http://apache.org/locator", 
+                      endpointInterface = "org.apache.locator.LocatorService",
+                      wsdlLocation = "testutils/locator.wsdl")
+public class LocatorServiceImpl implements LocatorService {
+
+    static final Logger LOG = LogUtils.getL7dLogger(LocatorServiceImpl.class);
+
+    public void registerPeerManager(
+                                    javax.xml.ws.wsaddressing.W3CEndpointReference peerManager,
+                                    javax.xml.ws.Holder<
+                                    javax.xml.ws.wsaddressing.W3CEndpointReference> 
+                                            peerManagerReference,
+                                    javax.xml.ws.Holder<java.lang.String> nodeId) {
+        LOG.info("Executing operation registerPeerManager");
+    }
+
+    public void deregisterPeerManager(java.lang.String nodeId) {
+        LOG.info("Executing operation deregisterPeerManager");
+    }
+
+    public void registerEndpoint(EndpointIdentity endpointId,
+                                 javax.xml.ws.wsaddressing.W3CEndpointReference endpointReference)
{
+        LOG.info("Executing operation registerEndpoint");
+    }
+
+    public void deregisterEndpoint(EndpointIdentity endpointId,
+                                   javax.xml.ws.wsaddressing.W3CEndpointReference endpointReference)
{
+        LOG.info("Executing operation deregisterEndpoint");
+    }
+
+    public javax.xml.ws.wsaddressing.W3CEndpointReference lookupEndpoint(
+        javax.xml.namespace.QName serviceQname)
+        throws EndpointNotExistFault {
+        LOG.info("Executing operation lookupEndpoint");
+        W3CEndpointReferenceBuilder eprBuilder = new  W3CEndpointReferenceBuilder();
+        eprBuilder.address("http://bar");
+        eprBuilder.serviceName(serviceQname);
+        eprBuilder.wsdlDocumentLocation("wsdlLoc");
+        
+        // just in case, for backward compatibility, the builder may be asked to
+        // create a wsdlLocation attribute with a location only
+        if (serviceQname.getNamespaceURI().endsWith("2")) {
+            Message m = PhaseInterceptorChain.getCurrentMessage();
+            m.setContextualProperty("org.apache.cxf.wsa.metadata.wsdlLocationOnly", "true");
+        }
+        
+        return eprBuilder.build();
+    }
+
+    
+    public List<Endpoint> listEndpoints() {
+        LOG.info("Executing operation listEndpoints");
+        return new ArrayList<Endpoint>();
+    }
+
+    
+    
+    public QueryEndpointsResponse queryEndpoints(QueryEndpoints parameters) {
+        LOG.info("Executing operation queryEndpoints");
+        return null;
+    }
+
+}

Propchange: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/LocatorServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message