cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r907724 [2/2] - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/f...
Date Mon, 08 Feb 2010 16:59:56 GMT
Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=907724&r1=907723&r2=907724&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Mon Feb  8 16:59:55 2010
@@ -32,6 +32,7 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -463,6 +464,47 @@
     }
     
     @SuppressWarnings("unchecked")
+    @Test
+    public void testInNsElementsFromLocalsWildcard() throws Exception {
+        String data = "<?xml version='1.0' encoding='UTF-8'?>"
+            + "<tagholder><thetag><group>B</group><name>A</name></thetag></tagholder>";
+        JAXBElementProvider provider = new JAXBElementProvider();
+        Map<String, String> map = new LinkedHashMap<String, String>();
+        map.put("group", "group");
+        map.put("name", "name");
+        map.put("*", "{http://tags}*");
+        provider.setInTransformElements(map);
+        ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
+        Object o = provider.readFrom((Class)TagVO2Holder.class, TagVO2Holder.class,
+                      new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String,
String>(), is);
+        TagVO2Holder holder = (TagVO2Holder)o;
+        TagVO2 tag2 = holder.getTagValue();
+        assertEquals("A", tag2.getName());
+        assertEquals("B", tag2.getGroup());    
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testInNsElementsFromLocalsWildcard2() throws Exception {
+        String data = "<?xml version='1.0' encoding='UTF-8'?>"
+            + "<ns2:tagholder xmlns:ns2=\"http://tags2\" attr=\"attribute\"><ns2:thetag><group>B</group>"
+            + "<name>A</name></ns2:thetag></ns2:tagholder>";
+        JAXBElementProvider provider = new JAXBElementProvider();
+        Map<String, String> map = new LinkedHashMap<String, String>();
+        map.put("group", "group");
+        map.put("name", "name");
+        map.put("{http://tags2}*", "{http://tags}*");
+        provider.setInTransformElements(map);
+        ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
+        Object o = provider.readFrom((Class)TagVO2Holder.class, TagVO2Holder.class,
+                      new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String,
String>(), is);
+        TagVO2Holder holder = (TagVO2Holder)o;
+        TagVO2 tag2 = holder.getTagValue();
+        assertEquals("A", tag2.getName());
+        assertEquals("B", tag2.getGroup());    
+    }
+    
+    @SuppressWarnings("unchecked")
     private void readTagVOAfterTransform(String data, String keyValue) throws Exception {
         JAXBElementProvider provider = new JAXBElementProvider();
         Map<String, String> map = new HashMap<String, String>();
@@ -590,6 +632,42 @@
     }
     
     @Test
+    public void testOutElementsMapLocalNsToLocalWildcard() throws Exception {
+        JAXBElementProvider provider = new JAXBElementProvider();
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("{http://tags}*", "*");
+        provider.setOutTransformElements(map);
+        TagVO2 tag = new TagVO2("A", "B");
+        TagVO2Holder holder = new TagVO2Holder();
+        holder.setTag(tag);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        provider.writeTo(holder, TagVO2Holder.class, TagVO2Holder.class,
+                       new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String,
Object>(), bos);
+        String expected = "<?xml version='1.0' encoding='UTF-8'?>"
+            + "<tagholder attr=\"attribute\"><thetag><group>B</group><name>A</name></thetag></tagholder>";
+        assertEquals(expected, bos.toString());
+    }
+    
+    @Test
+    public void testOutElementsMapLocalNsToLocalWildcard2() throws Exception {
+        JAXBElementProvider provider = new JAXBElementProvider();
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("{http://tags}*", "{http://tags2}*");
+        provider.setOutTransformElements(map);
+        TagVO2 tag = new TagVO2("A", "B");
+        TagVO2Holder holder = new TagVO2Holder();
+        holder.setTag(tag);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        provider.writeTo(holder, TagVO2Holder.class, TagVO2Holder.class,
+                       new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String,
Object>(), bos);
+        
+        String expected = "<?xml version='1.0' encoding='UTF-8'?>"
+            + "<ns2:tagholder xmlns:ns2=\"http://tags2\" attr=\"attribute\"><ns2:thetag><group>B</group>"
+            + "<name>A</name></ns2:thetag></ns2:tagholder>";
+        assertEquals(expected, bos.toString());
+    }
+    
+    @Test
     public void testOutElementsMapLocalToLocalNs() throws Exception {
         JAXBElementProvider provider = new JAXBElementProvider();
         Map<String, String> map = new HashMap<String, String>();

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=907724&r1=907723&r2=907724&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Mon Feb  8 16:59:55 2010
@@ -1396,6 +1396,7 @@
     private Message createMessage() {
         ProviderFactory factory = ProviderFactory.getInstance();
         Message m = new MessageImpl();
+        m.put("org.apache.cxf.http.case_insensitive_queries", false);
         Exchange e = new ExchangeImpl();
         m.setExchange(e);
         e.setInMessage(m);

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=907724&r1=907723&r2=907724&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Mon Feb  8 16:59:55 2010
@@ -140,6 +140,14 @@
         return books.containsKey(id);
     }
     
+    @POST
+    @Path("books/check2")
+    @Produces("text/plain")
+    @Consumes("text/plain")
+    public Boolean checkBook2(Long id) {
+        return books.containsKey(id);
+    }
+    
     
     @GET
     @Path("timetable")
@@ -500,7 +508,7 @@
     
     @POST
     @Path("/books/customstatus")
-    @Produces("text/xml")
+    @Produces("application/xml")
     @Consumes("text/xml")
     public Book addBookCustomFailure(Book book, @Context HttpServletResponse response) {
         response.setStatus(333);

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=907724&r1=907723&r2=907724&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Mon Feb  8 16:59:55 2010
@@ -387,7 +387,13 @@
     public void testBookExists() throws Exception {
         checkBook("http://localhost:9080/bookstore/books/check/123", true);
         checkBook("http://localhost:9080/bookstore/books/check/125", false);  
-        
+    }
+    
+    @Test
+    public void testBookExists2() throws Exception {
+        BookStore proxy = JAXRSClientFactory.create("http://localhost:9080", BookStore.class);
+        assertTrue(proxy.checkBook2(123L));
+        assertFalse(proxy.checkBook2(125L));
     }
     
     private void checkBook(String address, boolean expected) throws Exception {
@@ -699,11 +705,12 @@
     public void testAddBookCustomFailureStatus() throws Exception {
         String endpointAddress = "http://localhost:9080/bookstore/books/customstatus";
         WebClient client = WebClient.create(endpointAddress);
-        Book book = client.type("text/xml").accept("text/xml").post(new Book(), Book.class);
+        Book book = client.type("text/xml").accept("application/xml").post(new Book(), Book.class);
         assertEquals(888L, book.getId());
         Response r = client.getResponse();
         assertEquals("CustomValue", r.getMetadata().getFirst("CustomHeader"));
         assertEquals(333, r.getStatus());
+        assertEquals("application/xml", r.getMetadata().getFirst("Content-Type"));
     }
     
     @Test



Mime
View raw message