Package org.apache.cxf.jaxrs.provider

Examples of org.apache.cxf.jaxrs.provider.JAXBElementProvider


        assertEquals(123L, books.iterator().next().getId());
    }
   
    @Test
    public void testPostGetBookAdapterListJSON() throws Exception {
        JAXBElementProvider provider = new JAXBElementProvider();
        Map<String, String> outMap = new HashMap<String, String>();
        outMap.put("Books", "CollectionWrapper");
        outMap.put("books", "Book");
        provider.setOutTransformElements(outMap);
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/adapter-list",
                                        Collections.singletonList(provider));
        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
        Response r = wc.type("application/xml").accept("application/json")
            .post(new Books(new Book("CXF", 123L)));
View Full Code Here


                               "application/xml", 200);
    }
   
    @Test
    public void testPostGetBookAdapterList() throws Exception {
        JAXBElementProvider provider = new JAXBElementProvider();
        Map<String, String> outMap = new HashMap<String, String>();
        outMap.put("Books", "CollectionWrapper");
        outMap.put("books", "Book");
        provider.setOutTransformElements(outMap);
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/adapter-list",
                                        Collections.singletonList(provider));
       
        Collection<? extends Book> books = wc.type("application/xml").accept("application/xml")
            .postAndGetCollection(new Books(new Book("CXF", 123L)), Book.class);
View Full Code Here

    }
   
    @Test
    public void testPostGeneratedBook() throws Exception {
        String baseAddress = "http://localhost:" + PORT + "/the/generated/bookstore/books/1";
        JAXBElementProvider provider = new JAXBElementProvider();
        provider.setJaxbElementClassMap(Collections.singletonMap(
                                          "org.apache.cxf.systest.jaxrs.codegen.schema.Book",
                                          "{http://superbooks}thebook"));
       
        WebClient wc = WebClient.create(baseAddress,
                                        Collections.singletonList(provider));
View Full Code Here

        assertEquals("CXF Rocks", b22.getName());
    }
   
    @Test
    public void testGetBookCollection2() throws Exception {
        JAXBElementProvider provider = new JAXBElementProvider();
        provider.setMarshallAsJaxbElement(true);
        provider.setUnmarshallAsJaxbElement(true);
        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT,
                                                    BookStore.class,
                                                    Collections.singletonList(provider));
        BookNoXmlRootElement b1 = new BookNoXmlRootElement("CXF in Action", 123L);
        BookNoXmlRootElement b2 = new BookNoXmlRootElement("CXF Rocks", 124L);
View Full Code Here

                               "application/xml", 200);
    }
   
    @Test
    public void testPostGetBookAdapterList() throws Exception {
        JAXBElementProvider provider = new JAXBElementProvider();
        Map<String, String> outMap = new HashMap<String, String>();
        outMap.put("Books", "CollectionWrapper");
        outMap.put("books", "Book");
        provider.setOutTransformElements(outMap);
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/adapter-list",
                                        Collections.singletonList(provider));
        Collection<? extends Book> books = wc.type("application/xml").accept("application/xml")
            .postAndGetCollection(new Books(new Book("CXF", 123L)), Book.class);
        assertEquals(1, books.size());
View Full Code Here

        assertEquals(123L, books.iterator().next().getId());
    }
   
    @Test
    public void testPostGetBookAdapterListJSON() throws Exception {
        JAXBElementProvider provider = new JAXBElementProvider();
        Map<String, String> outMap = new HashMap<String, String>();
        outMap.put("Books", "CollectionWrapper");
        outMap.put("books", "Book");
        provider.setOutTransformElements(outMap);
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/adapter-list",
                                        Collections.singletonList(provider));
        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
        Response r = wc.type("application/xml").accept("application/json")
            .post(new Books(new Book("CXF", 123L)));
View Full Code Here

        assertEquals("CXF Rocks", b22.getName());
    }
   
    @Test
    public void testGetBookCollection2() throws Exception {
        JAXBElementProvider provider = new JAXBElementProvider();
        provider.setMarshallAsJaxbElement(true);
        provider.setUnmarshallAsJaxbElement(true);
        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT,
                                                    BookStore.class,
                                                    Collections.singletonList(provider));
        BookNoXmlRootElement b1 = new BookNoXmlRootElement("CXF in Action", 123L);
        BookNoXmlRootElement b2 = new BookNoXmlRootElement("CXF Rocks", 124L);
View Full Code Here

                               "application/xml", 200);
    }
   
    @Test
    public void testPostGetBookAdapterList() throws Exception {
        JAXBElementProvider provider = new JAXBElementProvider();
        Map<String, String> outMap = new HashMap<String, String>();
        outMap.put("Books", "CollectionWrapper");
        outMap.put("books", "Book");
        provider.setOutTransformElements(outMap);
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/adapter-list",
                                        Collections.singletonList(provider));
        Collection<? extends Book> books = wc.type("application/xml").accept("application/xml")
            .postAndGetCollection(new Books(new Book("CXF", 123L)), Book.class);
        assertEquals(1, books.size());
View Full Code Here

        assertEquals(123L, books.iterator().next().getId());
    }
   
    @Test
    public void testPostGetBookAdapterListJSON() throws Exception {
        JAXBElementProvider provider = new JAXBElementProvider();
        Map<String, String> outMap = new HashMap<String, String>();
        outMap.put("Books", "CollectionWrapper");
        outMap.put("books", "Book");
        provider.setOutTransformElements(outMap);
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/adapter-list",
                                        Collections.singletonList(provider));
        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
        Response r = wc.type("application/xml").accept("application/json")
            .post(new Books(new Book("CXF", 123L)));
View Full Code Here

            }
        }
    }
   
    private static void checkJaxbType(Class<?> type, Map<Class<?>, Type> types) {
        JAXBElementProvider provider = new JAXBElementProvider();
        if (!InjectionUtils.isPrimitive(type)
            && !JAXBElement.class.isAssignableFrom(type)
            && provider.isReadable(type, type, new Annotation[0], MediaType.APPLICATION_XML_TYPE)) {
            types.put(type, type);
        }       
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.provider.JAXBElementProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.