Package org.apache.cxf.jaxrs.resources

Examples of org.apache.cxf.jaxrs.resources.Book


        Service s = new JAXRSServiceImpl(Collections.singletonList(c), true);
        DataBinding binding = new JAXBDataBinding();
        binding.initialize(s);
        DataBindingJSONProvider p = new DataBindingJSONProvider();
        p.setDataBinding(binding);
        Book b = new Book("CXF", 127L);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(b, Book.class, Book.class,
            new Annotation[0], MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(), bos);
        String data = "{\"Book\":{\"id\":127,\"name\":\"CXF\",\"state\":\"\"}}";
        assertEquals(bos.toString(), data);
View Full Code Here


        DataBinding binding = new JAXBDataBinding();
        binding.initialize(s);
        DataBindingJSONProvider p = new DataBindingJSONProvider();
        p.setDataBinding(binding);
        ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
        Book book = (Book)p.readFrom((Class)Book.class, Book.class,
                                      new Annotation[0], MediaType.APPLICATION_JSON_TYPE,
                                      new MetadataMap<String, String>(), is);
        assertEquals("CXF", book.getName());
        assertEquals(127L, book.getId());
    }
View Full Code Here

        s.put("writeXsiType", true);
        AegisDatabinding binding = new AegisDatabinding();
        binding.initialize(s);
        DataBindingJSONProvider p = new DataBindingJSONProvider();
        p.setDataBinding(binding);
        Book b = new Book("CXF", 127L);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(b, Book.class, Book.class,
            new Annotation[0], MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(), bos);
        doTestAegisRead(bos.toString());
    }
View Full Code Here

        AegisDatabinding binding = new AegisDatabinding();
        binding.initialize(s);
        DataBindingJSONProvider p = new DataBindingJSONProvider();
        p.setDataBinding(binding);
       
        Book b = new Book("CXF", 127L);
        List<Book> books = new ArrayList<Book>();
        books.add(b);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(books, List.class, Book.class,
            new Annotation[0], MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(), bos);
View Full Code Here

        AegisDatabinding binding = new AegisDatabinding();
        binding.initialize(s);
        DataBindingJSONProvider p = new DataBindingJSONProvider();
        p.setDataBinding(binding);
        ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
        Book book = (Book)p.readFrom((Class)Book.class, Book.class,
                                      new Annotation[0], MediaType.APPLICATION_XML_TYPE,
                                      new MetadataMap<String, String>(), is);
        assertEquals("CXF", book.getName());
        assertEquals(127L, book.getId());
    }
View Full Code Here

    @Ignore
    public static class TheBooks {

        @Path("/books/{bookId}/{new}")
        public Book getNewBook(Book b) {
            return new Book();
        }
View Full Code Here

            return new Book();
        }
       
        @Path("/books/{bookId}/{new}")
        public Book getNewBook2() {
            return new Book();
        }
View Full Code Here

    public void testJAXBWrite() throws Exception {
        Service s = new JAXRSServiceImpl(Collections.singletonList(c), true);
        DataBinding binding = new JAXBDataBinding();
        binding.initialize(s);
        DataBindingProvider p = new DataBindingProvider(binding);
        Book b = new Book("CXF", 127L);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(b, Book.class, Book.class,
            new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String, Object>(), bos);
        String data = "<Book><id>127</id><name>CXF</name><state></state></Book>";
        assertEquals(bos.toString(), data);
View Full Code Here

        Service s = new JAXRSServiceImpl(Collections.singletonList(c), true);
        DataBinding binding = new JAXBDataBinding();
        binding.initialize(s);
        DataBindingProvider p = new DataBindingProvider(binding);
        ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
        Book book = (Book)p.readFrom((Class)Book.class, Book.class,
                                      new Annotation[0], MediaType.APPLICATION_XML_TYPE,
                                      new MetadataMap<String, String>(), is);
        assertEquals("CXF", book.getName());
        assertEquals(127L, book.getId());
    }
View Full Code Here

    @Ignore
    public static class TheBooks {

        @Path("/books/{bookId}/{new}")
        public Book getNewBook(Book b) {
            return new Book();
        }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.resources.Book

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.