Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java?rev=907718&r1=907717&r2=907718&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java (original) +++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java Mon Feb 8 16:41:11 2010 @@ -30,10 +30,12 @@ import javax.xml.bind.annotation.XmlType; import org.apache.cxf.jaxrs.ext.Description; +import org.apache.cxf.jaxrs.ext.xml.XMLName; @XmlRootElement(name = "thebook", namespace = "http://superbooks") @XmlType(name = "book", namespace = "http://superbooks") @Description("Book subresource") +...@xmlname(value = "{http://books}thesuperbook", prefix = "p1") public class Book { private int id;
Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Chapter.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Chapter.java?rev=907718&r1=907717&r2=907718&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Chapter.java (original) +++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Chapter.java Mon Feb 8 16:41:11 2010 @@ -25,10 +25,12 @@ import javax.xml.bind.annotation.XmlType; import org.apache.cxf.jaxrs.ext.Description; +import org.apache.cxf.jaxrs.ext.xml.XMLName; @XmlRootElement(name = "thechapter", namespace = "http://superbooks") @XmlType(name = "chapter", namespace = "http://superbooks") @Description("Chapter subresource") +...@xmlname(value = "{http://books}thesuperchapter", prefix = "p1") public class Chapter { private int id; Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=907718&r1=907717&r2=907718&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java (original) +++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java Mon Feb 8 16:41:11 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/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=907718&r1=907717&r2=907718&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java (original) +++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java Mon Feb 8 16:41:11 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); Added: cxf/trunk/rt/frontend/jaxrs/src/test/resources/book1.xsd URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/resources/book1.xsd?rev=907718&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/test/resources/book1.xsd (added) +++ cxf/trunk/rt/frontend/jaxrs/src/test/resources/book1.xsd Mon Feb 8 16:41:11 2010 @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + 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. +--> + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://superbooks" + xmlns:tns="http://superbooks" elementFormDefault="unqualified"> + + <xs:element name="thebook" type="tns:book"/> + <xs:element name="thebook2" type="tns:book2"/> + <xs:element name="thechapter" type="tns:chapter"/> + + <xs:complexType name="book"> + + <xs:sequence> + <xs:element minOccurs="0" ref="tns:thechapter"/> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="chapter"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="book2"> + + <xs:sequence> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + +</xs:schema> \ No newline at end of file Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/resources/book1.xsd ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/resources/book1.xsd ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/resources/book1.xsd ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: cxf/trunk/rt/frontend/jaxrs/src/test/resources/book2.xsd URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/resources/book2.xsd?rev=907718&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/test/resources/book2.xsd (added) +++ cxf/trunk/rt/frontend/jaxrs/src/test/resources/book2.xsd Mon Feb 8 16:41:11 2010 @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + 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. +--> + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://superbooks" + xmlns:tns="http://superbooks" elementFormDefault="unqualified"> + + <xs:element name="book" type="tns:book"/> + <xs:element name="book2" type="tns:book2"/> + <xs:element name="chapter" type="tns:chapter"/> + + <xs:complexType name="book"> + + <xs:sequence> + <xs:element minOccurs="0" ref="tns:thechapter"/> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="chapter"> + <xs:sequence> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="book2"> + + <xs:sequence> + <xs:element name="id" type="xs:int"/> + </xs:sequence> + </xs:complexType> + +</xs:schema> \ No newline at end of file Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/resources/book2.xsd ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/resources/book2.xsd ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/resources/book2.xsd ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: cxf/trunk/rt/frontend/jaxrs/src/test/resources/books.xsd URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/resources/books.xsd?rev=907718&view=auto ============================================================================== --- cxf/trunk/rt/frontend/jaxrs/src/test/resources/books.xsd (added) +++ cxf/trunk/rt/frontend/jaxrs/src/test/resources/books.xsd Mon Feb 8 16:41:11 2010 @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + 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. +--> + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://books" + xmlns:tns="http://books" xmlns:sbooks="http://superbooks"> + + <xs:import schemaLocation="book1.xsd"/> + + <xs:element name="books" type="tns:books"/> + + <xs:complexType name="books"> + + <xs:sequence> + <xs:element minOccurs="0" ref="sbooks:thebook"/> + </xs:sequence> + </xs:complexType> + +</xs:schema> \ No newline at end of file Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/resources/books.xsd ------------------------------------------------------------------------------ svn:eol-style = native Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/resources/books.xsd ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/resources/books.xsd ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=907718&r1=907717&r2=907718&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Mon Feb 8 16:41:11 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/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=907718&r1=907717&r2=907718&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Mon Feb 8 16:41:11 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
