Package org.apache.torque.test

Examples of org.apache.torque.test.Book


            Author withoutBook = new Author();
            withoutBook.setName(AUTHOR_3_NAME);
            AuthorPeer.doInsert(withoutBook);

            Book effective = new Book();
            effective.setTitle(BOOK_1_TITLE);
            effective.setIsbn(BOOK_1_ISBN);
            effective.setAuthor(bloch);
            effective.save();

            Book tcpip = new Book();
            tcpip.setTitle(BOOK_2_TITLE);
            tcpip.setIsbn(BOOK_2_ISBN);
            tcpip.setAuthorId(stevens.getAuthorId());
            tcpip.save();

            Book tcpipVolTwo = new Book();
            tcpipVolTwo.setTitle(BOOK_3_TITLE);
            tcpipVolTwo.setIsbn(BOOK_3_ISBN);
            tcpipVolTwo.setAuthorId(stevens.getAuthorId());
            tcpipVolTwo.save();

        }
        catch (Exception e) {
            e.printStackTrace();
            fail("Exception caught : "
View Full Code Here


            fail("Exception caught : "
                     + e.getClass().getName()
                     + " : " + e.getMessage());
        }

        Book book = (Book) books.get(0);
        assertTrue(
                "title of first book is not"
                + BOOK_1_TITLE
                + " but "
                + book.getTitle(),
                BOOK_1_TITLE.equals(book.getTitle())
                );

        book = (Book) books.get(2);
        assertTrue(
                "ISBN of third book is not"
                + BOOK_3_ISBN
                + " but "
                + book.getIsbn(),
                BOOK_3_ISBN.equals(book.getIsbn()));
    }
View Full Code Here

    author.setName("Author to be copied");
    author.save();

    for (int j = 1; j <= 10; j++)
    {
      Book book = new Book();
      book.setAuthor(author);
      book.setTitle("Book " + j + " - " + author.getName());
      book.setIsbn("unknown");
      book.save();
    }
    assertTrue("Number of books before copy should be 10, was "
                + author.getBooks().size(), author.getBooks().size() == 10);
    Author authorCopy = author.copy();
    authorCopy.save();
View Full Code Here

                author.setName("Author " + i);
                author.save();

                for (int j = 1; j <= 10; j++)
                {
                    Book book = new Book();
                    book.setAuthor(author);
                    book.setTitle("Book " + j + " - Author " + i);
                    book.setIsbn("unknown");
                    book.save();
                }
            }
            BooleanCheck bc = new BooleanCheck();
            bc.setTestKey("t1");
            bc.setBintValue(true);
View Full Code Here

        author.setName("Author to be copied");
        author.save();

        for (int j = 1; j <= 10; j++)
        {
            Book book = new Book();
            book.setAuthor(author);
            book.setTitle("Book " + j + " - " + author.getName());
            book.setIsbn("unknown");
            book.save();
        }
        assertTrue("Number of books before copy should be 10, was "
                + author.getBooks().size(),
                author.getBooks().size() == 10);
        Author authorCopy = author.copy();
View Full Code Here

    public void testSameObjectRelations() throws Exception
    {
        Author author = new Author();
        author.setAuthorId(AUTHOR_1_ID);
     
        Book book = new Book();
        book.setBookId(BOOK_1_ID);
     
        author.addBook(book);
        book.setAuthor(author);
       
        // check one roundtrip from author
        assertTrue("author from book should be the same object as author",
                author == book.getAuthor());
       
        AuthorBean authorBean = author.getBean();
        BookBean bookBean = (BookBean) authorBean.getBookBeans().get(0);
        assertTrue("authorBean from BookBean should be the same "
                + "object as authorBean",
                bookBean.getAuthorBean() == authorBean);
       
        author = Author.createAuthor(authorBean);
        book = (Book) author.getBooks().get(0);
       
        assertTrue("author from book should be the same object as author "
                + "after creating from bean",
                author == book.getAuthor());
       
        // check one roundtrip from book
        assertTrue("book from author should be the same object as book",
                book == author.getBooks().get(0));

        bookBean = book.getBean();
        authorBean = bookBean.getAuthorBean();
        assertTrue("bookBean from authorBean should be the same "
                + "object as bookBean",
                authorBean.getBookBeans().get(0) == bookBean);

        book = Book.createBook(bookBean);
        author = book.getAuthor();

        assertTrue("book from author should be the same object as book "
                + "after creating from bean",
                author.getBooks().get(0) == book);
    }
View Full Code Here

        //         |            |                    |  
        // author ----> book -----> differentAuthor ---> differentBook
        Author author = new Author();
        author.setAuthorId(AUTHOR_1_ID);

        Book book = new Book();
        book.setBookId(BOOK_1_ID);
       
        Author differentAuthor = new Author();
        author.setAuthorId(AUTHOR_1_ID);

        author.addBook(book);
        book.setAuthor(differentAuthor);
       
        Book differentBook = new Book();
        book.setBookId(BOOK_1_ID);
       
        differentAuthor.addBook(differentBook);

        // check one roundtrip from author
View Full Code Here

       
        BookBean bookBean = new BookBean();
        bookBean.setTitle(BOOK_1_TITLE);
        bookBean.setIsbn(BOOK_1_ISBN);
       
        Book book = Book.createBook(bookBean);
        assertTrue("isModified() should return true after creation of object "
                + " from new bean",
                book.isModified());
        assertTrue("isNew() should return true after creation of object "
                + " from new bean",
                book.isNew());
        book.setAuthor(author);
        book.save();
       
        List bookList = BookPeer.doSelect(new Criteria());
        assertTrue("Ther should be one book in DB but there are "
                + bookList.size(),
                bookList.size() == 1);
View Full Code Here

            assertTrue("authorId should not be 0 after insert",
                    author.getAuthorId() != 0);

            for (int j = 1; j <= 10; j++)
            {
                Book book = new Book();
                book.setAuthor(author);
                book.setTitle("Book " + j + " - Author " + i);
                book.setIsbn("unknown");
                book.save();
            }
        }
        // clean booleancheck table (because insert uses fixed keys)
        Criteria criteria = new Criteria();
        criteria.add(BooleanCheckPeer.TEST_KEY, (Object) null, Criteria.NOT_EQUAL);
View Full Code Here

       
        Author author = new Author();
        author.setName("Name");
        author.save();

        Book book = new Book();
        book.setTitle("title");
        book.setAuthor(author);
        book.setIsbn("ISBN");
        book.save();

        // delete without matching data
        Criteria criteria = new Criteria();
        criteria.add(
                AuthorPeer.AUTHOR_ID,
View Full Code Here

TOP

Related Classes of org.apache.torque.test.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.