Package org.exoplatform.services.rest.generated

Examples of org.exoplatform.services.rest.generated.Book


   {
      @GET
      @Produces("application/json")
      public Book m1()
      {
         Book book = new Book();
         book.setTitle("Hamlet");
         book.setAuthor("William Shakespeare");
         book.setSendByPost(true);
         return book;
      }
View Full Code Here


         return createArray();
      }

      private Book[] createArray()
      {
         Book book1 = new Book();
         book1.setTitle("Hamlet");
         book1.setAuthor("William Shakespeare");
         book1.setSendByPost(true);
         Book book2 = new Book();
         book2.setTitle("Collected Stories");
         book2.setAuthor("Gabriel Garcia Marquez");
         book2.setSendByPost(true);
         return new Book[]{book1, book2};
      }
View Full Code Here

         return createCollection();
      }

      private List<Book> createCollection()
      {
         Book book1 = new Book();
         book1.setTitle("Hamlet");
         book1.setAuthor("William Shakespeare");
         book1.setSendByPost(true);
         Book book2 = new Book();
         book2.setTitle("Collected Stories");
         book2.setAuthor("Gabriel Garcia Marquez");
         book2.setSendByPost(true);
         return Arrays.asList(book1, book2);
      }
View Full Code Here

         return createMap();
      }

      private Map<String, Book> createMap()
      {
         Book book1 = new Book();
         book1.setTitle("Hamlet");
         book1.setAuthor("William Shakespeare");
         book1.setSendByPost(true);
         Book book2 = new Book();
         book2.setTitle("Collected Stories");
         book2.setAuthor("Gabriel Garcia Marquez");
         book2.setSendByPost(true);
         Map<String, Book> m = new HashMap<String, Book>();
         m.put("12345", book1);
         m.put("54321", book2);
         return m;
      }
View Full Code Here

      h.putSingle("accept", "application/xml");
      ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
      ContainerResponse response = launcher.service("GET", "/", "", h, null, writer, null);
      assertEquals(200, response.getStatus());
      assertEquals("application/xml", response.getContentType().toString());
      Book book = (Book)response.getEntity();
      assertEquals("Hamlet", book.getTitle());
      assertEquals("William Shakespeare", book.getAuthor());
      assertTrue(book.isSendByPost());

      // Resource2#m2()
      writer = new ByteArrayContainerResponseWriter();
      response = launcher.service("POST", "/", "", h, null, writer, null);
      assertEquals(200, response.getStatus());
      assertEquals("application/xml", response.getContentType().toString());
      book = (Book)response.getEntity();
      assertEquals("Hamlet\n", book.getTitle());
      assertEquals("William Shakespeare\n", book.getAuthor());
      assertFalse(book.isSendByPost());

      unregistry(r2);
   }
View Full Code Here

      assertEquals(200, response.getStatus());
      assertEquals("application/json", response.getContentType().toString());
      JsonParserImpl parser = new JsonParserImpl();
      JsonDefaultHandler handler = new JsonDefaultHandler();
      parser.parse(new ByteArrayInputStream(writer.getBody()), handler);
      Book book = ObjectBuilder.createObject(Book.class, handler.getJsonObject());
      assertEquals("Hamlet", book.getTitle());
      assertEquals("William Shakespeare", book.getAuthor());
      assertTrue(book.isSendByPost());

      // ResourceBook2#m2()
      writer.reset();
      handler.reset();
      response = launcher.service("POST", "/", "", h, null, writer, null);
      assertEquals(200, response.getStatus());
      assertEquals("application/json", response.getContentType().toString());
      parser.parse(new ByteArrayInputStream(writer.getBody()), handler);
      book = ObjectBuilder.createObject(Book.class, handler.getJsonObject());
      assertEquals("Hamlet", book.getTitle());
      assertEquals("William Shakespeare", book.getAuthor());
      assertTrue(book.isSendByPost());

      unregistry(r2);
   }
View Full Code Here

      @POST
      @Path("b")
      @Consumes("application/xml")
      public void m1(JAXBElement<Book> e)
      {
         Book book = e.getValue();
         assertEquals("Java and XML Data Binding", book.getTitle());
         assertEquals("Brett McLaughlin", book.getAuthor());
         assertEquals("EUR", book.getPrice().getCurrency());
         assertEquals("EUR", book.getMemberPrice().getCurrency());
         assertTrue(book.isSendByPost());
      }
View Full Code Here

   {
      @GET
      @Produces("application/xml")
      public Book m0()
      {
         Book book = new Book();
         book.setAuthor("William Shakespeare");
         book.setTitle("Hamlet");
         book.setSendByPost(true);
         // ignore some fields
         return book;
      }
View Full Code Here

      // Without @Produces annotation also should work.
      @POST
      public Book m1()
      {
         Book book = new Book();
         book.setAuthor("William Shakespeare\n");
         book.setTitle("Hamlet\n");
         book.setSendByPost(false);
         // ignore some fields
         return book;
      }
View Full Code Here

      MessageBodyReader prov = providers.getMessageBodyReader(Book.class, null, null, mediaType);
      assertNotNull(prov);
      assertTrue(prov.isReadable(Book.class, Book.class, null, mediaType));
      MultivaluedMap<String, String> h = new MultivaluedMapImpl();
      h.putSingle(HttpHeaders.CONTENT_LENGTH, "" + data.length);
      Book book = (Book)prov.readFrom(Book.class, Book.class, null, mediaType, h, new ByteArrayInputStream(data));
      assertEquals("Brett McLaughlin", book.getAuthor());
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.rest.generated.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.