Package org.exoplatform.ws.frameworks.json

Examples of org.exoplatform.ws.frameworks.json.Book


   protected void setUp() throws Exception
   {
      super.setUp();

      junitBook = new Book();
      junitBook.setAuthor("Vincent Masson");
      junitBook.setTitle("JUnit in Action");
      junitBook.setPages(386);
      junitBook.setPrice(19.37);
      junitBook.setIsdn(93011099534534L);
      junitBook.setAvailability(false);
      junitBook.setDelivery(false);

      csharpBook = new Book();
      csharpBook.setAuthor("Christian Gross");
      csharpBook.setTitle("Beginning C# 2008 from novice to professional");
      csharpBook.setPages(511);
      csharpBook.setPrice(23.56);
      csharpBook.setIsdn(9781590598696L);
      csharpBook.setAvailability(false);
      csharpBook.setDelivery(false);

      javaScriptBook = new Book();
      javaScriptBook.setAuthor("Chuck Easttom");
      javaScriptBook.setTitle("Advanced JavaScript. Third Edition");
      javaScriptBook.setPages(617);
      javaScriptBook.setPrice(25.99);
      javaScriptBook.setIsdn(9781598220339L);
View Full Code Here


      String author = "Vincent Masson";
      int pages = 386;
      double price = 19.37;
      long isdn = 930110995;

      Book book = new Book();
      book.setAuthor(author);
      book.setTitle(title);
      book.setPages(pages);
      book.setPrice(price);
      book.setIsdn(isdn);

      JsonValue jv = new JsonGeneratorImpl().createJsonObject(book);
      JsonWriter jsonWriter = new JsonWriterImpl(out);
      jv.writeTo(jsonWriter);
      jsonWriter.flush();
      jsonWriter.close();

      ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
      JsonParser jsonParser = new JsonParserImpl();
      JsonHandler jsonHandler = new JsonDefaultHandler();

      jsonParser.parse(in, jsonHandler);
      JsonValue jsonValue = jsonHandler.getJsonObject();
      Book newBook = ObjectBuilder.createObject(Book.class, jsonValue);
      assertEquals(author, newBook.getAuthor());
      assertEquals(title, newBook.getTitle());
      assertEquals(pages, newBook.getPages());
      assertEquals(price, newBook.getPrice());
      assertEquals(isdn, newBook.getIsdn());
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.ws.frameworks.json.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.