cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r559631 - in /incubator/cxf/trunk: rt/bindings/http/ rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/ rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type...
Date Wed, 25 Jul 2007 22:15:09 GMT
Author: dandiep
Date: Wed Jul 25 15:15:08 2007
New Revision: 559631

URL: http://svn.apache.org/viewvc?view=rev&rev=559631
Log:
CXF-785: Fix an NPE if a namespace prefix is invalid.

CXF-800: I fixed the root cause of the bug in the JRA project, but I 
added an additional unit test here. Basically the issue was we weren't
able to handle resources like /customer/{123} and /customer/details/{123}.
The first would always get triggered.

We're dependent on a JRA snapshot until I finallize a release tomorrow.


Added:
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.aegis.xml
  (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.java
  (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadXMLTest.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/bindings/http/pom.xml
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/bare/CustomerService.java

Modified: incubator/cxf/trunk/rt/bindings/http/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/pom.xml?view=diff&rev=559631&r1=559630&r2=559631
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/pom.xml (original)
+++ incubator/cxf/trunk/rt/bindings/http/pom.xml Wed Jul 25 15:15:08 2007
@@ -34,7 +34,7 @@
         <dependency>
             <groupId>org.codehaus.jra</groupId>
             <artifactId>jra</artifactId>
-            <version>1.0-alpha-3</version>
+            <version>1.0-alpha-4-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.cxf</groupId>
@@ -130,6 +130,16 @@
         </plugins>
     </build>
 
+    <repositories>
+      <repository>
+        <id>codehaus.org</id>
+        <name>Codehaus Snapshot Repository</name>
+        <url>http://snapshots.repository.codehaus.org/</url>
+        <snapshots>
+          <enabled>true</enabled>
+        </snapshots>
+      </repository>
+    </repositories>
 
     <scm>
         <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/cxf/trunk/rt/bindings/http</connection>

Modified: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java?view=diff&rev=559631&r1=559630&r2=559631
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
(original)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
Wed Jul 25 15:15:08 2007
@@ -78,6 +78,10 @@
         assertNotNull(bop);
         assertEquals("updateCustomer", bop.getName().getLocalPart());
         
+        bop = mapper.getOperation("/customers/details/123", "GET", null);
+        assertNotNull(bop);
+        assertEquals("getSomeDetails", bop.getName().getLocalPart());
+        
         // TEST POST/GETs
         
         Document res = get("http://localhost:9001/foo/customers");

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java?view=diff&rev=559631&r1=559630&r2=559631
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java
Wed Jul 25 15:15:08 2007
@@ -369,7 +369,12 @@
 
         String prefix = value.substring(0, index);
         String localName = value.substring(index + 1);
-        String ns = e.getNamespace(prefix).getURI();
+        Namespace jNS = e.getNamespace(prefix);
+        if (jNS == null) {
+            throw new DatabindingException("No namespace was found for prefix: " + prefix);
+        }
+        
+        String ns = jNS.getURI();
 
         if (ns == null || localName == null) {
             throw new DatabindingException("Invalid QName in mapping: " + value);

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.aegis.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.aegis.xml?view=auto&rev=559631
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.aegis.xml
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.aegis.xml
Wed Jul 25 15:15:08 2007
@@ -0,0 +1,4 @@
+<mappings xmlns:btrnmi="urn:org.apache.cxf.aegis.type">
+  <mapping name="oacat:Invalid">
+  </mapping>
+</mappings>
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.aegis.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.aegis.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.aegis.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.aegis.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.java?view=auto&rev=559631
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.java
Wed Jul 25 15:15:08 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.type.basic;
+
+public class BadBeanDescriptor {
+    private String property;
+
+    public String getProperty() {
+        return property;
+    }
+
+    public void setProperty(String property) {
+        this.property = property;
+    }
+    
+    
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadBeanDescriptor.java
------------------------------------------------------------------------------
    svn:executable = *

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadXMLTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadXMLTest.java?view=auto&rev=559631
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadXMLTest.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadXMLTest.java
Wed Jul 25 15:15:08 2007
@@ -0,0 +1,44 @@
+/**
+ * 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.type.basic;
+
+import junit.framework.TestCase;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.junit.Test;
+
+public class BadXMLTest extends TestCase {
+    TypeMapping mapping;
+    private DefaultTypeMappingRegistry reg;
+
+    @Test
+    public void testBadDescriptorNS() throws Exception {
+
+        reg = new DefaultTypeMappingRegistry(true);
+        mapping = reg.createTypeMapping(true);
+        try {
+            mapping.getTypeCreator().createType(BadBeanDescriptor.class);
+            fail("No exception was thrown");
+        } catch (DatabindingException e) {
+            // this is supposed to happen
+        }
+
+    }
+}

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

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BadXMLTest.java
------------------------------------------------------------------------------
    svn:executable = *

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

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/bare/CustomerService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/bare/CustomerService.java?view=diff&rev=559631&r1=559630&r2=559631
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/bare/CustomerService.java
(original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/bare/CustomerService.java
Wed Jul 25 15:15:08 2007
@@ -80,6 +80,14 @@
         return c;
     }
 
+    @Get
+    @HttpResource(location = "/customers/details/{id}")
+    @WebMethod
+    public String getSomeDetails(@WebParam(name = "GetCustomer") GetCustomer getCustomer)

+        throws CustomerNotFoundFault {
+        return "some details";
+    }
+    
     @Put
     @HttpResource(location = "/customers/{id}")
     @WebMethod



Mime
View raw message