You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/09/05 23:59:07 UTC

svn commit: r573082 - in /incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces: ./ NamespaceConfusionTest.java data/ data/Name.java impl/ impl/NameServiceImpl.java intf/ intf/NameService.java

Author: dkulp
Date: Wed Sep  5 14:59:07 2007
New Revision: 573082

URL: http://svn.apache.org/viewvc?rev=573082&view=rev
Log:
[CXF-959] Add testcase provided by Benson Margulies

Added:
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/data/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/data/Name.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/impl/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/impl/NameServiceImpl.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/intf/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/intf/NameService.java   (with props)

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java?rev=573082&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java Wed Sep  5 14:59:07 2007
@@ -0,0 +1,121 @@
+/**
+ * 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.aegis.namespaces;
+
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.namespaces.data.Name;
+import org.apache.cxf.aegis.namespaces.impl.NameServiceImpl;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.service.Service;
+
+import org.jaxen.JaxenException;
+import org.jaxen.NamespaceContext;
+import org.jaxen.SimpleNamespaceContext;
+import org.jaxen.dom.DOMXPath;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class NamespaceConfusionTest extends AbstractAegisTest {
+    
+    private TypeMapping tm;
+    private Service service;
+        
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        
+        Server s = createService(NameServiceImpl.class, null);
+        service = s.getEndpoint().getService();
+
+        tm = (TypeMapping)service.get(TypeMapping.class.getName());
+    }
+    
+    private String getNamespaceForPrefix(Element rootElement, 
+                                         NamespaceContext namespaceContext, 
+                                         Element typeElement, 
+                                         String prefix) throws JaxenException {
+        DOMXPath findSchema = new DOMXPath("ancestor::xsd:schema");
+        findSchema.setNamespaceContext(namespaceContext);
+        Element schemaElement = (Element)findSchema.selectSingleNode(typeElement);
+
+        NamedNodeMap attributes = schemaElement.getAttributes();
+        for (int x = 0; x < attributes.getLength(); x++) {
+            Attr attr = (Attr)attributes.item(x);
+            if (attr.getName().startsWith("xmlns:")) {
+                String attrPrefix = attr.getName().split(":")[1];
+                if (attrPrefix.equals(prefix)) {
+                    return attr.getValue();
+                }
+            }
+        }
+
+        attributes = rootElement.getAttributes();
+        for (int x = 0; x < attributes.getLength(); x++) {
+            Attr attr = (Attr)attributes.item(x);
+            if (attr.getName().startsWith("xmlns:")) {
+                String attrPrefix = attr.getName().split(":")[1];
+                if (attrPrefix.equals(prefix)) {
+                    return attr.getValue();
+                }
+            }
+        }
+
+        return null;
+    }
+    
+    
+    @Test
+    public void testNameNamespace() throws WSDLException, JaxenException {
+        org.w3c.dom.Document wsdlDoc = getWSDLDocument("NameServiceImpl");
+        Element rootElement = wsdlDoc.getDocumentElement();
+        
+        SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext();
+        namespaceContext.addNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
+        DOMXPath arrayOfNameFinder = 
+            new DOMXPath("//xsd:complexType[@name='ArrayOfName']/xsd:sequence/xsd:element");
+        arrayOfNameFinder.setNamespaceContext(namespaceContext);
+        
+        Element arrayOfNameElement = (Element)arrayOfNameFinder.selectSingleNode(rootElement);
+        assertNotNull(arrayOfNameElement);
+
+        String typename = arrayOfNameElement.getAttribute("type");
+        String prefix = typename.split(":")[0];
+
+        String uri = getNamespaceForPrefix(rootElement, namespaceContext, 
+                                           arrayOfNameElement, prefix);
+        assertNotNull(uri);
+        Type nameType = tm.getTypeCreator().createType(Name.class);
+        QName tmQname = nameType.getSchemaType();
+        assertEquals(tmQname.getNamespaceURI(), uri);
+    }
+    
+    
+    
+
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/NamespaceConfusionTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/data/Name.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/data/Name.java?rev=573082&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/data/Name.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/data/Name.java Wed Sep  5 14:59:07 2007
@@ -0,0 +1,47 @@
+/**
+ * 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.aegis.namespaces.data;
+
+public class Name {
+
+    String data;
+    String uid;
+    
+    Name() {
+        this.data = "";
+        this.uid = "";
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid;
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/data/Name.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/data/Name.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/impl/NameServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/impl/NameServiceImpl.java?rev=573082&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/impl/NameServiceImpl.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/impl/NameServiceImpl.java Wed Sep  5 14:59:07 2007
@@ -0,0 +1,37 @@
+/**
+ * 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.aegis.namespaces.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.jws.WebService;
+
+import org.apache.cxf.aegis.namespaces.data.Name;
+import org.apache.cxf.aegis.namespaces.intf.NameService;
+
+@WebService(serviceName = "NameService", 
+            endpointInterface = "org.apache.cxf.aegis.namespaces.intf.NameService", 
+            targetNamespace = "urn:org.apache.cxf.aegis.namespace")
+public class NameServiceImpl implements NameService {
+
+    public List<Name> listAvailableNames() {
+        return new ArrayList<Name>();
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/impl/NameServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/impl/NameServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/intf/NameService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/intf/NameService.java?rev=573082&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/intf/NameService.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/intf/NameService.java Wed Sep  5 14:59:07 2007
@@ -0,0 +1,33 @@
+/**
+ * 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.aegis.namespaces.intf;
+
+import java.util.List;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+import org.apache.cxf.aegis.namespaces.data.Name;
+
+@WebService(name = "NamespaceTest", targetNamespace = "urn:org.apache.cxf.aegis.namespace")
+public interface NameService {
+
+    @WebMethod
+    List<Name> listAvailableNames();
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/intf/NameService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/intf/NameService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Re: svn commit: r573082 - in/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces: ./ NamespaceConfusionTest.java data/ data/Name.java impl/impl/NameServiceImpl.java intf/ intf/NameService.java

Posted by Daniel Kulp <dk...@apache.org>.
Will do.   My next commit will have the comment.

Thanks!
Dan


On Wednesday 05 September 2007, Benson Margulies wrote:
> That's fair. Dan, instead of going through the jira-to-you-to-svn pass
> again, how about you add the following javadoc to the class ...
>
> /**
>   * Regression test for CXF-959. This is a point test for consistent
> use of
>   * namespace prefixes in generated WSDL/XMLSchema. This test could
>   * be made into a more comprehensive functional test by exercising
> cases
>   * such as multiple schema.
>   */
>
> > -----Original Message-----
> > From: Glen Mazza [mailto:glen.mazza@verizon.net]
> > Sent: Wednesday, September 05, 2007 6:20 PM
> > To: cxf-dev@incubator.apache.org
> > Subject: Re: svn commit: r573082 -
>
> in/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/c
>xf /a
>
> > egis/namespaces: ./ NamespaceConfusionTest.java data/ data/Name.java
> > impl/impl/NameServiceImpl.java intf/ intf/NameService.java
> >
> > Am Mittwoch, den 05.09.2007, 21:59 +0000 schrieb dkulp@apache.org:
> > > Author: dkulp
> > > Date: Wed Sep  5 14:59:07 2007
> > > New Revision: 573082
> > >
> > > URL: http://svn.apache.org/viewvc?rev=573082&view=rev
> > > Log:
> > > [CXF-959] Add testcase provided by Benson Margulies
> > >
> > > +
> > > +public class NamespaceConfusionTest extends AbstractAegisTest {
> > > +
> >
> > I think it would be nice to have a comment for this class explaining
> > what it does/what it is for.  By name alone, I don't think it is
> > sufficiently evident to the reader (at least not this one.)
> >
> > Glen



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

RE: svn commit: r573082 - in/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces: ./ NamespaceConfusionTest.java data/ data/Name.java impl/impl/NameServiceImpl.java intf/ intf/NameService.java

Posted by Benson Margulies <bi...@basistech.com>.
That's fair. Dan, instead of going through the jira-to-you-to-svn pass
again, how about you add the following javadoc to the class ...

/** 
  * Regression test for CXF-959. This is a point test for consistent use
of 
  * namespace prefixes in generated WSDL/XMLSchema. This test could 
  * be made into a more comprehensive functional test by exercising
cases 
  * such as multiple schema.
  */

> -----Original Message-----
> From: Glen Mazza [mailto:glen.mazza@verizon.net]
> Sent: Wednesday, September 05, 2007 6:20 PM
> To: cxf-dev@incubator.apache.org
> Subject: Re: svn commit: r573082 -
>
in/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf
/a
> egis/namespaces: ./ NamespaceConfusionTest.java data/ data/Name.java
> impl/impl/NameServiceImpl.java intf/ intf/NameService.java
> 
> Am Mittwoch, den 05.09.2007, 21:59 +0000 schrieb dkulp@apache.org:
> > Author: dkulp
> > Date: Wed Sep  5 14:59:07 2007
> > New Revision: 573082
> >
> > URL: http://svn.apache.org/viewvc?rev=573082&view=rev
> > Log:
> > [CXF-959] Add testcase provided by Benson Margulies
> >
> > +
> > +public class NamespaceConfusionTest extends AbstractAegisTest {
> > +
> 
> I think it would be nice to have a comment for this class explaining
> what it does/what it is for.  By name alone, I don't think it is
> sufficiently evident to the reader (at least not this one.)
> 
> Glen
> 


Re: svn commit: r573082 - in /incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces: ./ NamespaceConfusionTest.java data/ data/Name.java impl/ impl/NameServiceImpl.java intf/ intf/NameService.java

Posted by Glen Mazza <gl...@verizon.net>.
Am Mittwoch, den 05.09.2007, 21:59 +0000 schrieb dkulp@apache.org:
> Author: dkulp
> Date: Wed Sep  5 14:59:07 2007
> New Revision: 573082
> 
> URL: http://svn.apache.org/viewvc?rev=573082&view=rev
> Log:
> [CXF-959] Add testcase provided by Benson Margulies
> 
> +
> +public class NamespaceConfusionTest extends AbstractAegisTest {
> +    

I think it would be nice to have a comment for this class explaining
what it does/what it is for.  By name alone, I don't think it is
sufficiently evident to the reader (at least not this one.)

Glen