Package org.apache.torque.test

Examples of org.apache.torque.test.Book


        // insert test data
        Author author = new Author();
        author.setName("Author with one book");
        author.save();
        Book book = new Book();
        book.setAuthor(author);
        book.setTitle("Book 1");
        book.setIsbn("unknown");
        book.save();
     
        author = new Author();
        author.setName("Author without book");
        author.save();

        author = new Author();
        author.setName("Author with three books");
        author.save();
        for (int bookNr = 2; bookNr <=4; bookNr++)
        {
            book = new Book();
            book.setAuthor(author);
            book.setTitle("Book " + bookNr);
            book.setIsbn("unknown");
            book.save();
        }

        // test left join
        Criteria criteria = new Criteria();
        criteria.addJoin(AuthorPeer.AUTHOR_ID, BookPeer.AUTHOR_ID,
View Full Code Here


        Criteria criteria = new Criteria();
        criteria.addAscendingOrderByColumn(BookPeer.TITLE);
        List books = MyBookPeer.doSelectJoinAuthor(criteria);
        assertTrue("books should contain 4 books but contains "
                + books.size(), books.size() == 4);
        Book bookTwo = (Book) books.get(1);
        Book bookThree = (Book) books.get(2);
        assertTrue ("the authors of BookTwo and BookThree"
                + " should point to the same instance",
                bookTwo.getAuthor() == bookThree.getAuthor());
    }
View Full Code Here

        // insert test data
        Author firstAuthor = new Author();
        firstAuthor.setName("Author 1");
        firstAuthor.save();
        Book book = new Book();
        book.setAuthor(firstAuthor);
        book.setTitle("Book 1");
        book.setIsbn("unknown");
        book.save();
           
        Author secondAuthor = new Author();
        secondAuthor.setName("Author 2");
        secondAuthor.save();
        for (int bookNr = 2; bookNr <=4; bookNr++)
        {
            book = new Book();
            book.setAuthor(secondAuthor);
            book.setTitle("Book " + bookNr);
            book.setIsbn("unknown");
            book.save();
        }
       
        // test simple ascending order by
        Criteria criteria = new Criteria();
        criteria.addAscendingOrderByColumn(BookPeer.TITLE);
View Full Code Here

       
        author = new Author();
        author.setName("NotCorrespondingName");
        author.save();
       
        Book book = new Book();
        book.setTitle("Name");
        book.setAuthor(author);
        book.setIsbn("unknown");
        book.save();
       
        Criteria criteria = new Criteria();
        criteria.addJoin(BookPeer.TITLE, AuthorPeer.NAME);
        BookPeer.addSelectColumns(criteria);
        AuthorPeer.addSelectColumns(criteria);
        // basically a BaseBookPeer.setDbName(criteria);
        // and BasePeer.doSelect(criteria);
        List villageRecords = BookPeer.doSelectVillageRecords(criteria);
        Record record = (Record) villageRecords.get(0);
        book = new Book();
        BookPeer.populateObject(record, 1, book);
        author = new Author();
        AuthorPeer.populateObject(record, BookPeer.numColumns + 1, author);

        if (book.getAuthorId() == author.getAuthorId()) {
            fail("wrong Ids read");
        }
    }
View Full Code Here

            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

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.