cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r763953 - in /cxf/trunk: rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ systests/src/test/java/org/apache/cxf/systest/jaxrs/
Date Fri, 10 Apr 2009 14:42:20 GMT
Author: sergeyb
Date: Fri Apr 10 14:42:20 2009
New Revision: 763953

URL: http://svn.apache.org/viewvc?rev=763953&view=rev
Log:
Couple of updates to get the JAXRS tests passing on IBM JDK

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/CD.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java?rev=763953&r1=763952&r2=763953&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
Fri Apr 10 14:42:20 2009
@@ -25,9 +25,12 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.ws.rs.core.MultivaluedMap;
+
 import org.apache.cxf.jaxrs.resources.Book;
 import org.apache.cxf.jaxrs.resources.BookStore;
 import org.apache.cxf.jaxrs.resources.UriBuilderWrongAnnotations;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -337,7 +340,7 @@
         URI newUri = new UriBuilderImpl().scheme("http").host("foo").port(1234).path("bar").queryParam("n1",
                                                                                         
              "v1")
             .queryParam("n2", "v2").fragment("fragment").build();
-        assertEquals("URI is not built correctly", uri, newUri);
+        compareURIs(uri, newUri);
     }
 
     @Test
@@ -567,4 +570,18 @@
         assertEquals("URI is not built correctly", new URI("http://blah/foo/bar;p1=v1/baz;p2=v2"),
newUri);
     }
     
+    private void compareURIs(URI uri1, URI uri2) {
+        
+        assertEquals("Unexpected scheme", uri1.getScheme(), uri2.getScheme());
+        assertEquals("Unexpected host", uri1.getHost(), uri2.getHost());
+        assertEquals("Unexpected port", uri1.getPort(), uri2.getPort());
+        assertEquals("Unexpected path", uri1.getPath(), uri2.getPath());
+        assertEquals("Unexpected fragment", uri1.getFragment(), uri2.getFragment());
+        
+        MultivaluedMap<String, String> queries1 = 
+            JAXRSUtils.getStructuredParams(uri1.getRawQuery(), "&", false);
+        MultivaluedMap<String, String> queries2 = 
+            JAXRSUtils.getStructuredParams(uri2.getRawQuery(), "&", false);
+        assertEquals("Unexpected queries", queries1, queries2);
+    }
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/CD.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/CD.java?rev=763953&r1=763952&r2=763953&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/CD.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/CD.java Fri Apr 10 14:42:20
2009
@@ -29,6 +29,11 @@
     public CD() {
     }
     
+    public CD(String name, long id) {
+        this.name = name;
+        this.id = id;
+    }
+    
     public void setName(String n) {
         name = n;
     }
@@ -45,4 +50,16 @@
         return id;
     }
 
+    public boolean equals(Object o) {
+        if (!(o instanceof CD)) {
+            return false;
+        }
+        
+        CD other = (CD)o;
+        return name.equals(other.name) && id == other.id;
+    }
+    
+    public int hashCode() {
+        return name.hashCode() + new Long(id).hashCode();
+    }
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=763953&r1=763952&r2=763953&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Fri Apr 10 14:42:20 2009
@@ -23,6 +23,7 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.Collection;
 import java.util.List;
 
 import javax.ws.rs.core.Response;
@@ -650,9 +651,12 @@
     @Test
     public void testGetCDs() throws Exception {
         
-        getAndCompareAsStrings("http://localhost:9080/bookstore/cds",
-                               "resources/expected_get_cds124.txt",
-                               "application/xml", 200);
+        WebClient wc = WebClient.create("http://localhost:9080/bookstore/cds");
+        CDs cds = wc.get(CDs.class);
+        Collection<CD> collection = cds.getCD();
+        assertEquals(2, collection.size());
+        assertTrue(collection.contains(new CD("BICYCLE RACE", 124)));
+        assertTrue(collection.contains(new CD("BOHEMIAN RHAPSODY", 123)));
     }
     
     @Test



Mime
View raw message