Package com.jcasey.jaxb

Examples of com.jcasey.jaxb.Books$Book


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Book b = new Book("Lolity", "james callog", 1998);
        ExtBook eb = new ExtBook("title", "author", 1020, "publisher");
    }
View Full Code Here


      JAXBContext jaxb = JAXBContext.newInstance(ObjectFactory.class);
      Unmarshaller unmarshaller = jaxb.createUnmarshaller();
     
      if(bookFile != null)
      {
        Books xmlBooks =  (Books)unmarshaller.unmarshal(bookFile);
       
        // copy data from XML to Hibernate database object
       
        for(Books.Book xmlBook:  xmlBooks.getBook())                       
        {
          com.jcasey.model.Book book = new com.jcasey.model.Book();
         
          book.setAuthor(xmlBook.getAuthor());
          book.setTitle(xmlBook.getTitle());
View Full Code Here

  private static final String BOOKS_XML = "./books.xml";

  public static void main(String[] args) throws JAXBException, IOException {

    Books books = new Books();
   
    // create books
    Book book1 = new Book();
    book1.setIsbn("978-1617290060");
    book1.setTitle("The Well-Grounded Java Developer: Vital techniques of Java 7 and polyglot programming");
    book1.setAuthor("Benjamin J Evans");
   
    // create genre objects
    Genre java = new Genre();
    java.setType("Java");
   
    Genre scala = new Genre();
    scala.setType("Scala");
   
    book1.setGenres(new Genres()); //Books do not need to *have* a list of Genres so create a list here
   
    // link genres with genre list   
  book1.getGenres().getGenre().add(java);
  book1.getGenres().getGenre().add(scala);
 
  // add book to list of books
    books.getBook().add(book1);
   
   
    // create book2 note there are no genres in this book
    Book book2 = new Book();
    book2.setIsbn("978-3832180577");
    book2.setTitle("Java Concurrency in Practice");
    book2.setAuthor("Brian Goetz");

    // add book to list of books
    books.getBook().add(book2);
   
    // create JAXB context and instantiate marshaller
    JAXBContext context = JAXBContext.newInstance(Books.class);
    Marshaller m = context.createMarshaller();
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

    // write to System.out
    m.marshal(books, System.out);

    // write to File
    m.marshal(books, new File(BOOKS_XML));

    // get variables from our xml file, created before
    System.out.println();
    System.out.println("Output from our XML File: ");
    Unmarshaller um = context.createUnmarshaller();
    Books books2 = (Books) um.unmarshal(new FileReader(BOOKS_XML));

    for (Book book : books2.getBook()) {
      System.out.println("Book: " + book.getTitle() + " from " + book.getAuthor());
    }
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void viewBook() throws Exception
  {
    Book mockBook = new Book("xxId", "xxName");
    Page page = new ViewBook(mockBook);
    tester.startPage(page);

    // assertion
    tester.assertRenderedPage(ViewBook.class);
View Full Code Here

  @Test
  public void bookmarkableLink() throws Exception
  {
    // for WebPage without default constructor, I define a TestPageSource to
    // let the page be instatiated lately.
    Book mockBook = new Book("xxId", "xxName");
    tester.startPage(new ViewBook(mockBook));

    // assertion
    tester.assertRenderedPage(ViewBook.class);
    tester.clickLink("link");
View Full Code Here

   * @throws Exception
   */
  @Test
  public void pageConstructor() throws Exception
  {
    Book mockBook = new Book("xxId", "xxName");
    Page page = new ViewBook(mockBook);
    tester.startPage(page);

    // assertion
    tester.assertRenderedPage(ViewBook.class);
View Full Code Here

   * @throws Exception
   */
  @Test
  public void viewBook() throws Exception
  {
    Book mockBook = new Book("xxId", "xxName");
    Page page = new ViewBook(mockBook);
    tester.startPage(page);

    // assertion
    tester.assertRenderedPage(ViewBook.class);
View Full Code Here

  @Test
  public void bookmarkableLink() throws Exception
  {
    // for WebPage without default constructor, I define a TestPageSource to
    // let the page be instatiated lately.
    Book mockBook = new Book("xxId", "xxName");
    tester.startPage(new ViewBook(mockBook));

    // assertion
    tester.assertRenderedPage(ViewBook.class);
    tester.clickLink("link");
View Full Code Here

   * @throws Exception
   */
  @Test
  public void pageConstructor() throws Exception
  {
    Book mockBook = new Book("xxId", "xxName");
    Page page = new ViewBook(mockBook);
    tester.startPage(page);

    // assertion
    tester.assertRenderedPage(ViewBook.class);
View Full Code Here

   * @throws Exception
   */
  @Test
  public void viewBook() throws Exception
  {
    Book mockBook = new Book("xxId", "xxName");
    Page page = new ViewBook(mockBook);
    tester.startPage(page);

    // assertion
    tester.assertRenderedPage(ViewBook.class);
View Full Code Here

TOP

Related Classes of com.jcasey.jaxb.Books$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.