db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/src/rttest/org/apache/torque DataTest.java
Date Tue, 27 May 2003 20:06:06 GMT
mpoeschl    2003/05/27 13:06:06

  Modified:    src/rttest/org/apache/torque Tag: TORQUE_3_0_BRANCH
                        DataTest.java
  Added:       src/rttest/org/apache/torque/util Tag: TORQUE_3_0_BRANCH
                        CopyTest.java
  Log:
  update rttests
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.1   +112 -112  db-torque/src/rttest/org/apache/torque/util/CopyTest.java
  
  Index: CopyTest.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/util/CopyTest.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- CopyTest.java	9 Jan 2003 17:46:22 -0000	1.2
  +++ CopyTest.java	27 May 2003 20:06:06 -0000	1.2.2.1
  @@ -1,112 +1,112 @@
  -package org.apache.torque.util;
  -
  -/* ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  - *    if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - *    "Apache Turbine" must not be used to endorse or promote products
  - *    derived from this software without prior written permission. For
  - *    written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without
  - *    prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  -
  -import org.apache.torque.BaseTestCase;
  -import org.apache.torque.test.Author;
  -import org.apache.torque.test.AuthorPeer;
  -import org.apache.torque.test.Book;
  -
  -/**
  - * Test code for TorqueObject.copy().
  - *
  - * @author <a href="mailto:torque@kivus.myip.org">Rafal Maczewski</a>
  - * @version $Id $
  - */
  -public class CopyTest extends BaseTestCase
  -{
  -    /**
  -     * Creates a new instance.
  -     */
  -    public CopyTest(String name)
  -    {
  -        super(name);
  -    }
  -
  -    public void setUp()
  -    {
  -        super.setUp();
  -    }
  -
  -    /**
  -     * does some inserts.
  -     */
  -    public void testCopyObject() throws Exception
  -    {
  -		Author author = new Author();
  -		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();
  -
  -		author = AuthorPeer.retrieveByPK(author.getPrimaryKey());
  -		assertTrue("Number of books in original object should be 10, was "
  -                + author.getBooks().size(), author.getBooks().size() == 10);
  -
  -		assertTrue("Number of books after copy should be 10, was "
  -                + author.getBooks().size(), authorCopy.getBooks().size() == 10);
  -    }
  -}
  +package org.apache.torque.util;
  +
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
  +import org.apache.torque.BaseTestCase;
  +import org.apache.torque.test.Author;
  +import org.apache.torque.test.AuthorPeer;
  +import org.apache.torque.test.Book;
  +
  +/**
  + * Test code for TorqueObject.copy().
  + *
  + * @author <a href="mailto:torque@kivus.myip.org">Rafal Maczewski</a>
  + * @version $Id $
  + */
  +public class CopyTest extends BaseTestCase
  +{
  +    /**
  +     * Creates a new instance.
  +     */
  +    public CopyTest(String name)
  +    {
  +        super(name);
  +    }
  +
  +    public void setUp()
  +    {
  +        super.setUp();
  +    }
  +
  +    /**
  +     * does some inserts.
  +     */
  +    public void testCopyObject() throws Exception
  +    {
  +		Author author = new Author();
  +		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();
  +
  +		author = AuthorPeer.retrieveByPK(author.getPrimaryKey());
  +		assertTrue("Number of books in original object should be 10, was "
  +                + author.getBooks().size(), author.getBooks().size() == 10);
  +
  +		assertTrue("Number of books after copy should be 10, was "
  +                + author.getBooks().size(), authorCopy.getBooks().size() == 10);
  +    }
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.1   +52 -4     db-torque/src/rttest/org/apache/torque/DataTest.java
  
  Index: DataTest.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/rttest/org/apache/torque/DataTest.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- DataTest.java	19 Nov 2002 17:36:40 -0000	1.3
  +++ DataTest.java	27 May 2003 20:06:06 -0000	1.3.2.1
  @@ -3,7 +3,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -54,10 +54,14 @@
    * <http://www.apache.org/>.
    */
   
  -import org.apache.log4j.Category;
  -import org.apache.torque.BaseTestCase;
  +import java.util.Map;
  +import java.util.HashMap;
  +import java.util.List;
  +import java.util.Iterator;
   import org.apache.torque.test.Author;
   import org.apache.torque.test.Book;
  +import org.apache.torque.test.BookPeer;
  +import org.apache.torque.util.Criteria;
   import org.apache.torque.test.MultiPk;
   
   /**
  @@ -121,6 +125,50 @@
               MultiPk mpk = new MultiPk();
               mpk.setPrimaryKey("Svarchar:N5:Schar:");
               mpk.save();
  +        }
  +        catch (Exception ex)
  +        {
  +            ex.printStackTrace();
  +        }
  +    }
  +
  +    private static final String[] validTitles = {
  +        "Book 7 - Author 8", "Book 6 - Author 8", "Book 7 - Author 7", 
  +        "Book 6 - Author 7", "Book 7 - Author 6", "Book 6 - Author 6",
  +        "Book 7 - Author 5", "Book 6 - Author 5", "Book 7 - Author 4",
  +        "Book 6 - Author 4"};
  +
  +    /**
  +     * test limit/offset which was broken for oracle (TRQ47)
  +     */
  +    public void testLimitOffset()
  +    {
  +        Map titleMap = new HashMap();
  +        for (int j = 0; j < validTitles.length; j++) 
  +        {
  +            titleMap.put(validTitles[j], null);
  +        }
  +
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            Criteria.Criterion c = crit.getNewCriterion(BookPeer.TITLE, 
  +                    (Object) "Book 6 - Author 1", Criteria.GREATER_EQUAL);
  +            c.and(crit.getNewCriterion(BookPeer.TITLE, 
  +                    (Object) "Book 8 - Author 3", Criteria.LESS_EQUAL));
  +            crit.add(c);
  +            crit.addDescendingOrderByColumn(BookPeer.BOOK_ID);
  +            crit.setLimit(10);
  +            crit.setOffset(5);
  +            List books = BookPeer.doSelect(crit);
  +            assertTrue("List should have 10 books, not " + books.size(), 
  +                       books.size() == 10);
  +            for (Iterator i = books.iterator(); i.hasNext();) 
  +            {
  +                String title = ((Book) i.next()).getTitle();
  +                assertTrue("Incorrect title: " + title, 
  +                           titleMap.containsKey(title));
  +            }
           }
           catch (Exception ex)
           {
  
  
  

Mime
View raw message