cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r549323 - in /incubator/cxf/trunk/rt/bindings/http/src: main/java/org/apache/cxf/binding/http/ test/java/org/apache/cxf/binding/http/bare/
Date Thu, 21 Jun 2007 01:50:27 GMT
Author: dandiep
Date: Wed Jun 20 18:50:26 2007
New Revision: 549323

URL: http://svn.apache.org/viewvc?view=rev&rev=549323
Log:
Add more tests and better error reporting for the HTTP Binding.

Added:
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/Messages.properties
  (with props)
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetData.java
  (with props)
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetDataResponse.java
  (with props)
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/TestService.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
    incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/index.jaxb

Modified: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java?view=diff&rev=549323&r1=549322&r2=549323
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
(original)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/IriDecoderHelper.java
Wed Jun 20 18:50:26 2007
@@ -24,6 +24,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.ResourceBundle;
 
 import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
@@ -33,19 +34,25 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.ws.commons.schema.XmlSchemaAnnotated;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
+
 /**
  * @author <a href=""mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
  */
 public final class IriDecoderHelper {
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(IriDecoderHelper.class);
 
     private IriDecoderHelper() {
         
@@ -202,11 +209,13 @@
             if (cplxType == null) {
                 cplxType = (XmlSchemaComplexType)findSchemaType(schemas, element.getSchemaTypeName());
             }
-        }
-        if (schemaAnnotation instanceof XmlSchemaComplexType) {
+        } else if (schemaAnnotation instanceof XmlSchemaComplexType) {
             cplxType = (XmlSchemaComplexType)schemaAnnotation;
             qname = cplxType.getQName();
+        } else if (schemaAnnotation instanceof XmlSchemaSimpleType) {
+            throw new Fault(new Message("SIMPLE_TYPE", BUNDLE));
         }
+        
         Document doc = DOMUtils.createDocument();
          
               

Added: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/Messages.properties?view=auto&rev=549323
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/Messages.properties
(added)
+++ incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/Messages.properties
Wed Jun 20 18:50:26 2007
@@ -0,0 +1,21 @@
+#
+#
+#    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.
+#
+#
+SIMPLE_TYPE = You can not map a URI parameter to a simple type when in unwrapped mode!
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/Messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/Messages.properties
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/Messages.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/bindings/http/src/main/java/org/apache/cxf/binding/http/Messages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=549323&r1=549322&r2=549323
==============================================================================
--- 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 Jun 20 18:50:26 2007
@@ -31,6 +31,7 @@
 import org.apache.cxf.binding.http.URIMapper;
 import org.apache.cxf.customer.bare.CustomerService;
 import org.apache.cxf.endpoint.ServerImpl;
+import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.junit.Test;
@@ -147,6 +148,64 @@
         c.setRequestMethod("GET");
         
         assertEquals("text/plain", c.getContentType());
+
+        svr.stop();
+    }
+
+    @Test
+    public void testGetOnBadUnwrappedParam() throws Exception {
+        BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
+        HttpBindingFactory factory = new HttpBindingFactory();
+        factory.setBus(getBus());
+        bfm.registerBindingFactory(HttpBindingFactory.HTTP_BINDING_ID, factory);
+        
+        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+        sf.setBus(getBus());
+        sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
+        sf.setServiceBean(new TestService());
+        sf.getServiceFactory().setWrapped(false);
+        sf.setAddress("http://localhost:9001/test/");
+
+        ServerImpl svr = (ServerImpl) sf.create();
+        
+        URL url = new URL("http://localhost:9001/test/topics/123");
+        HttpURLConnection c = (HttpURLConnection)url.openConnection();
+        c.setRequestMethod("GET");
+        
+        assertEquals("text/xml", c.getContentType());
+        
+        Document doc = DOMUtils.readXml(c.getErrorStream());
+        assertValid("//*[text()='You can not map a URI parameter to a "
+                    + "simple type when in unwrapped mode!']", doc);
+
+        svr.stop();
+    }
+    
+    @Test
+    public void testQueryParam() throws Exception {
+        BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
+        HttpBindingFactory factory = new HttpBindingFactory();
+        factory.setBus(getBus());
+        bfm.registerBindingFactory(HttpBindingFactory.HTTP_BINDING_ID, factory);
+        
+        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+        sf.setBus(getBus());
+        sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
+        sf.setServiceBean(new TestService());
+        sf.getServiceFactory().setWrapped(false);
+        sf.setAddress("http://localhost:9001/test/");
+
+        ServerImpl svr = (ServerImpl) sf.create();
+        
+        URL url = new URL("http://localhost:9001/test/rest/foo");
+        HttpURLConnection c = (HttpURLConnection)url.openConnection();
+        c.setRequestMethod("GET");
+        
+        assertEquals("text/xml", c.getContentType());
+        
+        Document doc = DOMUtils.readXml(c.getInputStream());
+        addNamespace("b", "http://bare.http.binding.cxf.apache.org/");
+        assertValid("//b:getDataResponse", doc);
 
         svr.stop();
     }

Added: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetData.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetData.java?view=auto&rev=549323
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetData.java
(added)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetData.java
Wed Jun 20 18:50:26 2007
@@ -0,0 +1,35 @@
+/**
+ * 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.binding.http.bare;
+
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType
+public class GetData {
+    private String xPathQuery;
+
+    public String getXPathQuery() {
+        return xPathQuery;
+    }
+
+    public void setXPathQuery(String pathQuery) {
+        xPathQuery = pathQuery;
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetData.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetData.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetDataResponse.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetDataResponse.java?view=auto&rev=549323
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetDataResponse.java
(added)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetDataResponse.java
Wed Jun 20 18:50:26 2007
@@ -0,0 +1,24 @@
+/**
+ * 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.binding.http.bare;
+
+public class GetDataResponse {
+
+}

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetDataResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetDataResponse.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/GetDataResponse.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/TestService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/TestService.java?view=auto&rev=549323
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/TestService.java
(added)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/TestService.java
Wed Jun 20 18:50:26 2007
@@ -0,0 +1,41 @@
+/**
+ * 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.binding.http.bare;
+
+import javax.jws.WebParam;
+import javax.jws.WebService;
+
+import org.codehaus.jra.Get;
+import org.codehaus.jra.HttpResource;
+
+@WebService
+public class TestService {
+
+    @Get
+    @HttpResource(location = "/topics/{id}")
+    public String getTopics(@WebParam(name = "id") long id) {
+        return "";
+    }
+    
+    @Get
+    @HttpResource(location = "/rest/{xPathQuery}")
+    public GetDataResponse getData(@WebParam(name = "GetData") GetData query) {
+        return new GetDataResponse();
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/TestService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/TestService.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/TestService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/index.jaxb
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/index.jaxb?view=diff&rev=549323&r1=549322&r2=549323
==============================================================================
--- incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/index.jaxb
(original)
+++ incubator/cxf/trunk/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/index.jaxb
Wed Jun 20 18:50:26 2007
@@ -1 +1,2 @@
-Customer
\ No newline at end of file
+GetDataResponse
+GetData
\ No newline at end of file



Mime
View raw message