cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r562342 - in /incubator/cxf/trunk/rt/bindings/http/src: main/java/org/apache/cxf/binding/http/IriDecoderHelper.java test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
Date Fri, 03 Aug 2007 05:40:31 GMT
Author: mmao
Date: Thu Aug  2 22:40:31 2007
New Revision: 562342

URL: http://svn.apache.org/viewvc?view=rev&rev=562342
Log:
Fix the build, replace the hard code message in the code



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

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=562342&r1=562341&r2=562342
==============================================================================
--- 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
Thu Aug  2 22:40:31 2007
@@ -52,10 +52,10 @@
  * @author <a href=""mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
  */
 public final class IriDecoderHelper {
-    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(IriDecoderHelper.class);
+    public static final ResourceBundle BUNDLE = BundleUtils.getBundle(IriDecoderHelper.class);
 
     private IriDecoderHelper() {
-        
+
     }
 
     public static List<Param> decodeIri(String uri, String loc) {
@@ -100,13 +100,13 @@
 
     private static String getEndFragment(int i, String locPath) {
         int end = locPath.indexOf('{', i);
-        
+
         if (end == -1) {
             end = locPath.length();
         } else if (locPath.charAt(end + 1) == '{') {
             return getEndFragment(end + 1, locPath);
         }
-        
+
         return locPath.substring(i, end);
     }
 
@@ -123,25 +123,25 @@
     }
 
     /**
-     * @param endFragment 
-     * 
+     * @param endFragment
+     *
      */
     public static int findPartEnd(String path, int c, String endFragment) {
         int end = path.length();
         int i = end;
-        
+
         if (!"".equals(endFragment)) {
             i = path.indexOf(endFragment, c);
             if (i >= c && i < end) {
                 end = i;
             }
         }
-        
+
         i =  path.indexOf('?', c);
         if (i >= c && i < end) {
             end = i;
         }
-        
+
         return end;
     }
 
@@ -186,11 +186,11 @@
         }
         return null;
     }
-    
+
     /**
      * Create a dom document conformant with the given schema element with the
      * input parameters.
-     * 
+     *
      * @param element
      * @param params
      * @return
@@ -198,7 +198,7 @@
     public static Document buildDocument(XmlSchemaAnnotated schemaAnnotation,
                                          Collection<SchemaInfo> schemas,
                                          List<Param> params) {
-        
+
         XmlSchemaElement element = null;
         QName qname = null;
         XmlSchemaComplexType cplxType = null;
@@ -215,19 +215,19 @@
         } else if (schemaAnnotation instanceof XmlSchemaSimpleType) {
             throw new Fault(new Message("SIMPLE_TYPE", BUNDLE));
         }
-        
+
         Document doc = DOMUtils.createDocument();
-         
-              
+
+
         XmlSchemaSequence seq = (XmlSchemaSequence)cplxType.getParticle();
         Element e = doc.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
         e.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, qname.getNamespaceURI());
         doc.appendChild(e);
-        
+
         if (seq == null || seq.getItems() == null) {
             return doc;
         }
-        
+
         for (int i = 0; i < seq.getItems().getCount(); i++) {
             XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().getItem(i);
             Param param = null;
@@ -250,7 +250,7 @@
         }
         return doc;
     }
-    
+
     public static Document interopolateParams(Document doc,
                                               XmlSchemaAnnotated schemaAnnotation,
                                               Collection<SchemaInfo> schemas,
@@ -273,12 +273,12 @@
         XmlSchemaSequence seq = (XmlSchemaSequence)cplxType.getParticle();
         Element root = doc.getDocumentElement();
         if (root == null) {
-            root = doc.createElementNS(qname.getNamespaceURI(), 
+            root = doc.createElementNS(qname.getNamespaceURI(),
                                     qname.getLocalPart());
             root.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, qname.getNamespaceURI());
             doc.appendChild(root);
         }
-        
+
         for (int i = 0; i < seq.getItems().getCount(); i++) {
             XmlSchemaElement elChild = (XmlSchemaElement)seq.getItems().getItem(i);
             Param param = null;
@@ -291,7 +291,7 @@
             if (param == null) {
                 continue;
             }
-            
+
             Element ec = getElement(root, elChild.getQName());
             if (ec == null) {
                 ec = doc.createElementNS(elChild.getQName().getNamespaceURI(), elChild.getQName()
@@ -299,7 +299,7 @@
                 if (!elChild.getQName().getNamespaceURI().equals(qname.getNamespaceURI()))
{
                     ec.setAttribute(XMLConstants.XMLNS_ATTRIBUTE, elChild.getQName().getNamespaceURI());
                 }
-                
+
                 // insert the element at the appropriate position
                 Element insertBeforeEl = getIndexedElement(root, i);
                 if (insertBeforeEl != null) {
@@ -314,7 +314,7 @@
                     ec.removeChild(n);
                 }
             }
-            
+
             if (param != null) {
                 params.remove(param);
                 ec.appendChild(doc.createTextNode(param.getValue()));
@@ -394,7 +394,7 @@
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see java.lang.Object#toString()
          */
         @Override
@@ -404,7 +404,7 @@
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see java.lang.Object#hashCode()
          */
         @Override
@@ -418,7 +418,7 @@
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see java.lang.Object#equals(java.lang.Object)
          */
         @Override

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=562342&r1=562341&r2=562342
==============================================================================
--- 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
Thu Aug  2 22:40:31 2007
@@ -28,7 +28,9 @@
 import org.apache.cxf.binding.BindingFactoryManager;
 import org.apache.cxf.binding.http.AbstractRestTest;
 import org.apache.cxf.binding.http.HttpBindingFactory;
+import org.apache.cxf.binding.http.IriDecoderHelper;
 import org.apache.cxf.binding.http.URIMapper;
+import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.customer.bare.CustomerService;
 import org.apache.cxf.endpoint.ServerImpl;
 import org.apache.cxf.helpers.DOMUtils;
@@ -37,14 +39,14 @@
 import org.junit.Test;
 
 public class BareServiceTest extends AbstractRestTest {
-    
+
     @Test
     public void testCreation() 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);
@@ -52,38 +54,38 @@
         sf.getServiceFactory().setWrapped(false);
         sf.setAddress("http://localhost:9001/foo/");
         sf.setServiceBean(new CustomerService());
-        
+
         Map<String, Object> props = new HashMap<String, Object>();
         props.put("contextMatchStrategy", "stem");
         sf.setProperties(props);
-        
+
         ServerImpl svr = (ServerImpl) sf.create();
 
         URIMapper mapper = (URIMapper) svr.getEndpoint().getService().get(URIMapper.class.getName());
         assertNotNull(mapper);
-        
+
         BindingOperationInfo bop = mapper.getOperation("/customers", "GET", null);
         assertNotNull(bop);
         assertEquals("getCustomers", bop.getName().getLocalPart());
-        
+
         bop = mapper.getOperation("/customers", "POST", null);
         assertNotNull(bop);
         assertEquals("addCustomer", bop.getName().getLocalPart());
-        
+
         bop = mapper.getOperation("/customers/123", "GET", null);
         assertNotNull(bop);
         assertEquals("getCustomer", bop.getName().getLocalPart());
-        
+
         bop = mapper.getOperation("/customers/123", "PUT", null);
         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");
         assertNotNull(res);
 
@@ -91,38 +93,38 @@
         assertValid("/c:customers", res);
         assertValid("/c:customers/c:customer/c:id[text()='123']", res);
         assertValid("/c:customers/c:customer/c:name[text()='Dan Diephouse']", res);
-        
+
         res = get("http://localhost:9001/foo/customers/123");
         assertNotNull(res);
-        
+
         assertValid("/c:customer", res);
         assertValid("/c:customer/c:id[text()='123']", res);
         assertValid("/c:customer/c:name[text()='Dan Diephouse']", res);
-        
+
         // Try invalid customer
         res = get("http://localhost:9001/foo/customers/0", 500);
         assertNotNull(res);
-        
+
         assertValid("//c:CustomerNotFoundDetails", res);
-        
+
         res = put("http://localhost:9001/foo/customers/123", "update.xml");
         assertNotNull(res);
-        
+
         assertValid("/c:updateCustomer", res);
-        
+
         res = post("http://localhost:9001/foo/customers", "add.xml");
         assertNotNull(res);
-        
+
         assertValid("/c:addCustomer", res);
 
         // Get the updated document
         res = get("http://localhost:9001/foo/customers/123");
         assertNotNull(res);
-        
+
         assertValid("/c:customer", res);
         assertValid("/c:customer/c:id[text()='123']", res);
         assertValid("/c:customer/c:name[text()='Danno Manno']", res);
-        
+
         svr.stop();
     }
 
@@ -132,7 +134,7 @@
         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);
@@ -140,25 +142,25 @@
         sf.getServiceFactory().setWrapped(false);
         sf.setAddress("http://localhost:9001/foo/");
         sf.setServiceBean(new CustomerService());
-        
+
         Map<String, Object> props = new HashMap<String, Object>();
         props.put("Content-Type", "text/plain");
         sf.setProperties(props);
-        
+
         ServerImpl svr = (ServerImpl) sf.create();
-        
+
         URL url = new URL("http://localhost:9001/foo/customers/123");
         HttpURLConnection c = (HttpURLConnection)url.openConnection();
         c.setRequestMethod("GET");
-        
+
         assertEquals("text/plain", c.getContentType());
 
         c.disconnect();
-        
+
         url = new URL("http://localhost:9001/foo/customers/bleh");
         c = (HttpURLConnection)url.openConnection();
         c.setRequestMethod("GET");
-        
+
         String ct = c.getContentType();
         assertTrue(ct.startsWith("text/plain"));
 
@@ -171,7 +173,7 @@
         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);
@@ -180,27 +182,27 @@
         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; charset=utf-8", 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);
+        Message msg = new Message("SIMPLE_TYPE", IriDecoderHelper.BUNDLE);
+        assertValid("//*[text()='" + msg.toString() + "']", 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);
@@ -209,13 +211,13 @@
         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; charset=utf-8", c.getContentType());
-        
+
         Document doc = DOMUtils.readXml(c.getInputStream());
         addNamespace("b", "http://bare.http.binding.cxf.apache.org/");
         assertValid("//b:getDataResponse", doc);



Mime
View raw message