db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: jakarta-ojb/src/test/org/apache/ojb/odmg ScrollableQueryResultsTest.java
Date Fri, 29 Nov 2002 13:54:36 GMT
arminw      2002/11/29 05:54:36

  Modified:    src/test/org/apache/ojb/broker/sequence
                        SequenceManagerTest.java
               src/test/org/apache/ojb/broker
                        MetaDataSerializationTest.java PBAwareTest.java
                        QueryTest.java
               src/test/org/apache/ojb/odmg ScrollableQueryResultsTest.java
  Log:
  update test cases
  
  Revision  Changes    Path
  1.10      +25 -26    jakarta-ojb/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java
  
  Index: SequenceManagerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SequenceManagerTest.java	23 Nov 2002 09:56:45 -0000	1.9
  +++ SequenceManagerTest.java	29 Nov 2002 13:54:36 -0000	1.10
  @@ -2,16 +2,16 @@
   
   import junit.framework.TestCase;
   import org.apache.ojb.broker.*;
  -import org.apache.ojb.broker.query.QueryByCriteria;
  -import org.apache.ojb.broker.query.Query;
  -import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
  +import org.apache.ojb.broker.query.Criteria;
  +import org.apache.ojb.broker.query.Query;
  +import org.apache.ojb.broker.query.QueryByCriteria;
   import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
   import org.apache.ojb.broker.util.sequence.SequenceConfiguration;
  -import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
   import org.apache.ojb.broker.util.sequence.SequenceManager;
  -import org.apache.ojb.broker.util.sequence.SequenceManagerFactory;
   import org.apache.ojb.broker.util.sequence.SequenceManagerException;
  +import org.apache.ojb.broker.util.sequence.SequenceManagerFactory;
  +import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
   
   import java.util.ArrayList;
   import java.util.Iterator;
  @@ -84,7 +84,6 @@
           else
           {
               // we need the SM grab size
  -            System.out.println("Prepare for sequence generation");
               SequenceConfiguration conf =
                       (SequenceConfiguration) OjbConfigurator.getInstance().getConfigurationFor(null);
               int seqGrabSize = conf.getSequenceManagerGrabSize();
  @@ -123,7 +122,7 @@
       public void testMultipleAutoincrement()
       {
           String MESSAGE = "Autoincrement field was not set: ";
  -        String name = "my test key "+System.currentTimeMillis();
  +        String name = "my test key " + System.currentTimeMillis();
           SMKey key = new SMKey();
           key.setName(name);
           PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  @@ -131,10 +130,10 @@
           broker.store(key);
   
           assertEquals("Value was not store: " + key, name, key.getName());
  -        assertNotNull(MESSAGE + key,key.getIntegerKey());
  -        assertTrue(MESSAGE + key,(key.getIntKey() != 0));
  -        assertNotNull(MESSAGE + key,key.getLongKey());
  -        assertNotNull(MESSAGE + key,key.getStringKey());
  +        assertNotNull(MESSAGE + key, key.getIntegerKey());
  +        assertTrue(MESSAGE + key, (key.getIntKey() != 0));
  +        assertNotNull(MESSAGE + key, key.getLongKey());
  +        assertNotNull(MESSAGE + key, key.getStringKey());
   //        System.out.println("## SMKey: \n"+key);
   
           Criteria cr = new Criteria();
  @@ -142,11 +141,11 @@
           Query query = new QueryByCriteria(SMKey.class, cr);
           key = (SMKey) broker.getObjectByQuery(query);
   
  -        assertEquals("Value was not store: ",name, key.getName());
  -        assertNotNull(MESSAGE + key,key.getIntegerKey());
  -        assertTrue(MESSAGE + key,(key.getIntKey() != 0));
  -        assertNotNull(MESSAGE + key,key.getLongKey());
  -        assertNotNull(MESSAGE + key,key.getStringKey());
  +        assertEquals("Value was not store: ", name, key.getName());
  +        assertNotNull(MESSAGE + key, key.getIntegerKey());
  +        assertTrue(MESSAGE + key, (key.getIntKey() != 0));
  +        assertNotNull(MESSAGE + key, key.getLongKey());
  +        assertNotNull(MESSAGE + key, key.getStringKey());
   //        System.out.println("## SMKey: \n"+key);
   
           broker.close();
  @@ -226,11 +225,11 @@
           result[4] = SequenceManagerHelper.getMaxForExtent(broker, field);
           broker.close();
           boolean bool = false;
  -        for(int i = 0; i < result.length; i++)
  +        for (int i = 0; i < result.length; i++)
           {
  -            for(int k = 0; k < result.length; k++)
  +            for (int k = 0; k < result.length; k++)
               {
  -                if(! (result[i] == result[k]))
  +                if (!(result[i] == result[k]))
                   {
                       fail(DEF_FAIL_MESSAGE);
                   }
  @@ -258,11 +257,11 @@
           result[4] = SequenceManagerHelper.getMaxForExtent(broker, field);
           broker.close();
           boolean bool = false;
  -        for(int i = 0; i < result.length; i++)
  +        for (int i = 0; i < result.length; i++)
           {
  -            for(int k = 0; k < result.length; k++)
  +            for (int k = 0; k < result.length; k++)
               {
  -                if(! (result[i] == result[k]))
  +                if (!(result[i] == result[k]))
                   {
                       fail(DEF_FAIL_MESSAGE);
                   }
  @@ -353,8 +352,8 @@
               if (listTwo.contains(listOne.get(i)))
               {
                   fail("\nFound double generated key " + listOne.get(i) +
  -                        " when generate keys for \n" + classOne + " with autoincrement field "+fieldOne+
  -                        " and \n" + classTwo + " with autoincrement field "+fieldTwo);
  +                        " when generate keys for \n" + classOne + " with autoincrement field " + fieldOne +
  +                        " and \n" + classTwo + " with autoincrement field " + fieldTwo);
               }
           }
           broker.close();
  @@ -441,7 +440,7 @@
       {
           generateKeys();
           TreeSet set = new TreeSet((List) generatedKeys.clone());
  -        if(set.isEmpty()) fail("No generated keys found");
  +        if (set.isEmpty()) fail("No generated keys found");
           int result = ((Integer) set.last()).intValue() - ((Integer) set.first()).intValue() + 1;
           assertEquals("You have lost sequence numbers", keyCount, result);
       }
  
  
  
  1.3       +84 -133   jakarta-ojb/src/test/org/apache/ojb/broker/MetaDataSerializationTest.java
  
  Index: MetaDataSerializationTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/MetaDataSerializationTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MetaDataSerializationTest.java	14 Aug 2002 13:22:28 -0000	1.2
  +++ MetaDataSerializationTest.java	29 Nov 2002 13:54:36 -0000	1.3
  @@ -1,14 +1,17 @@
   package org.apache.ojb.broker;
   
   import junit.framework.TestCase;
  -import org.apache.ojb.broker.Identity;
  -import org.apache.ojb.broker.PersistenceBroker;
  -import org.apache.ojb.broker.PersistenceBrokerFactory;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.DescriptorRepository;
  -import org.apache.ojb.broker.singlevm.PersistenceBrokerImpl;
  +import org.apache.ojb.broker.util.BrokerHelper;
   
  -import java.io.*;
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
  +import java.io.File;
  +import java.io.FileInputStream;
  +import java.io.FileOutputStream;
  +import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
   import java.util.Iterator;
   import java.util.Vector;
   
  @@ -67,80 +70,57 @@
        * test serialization and deserialisation of all ClassDescriptors in
        * Descriptor repository
        */
  -    public void testIt()
  +    public void testIt() throws Exception
       {
  -        try
  +        DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  +        Iterator iter = repository.iterator();
  +        while (iter.hasNext())
           {
  -            DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  -            Iterator iter = repository.iterator();
  -            while (iter.hasNext())
  -            {
  -                ClassDescriptor cld = (ClassDescriptor) iter.next();
  -                //System.out.println("CLD: " + cld.getClassOfObject().getName());
  -                byte[] arr = serialize(cld);
  -
  -                ClassDescriptor cld1 = deserialize(arr);
  -            }
  -
  +            ClassDescriptor cld = (ClassDescriptor) iter.next();
  +            //System.out.println("CLD: " + cld.getClassOfObject().getName());
  +            byte[] arr = serialize(cld);
   
  -        }
  -        catch (Throwable t)
  -        {
  -            fail(t.getMessage());
  +            ClassDescriptor cld1 = deserialize(arr);
           }
       }
   
       /**
        * test serialization of ClassDescriptors to disk
        */
  -    public void testToDisk()
  +    public void testToDisk() throws Exception
       {
  -        try
  -        {
  -            DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  -            Iterator iter = repository.iterator();
  -            Vector vec = new Vector();
  -            while (iter.hasNext())
  -            {
  -                vec.add(iter.next());
  -            }
  -            File outfile = new File("repository.serialized");
  -            FileOutputStream fos = new FileOutputStream(outfile);
  -            ObjectOutputStream oos = new ObjectOutputStream(fos);
  -            oos.writeObject(vec);
  -            oos.close();
  -            fos.close();
  -        }
  -        catch (Throwable t)
  -        {
  -            fail(t.getMessage());
  -        }
  +        DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  +        Iterator iter = repository.iterator();
  +        Vector vec = new Vector();
  +        while (iter.hasNext())
  +        {
  +            vec.add(iter.next());
  +        }
  +        File outfile = new File("repository.serialized");
  +        FileOutputStream fos = new FileOutputStream(outfile);
  +        ObjectOutputStream oos = new ObjectOutputStream(fos);
  +        oos.writeObject(vec);
  +        oos.close();
  +        fos.close();
       }
   
       /**
        * test deserialization of ClassDescriptors from disk
        */
  -    public void testFromDisk()
  +    public void testFromDisk() throws Exception
       {
  -        try
  -        {
  -            File infile = new File("repository.serialized");
  -            FileInputStream fis = new FileInputStream(infile);
  -            ObjectInputStream ois = new ObjectInputStream(fis);
  -            Vector vec = (Vector) ois.readObject();
  -            ois.close();
  -            fis.close();
  +        File infile = new File("repository.serialized");
  +        FileInputStream fis = new FileInputStream(infile);
  +        ObjectInputStream ois = new ObjectInputStream(fis);
  +        Vector vec = (Vector) ois.readObject();
  +        ois.close();
  +        fis.close();
   
  -            Iterator iter = vec.iterator();
  -            while (iter.hasNext())
  -            {
  -                ClassDescriptor cld = (ClassDescriptor) iter.next();
  -                //System.out.println(cld.getClassOfObject().getName());
  -            }
  -        }
  -        catch (Throwable t)
  +        Iterator iter = vec.iterator();
  +        while (iter.hasNext())
           {
  -            fail(t.getMessage());
  +            ClassDescriptor cld = (ClassDescriptor) iter.next();
  +            //System.out.println(cld.getClassOfObject().getName());
           }
       }
   
  @@ -149,101 +129,72 @@
        * test serialization and deserialisation of all ClassDescriptors in
        * Descriptor repository
        */
  -    public void testRemote()
  +    public void testRemote() throws Exception
       {
  +        if (!BrokerHelper.isRunningInServerMode())
  +        {
  +            System.out.println("The Remote Metadata test can only be run in C/S mode");
  +            return;
  +        }
  +
           ClassDescriptor cld = null;
  -        try
  +        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +        for (int i = 0; i < 5; i++)
           {
  -            PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  -            if (broker instanceof PersistenceBrokerImpl)
  -            {
  -                System.out.println("The Remote Metadata test can only be run in C/S mode");
  -                return;
  -            }
  -            else
  +            DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  +            Iterator iter = repository.iterator();
  +            while (iter.hasNext())
               {
  -                for (int i = 0; i < 5; i++)
  -                {
  -                    DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  -                    Iterator iter = repository.iterator();
  -                    while (iter.hasNext())
  -                    {
  -                        cld = (ClassDescriptor) iter.next();
  -                        //System.out.println("CLD remote: " + cld.getClassOfObject().getName());
  -
  -                        ClassDescriptor cldRemote = broker.getClassDescriptor(cld.getClassOfObject());
  -                    }
  -                }
  +                cld = (ClassDescriptor) iter.next();
  +                //System.out.println("CLD remote: " + cld.getClassOfObject().getName());
   
  +                ClassDescriptor cldRemote = broker.getClassDescriptor(cld.getClassOfObject());
               }
  -            broker.close();
  -
  -        }
  -        catch (Throwable t)
  -        {
  -            System.out.println(cld.getClassOfObject().getName());
  -            System.out.println(t.getMessage());
  -            t.printStackTrace();
  -            fail(t.getMessage());
           }
  +        broker.close();
       }
   
       /**
        * test serialization and deserialisation of all ClassDescriptors in
        * Descriptor repository
        */
  -    public void testIdentityStuff()
  +    public void testIdentityStuff() throws Exception
       {
   
  -        try
  +        if (!BrokerHelper.isRunningInServerMode())
           {
  -            PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  -            if (broker instanceof PersistenceBrokerImpl)
  -            {
  -                System.out.println("The Remote Identity test can only be run in C/S mode");
  -                return;
  -            }
  -            else
  +            System.out.println("The Remote Metadata test can only be run in C/S mode");
  +            return;
  +        }
  +
  +        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +        DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  +        Iterator iter = repository.iterator();
  +        while (iter.hasNext())
  +        {
  +            ClassDescriptor cld = (ClassDescriptor) iter.next();
  +            //System.out.println("CLD: " + cld.getClassOfObject().getName());
  +            Class c = cld.getClassOfObject();
  +            if (!c.isInterface())
               {
   
  -                DescriptorRepository repository = DescriptorRepository.getDefaultInstance();
  -                Iterator iter = repository.iterator();
  -                while (iter.hasNext())
  +                Object o = null;
  +                try
  +                {
  +                    o = c.newInstance();
  +                    Identity oid = new Identity(o);
  +                    //System.out.println(oid.toString());
  +                }
  +                catch (InstantiationException e)
  +                {
  +                }
  +                catch (IllegalAccessException e)
                   {
  -                    ClassDescriptor cld = (ClassDescriptor) iter.next();
  -                    //System.out.println("CLD: " + cld.getClassOfObject().getName());
  -                    Class c = cld.getClassOfObject();
  -                    if (!c.isInterface())
  -                    {
  -
  -                        Object o = null;
  -                        try
  -                        {
  -                            o = c.newInstance();
  -                            Identity oid = new Identity(o);
  -                            //System.out.println(oid.toString());
  -                        }
  -                        catch (InstantiationException e)
  -                        {
  -                        }
  -                        catch (IllegalAccessException e)
  -                        {
  -                        }
  -
  -                    }
                   }
  -
               }
  -            broker.close();
  -        }
  -        catch (Throwable t)
  -        {
  -            System.out.println(t.getMessage());
  -            t.printStackTrace();
  -            fail(t.getMessage());
           }
  +        broker.close();
       }
  -
   
       byte[] serialize(ClassDescriptor cld) throws Exception
       {
  
  
  
  1.5       +14 -15    jakarta-ojb/src/test/org/apache/ojb/broker/PBAwareTest.java
  
  Index: PBAwareTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/PBAwareTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PBAwareTest.java	8 Nov 2002 13:55:47 -0000	1.4
  +++ PBAwareTest.java	29 Nov 2002 13:54:36 -0000	1.5
  @@ -1,9 +1,10 @@
   package org.apache.ojb.broker;
  +
   import junit.framework.TestCase;
  -import org.apache.ojb.broker.singlevm.PersistenceBrokerImpl;
  +import org.apache.ojb.broker.util.BrokerHelper;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   
  -/** 
  +/**
    * This TestClass tests OJB facilities to work with persistence
    * aware instances.
    */
  @@ -11,9 +12,10 @@
   {
       public static void main(String[] args)
       {
  -        String[] arr = { CLASS.getName()};
  +        String[] arr = {CLASS.getName()};
           junit.textui.TestRunner.main(arr);
       }
  +
       PersistenceBroker broker;
       private static Class CLASS = AutomaticForeignKeys.class;
   
  @@ -56,12 +58,12 @@
           }
       }
   
  -    /** 
  +    /**
        * tests the callbacks beforeStore() and afterStore().
        */
       public void testStoreCallbacks()
       {
  -        if (broker instanceof PersistenceBrokerImpl)
  +        if (!BrokerHelper.isRunningInServerMode())
           {
               PBAwareEntity obj = new PBAwareEntity();
               assertEquals(false, obj.getCalledBeforeStore());
  @@ -73,16 +75,16 @@
           else
           {
               LoggerFactory.getDefaultLogger().info(
  -                "callbacks only work within singevm mode");
  +                    "callbacks only work within singevm mode");
           }
       }
   
  -    /** 
  +    /**
        * tests the callbacks beforeDelete() and afterDelete().
        */
       public void testDeleteCallbacks()
       {
  -        if (broker instanceof PersistenceBrokerImpl)
  +        if (!BrokerHelper.isRunningInServerMode())
           {
   
               PBAwareEntity obj = new PBAwareEntity();
  @@ -95,17 +97,16 @@
           else
           {
               LoggerFactory.getDefaultLogger().info(
  -                "callbacks only work within singevm mode");
  +                    "callbacks only work within singevm mode");
           }
  -
       }
   
  -    /** 
  +    /**
        * tests the callback afterLookup()
        */
       public void testLookupCallback()
       {
  -        if (broker instanceof PersistenceBrokerImpl)
  +        if (!BrokerHelper.isRunningInServerMode())
           {
   
               PBAwareEntity obj = new PBAwareEntity();
  @@ -120,9 +121,7 @@
           else
           {
               LoggerFactory.getDefaultLogger().info(
  -                "callbacks only work within singevm mode");
  +                    "callbacks only work within singevm mode");
           }
  -
       }
  -
   }
  
  
  
  1.15      +649 -648  jakarta-ojb/src/test/org/apache/ojb/broker/QueryTest.java
  
  Index: QueryTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/QueryTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- QueryTest.java	8 Nov 2002 16:45:08 -0000	1.14
  +++ QueryTest.java	29 Nov 2002 13:54:36 -0000	1.15
  @@ -1,12 +1,5 @@
   package org.apache.ojb.broker;
   
  -import java.util.ArrayList;
  -import java.util.Collection;
  -import java.util.HashSet;
  -import java.util.Iterator;
  -import java.util.Set;
  -import java.util.Vector;
  -
   import junit.framework.TestCase;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.query.Criteria;
  @@ -14,7 +7,14 @@
   import org.apache.ojb.broker.query.QueryByCriteria;
   import org.apache.ojb.broker.query.QueryFactory;
   import org.apache.ojb.broker.query.ReportQueryByCriteria;
  -import org.apache.ojb.broker.singlevm.PersistenceBrokerImpl;
  +import org.apache.ojb.broker.util.BrokerHelper;
  +
  +import java.util.ArrayList;
  +import java.util.Collection;
  +import java.util.HashSet;
  +import java.util.Iterator;
  +import java.util.Set;
  +import java.util.Vector;
   
   /**
    * Testing the query API
  @@ -22,36 +22,36 @@
   public class QueryTest extends TestCase
   {
   
  -	PersistenceBroker broker;
  +    PersistenceBroker broker;
  +
  +    private static Class CLASS = QueryTest.class;
  +
  +    /**
  +     * BrokerTests constructor comment.
  +     * @param name java.lang.String
  +     */
  +    public QueryTest(String name)
  +    {
  +        super(name);
  +    }
   
  -	private static Class CLASS = QueryTest.class;
  +    /**
  +     * Insert the method's description here.
  +     * Creation date: (23.12.2000 18:30:38)
  +     * @param args java.lang.String[]
  +     */
  +    public static void main(String[] args)
  +    {
  +        String[] arr = {CLASS.getName()};
  +        junit.textui.TestRunner.main(arr);
  +    }
   
  -	/**
  -	 * BrokerTests constructor comment.
  -	 * @param name java.lang.String
  -	 */
  -	public QueryTest(String name)
  -	{
  -		super(name);
  -	}
  -
  -	/**
  -	 * Insert the method's description here.
  -	 * Creation date: (23.12.2000 18:30:38)
  -	 * @param args java.lang.String[]
  -	 */
  -	public static void main(String[] args)
  -	{
  -		String[] arr = { CLASS.getName()};
  -		junit.textui.TestRunner.main(arr);
  -	}
  -
  -	/**
  -	 * Insert the method's description here.
  -	 * Creation date: (06.12.2000 21:58:53)
  -	 */
  -	public void setUp()
  -	{
  +    /**
  +     * Insert the method's description here.
  +     * Creation date: (06.12.2000 21:58:53)
  +     */
  +    public void setUp()
  +    {
           try
           {
               broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  @@ -59,404 +59,404 @@
           catch (PBFactoryException e)
           {
           }
  -	}
  +    }
   
  -	/**
  -	 * Insert the method's description here.
  -	 * Creation date: (06.12.2000 21:59:14)
  -	 */
  -	public void tearDown()
  -	{
  -		broker.close();
  -	}
  -
  -	/**
  -	 * test EqualTo Criteria
  -	 */
  -	public void testEqualCriteria()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addEqualTo("firstname", "tom");
  -			Query q = QueryFactory.newQuery(Person.class, crit);
  -
  -			Collection results = broker.getCollectionByQuery(q);
  -			assertNotNull(results);
  -			assertTrue(results.size() > 0);
  -		}
  -		catch (Throwable t)
  -		{
  -            t.printStackTrace();
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * test Subquery
  -	 * get all product groups without articles
  +    /**
  +     * Insert the method's description here.
  +     * Creation date: (06.12.2000 21:59:14)
  +     */
  +    public void tearDown()
  +    {
  +        broker.close();
  +    }
  +
  +    /**
  +     * test EqualTo Criteria
  +     */
  +    public void testEqualCriteria()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addEqualTo("firstname", "tom");
  +            Query q = QueryFactory.newQuery(Person.class, crit);
  +
  +            Collection results = broker.getCollectionByQuery(q);
  +            assertNotNull(results);
  +            assertTrue(results.size() > 0);
  +        }
  +        catch (Throwable t)
  +        {
  +            t.printStackTrace();
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * test Subquery
  +     * get all product groups without articles
        *
        * test may fail if db does not support sub queries
  -	 */
  -	public void testSubQuery2()
  -	{
  -		Collection results = null;
  -		try
  -		{
  -			ReportQueryByCriteria subQuery;
  -			Criteria subCrit = new Criteria();
  -			Criteria crit = new Criteria();
  -
  -			subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
  -			subQuery.setColumns(new String[] { "productGroupId" });
  -			subQuery.setDistinct(true);
  -			
  -			crit.addNotIn("groupId", subQuery);
  -			Query q = QueryFactory.newQuery(ProductGroup.class, crit);
  -
  -			results = broker.getCollectionByQuery(q);
  -			assertNotNull(results);
  -			System.out.println("*** Found " + results.size() + " empty ProductGroups ***");
  +     */
  +    public void testSubQuery2()
  +    {
  +        Collection results = null;
  +        try
  +        {
  +            ReportQueryByCriteria subQuery;
  +            Criteria subCrit = new Criteria();
  +            Criteria crit = new Criteria();
  +
  +            subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
  +            subQuery.setColumns(new String[]{"productGroupId"});
  +            subQuery.setDistinct(true);
  +
  +            crit.addNotIn("groupId", subQuery);
  +            Query q = QueryFactory.newQuery(ProductGroup.class, crit);
  +
  +            results = broker.getCollectionByQuery(q);
  +            assertNotNull(results);
  +            System.out.println("*** Found " + results.size() + " empty ProductGroups ***");
   //			assertTrue(results.size() == 6);
  -		}
  -		catch (Throwable t)
  -		{
  +        }
  +        catch (Throwable t)
  +        {
               System.err.println("The DB may not support SubQueries");
               t.printStackTrace();
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * test Subquery
  -	 * get all articles with price > avg(price)
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * test Subquery
  +     * get all articles with price > avg(price)
        * PROBLEM: avg(price) is NOT extent aware !!
  -     * 
  +     *
        * test may fail if db does not support sub queries
  -	 */
  -	public void testSubQuery1()
  -	{
  -		try
  -		{
  -			ReportQueryByCriteria subQuery;
  -			Criteria subCrit = new Criteria();
  -			Criteria crit = new Criteria();
  -
  -			subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
  -			subQuery.setColumns(new String[] { "avg(price)" });
  -			
  -			crit.addGreaterOrEqualThan("price", subQuery);
  -			Query q = QueryFactory.newQuery(Article.class, crit);
  -
  -			Collection results = broker.getCollectionByQuery(q);
  -			assertNotNull(results);
  -			assertTrue(results.size() > 0);
  -		}
  -		catch (Throwable t)
  -		{
  +     */
  +    public void testSubQuery1()
  +    {
  +        try
  +        {
  +            ReportQueryByCriteria subQuery;
  +            Criteria subCrit = new Criteria();
  +            Criteria crit = new Criteria();
  +
  +            subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
  +            subQuery.setColumns(new String[]{"avg(price)"});
  +
  +            crit.addGreaterOrEqualThan("price", subQuery);
  +            Query q = QueryFactory.newQuery(Article.class, crit);
  +
  +            Collection results = broker.getCollectionByQuery(q);
  +            assertNotNull(results);
  +            assertTrue(results.size() > 0);
  +        }
  +        catch (Throwable t)
  +        {
               System.err.println("The DB may not support SubQueries");
               t.printStackTrace();
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * test Like Criteria
  -	 */
  -	public void testLikeCriteria()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addLike("firstname", "%o%");
  -			Query q = QueryFactory.newQuery(Person.class, crit);
  -
  -			Collection results = broker.getCollectionByQuery(q);
  -			assertNotNull(results);
  -			assertTrue(results.size() > 0);
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * test Null Criteria
  -	 */
  -	public void testNullCriteria()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addIsNull("firstname");
  -			Query q = QueryFactory.newQuery(Person.class, crit);
  -
  -			Collection results = broker.getCollectionByQuery(q);
  -			assertNotNull(results);
  -			assertTrue(results.size() == 0);
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * test Between Criteria
  -	 */
  -	public void testBetweenCriteria()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addBetween("id", new Integer(1), new Integer(5));
  -			Query q = QueryFactory.newQuery(Person.class, crit);
  -
  -			Collection results = broker.getCollectionByQuery(q);
  -			assertNotNull(results);
  -			assertTrue(results.size() == 5);
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * test In Criteria
  -	 */
  -	public void testInCriteria()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			Collection ids = new Vector();
  -			ids.add(new Integer(1));
  -			ids.add(new Integer(3));
  -			ids.add(new Integer(5));
  -
  -			crit.addIn("id", ids);
  -			Query q = QueryFactory.newQuery(Person.class, crit);
  -
  -			Collection results = broker.getCollectionByQuery(q);
  -			assertNotNull(results);
  -			assertTrue(results.size() == 3);
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * Single Path Expression
  -	 */
  -	public void testPathExpressions()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addEqualTo("productGroup.groupName", "Liquors");
  -			Query q = QueryFactory.newQuery(Article.class, crit);
  -			//System.out.println(q.toString());
  -
  -			Collection results = broker.getCollectionByQuery(q);
  -			//System.out.println(results.toString());
  -			assertNotNull(results);
  -			assertTrue(results.size() > 0);
  -
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * Multi Path Expression over decomposed m:n
  -	 */
  -	public void testPathExpressionsMtoNDecomposed()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addEqualTo("roles.project.title", "HSQLDB");
  -			// use decomposed m:n
  -			Query q = QueryFactory.newQuery(Person.class, crit);
  -
  -			Collection results = broker.getCollectionByQuery(q);
  -			assertNotNull(results);
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * Multi Path Expression over nondecomposed m:n
  -	 */
  -	public void testPathExpressionsMtoN()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addEqualTo("projects.title", "HSQLDB"); // direct m:n
  -			Query q = QueryFactory.newQuery(Person.class, crit);
  -
  -			Collection results = broker.getCollectionByQuery(q);
  -			assertNotNull(results);
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * Simple ReportQuery returning rows with 2 columns of Person
  -	 */
  -	public void testReportQuery()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			Collection results = new Vector();
  -			crit.addLike("firstname", "%o%");
  -			ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit);
  -			q.setColumns(new String[] { "id", "firstname" });
  -
  -			Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -			assertNotNull(iter);
  -			while (iter.hasNext())
  -			{
  -				results.add(iter.next());
  -			}
  -			assertTrue(results.size() > 0);
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * ReportQuery returning rows with some "Liquor" data ordered by price
  -	 */
  -	public void testReportQueryOrderBy()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			Collection results = new Vector();
  -			crit.addEqualTo("productGroup.groupName", "Liquors");
  -			ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class, crit);
  -			q.setColumns(new String[] { "articleId", "articleName", "price" });
  -			crit.addOrderByAscending("price");
  -
  -			Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -			assertNotNull(iter);
  -			while (iter.hasNext())
  -			{
  -				results.add(iter.next());
  -			}
  -			assertTrue(results.size() > 0);
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * ReportQuery returning rows with summed stock and price per article group
  -	 */
  -	public void testReportQueryGroupBy()
  -	{
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			Collection results = new Vector();
  -			ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit);
  -			q.setColumns(
  -				new String[] { "groupName", "sum(allArticlesInGroup.stock)", "sum(allArticlesInGroup.price)" });
  -			crit.addGroupBy("groupName");
  -
  -			Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -			assertNotNull(iter);
  -			while (iter.hasNext())
  -			{
  -				results.add(iter.next());
  -			}
  -			assertTrue(results.size() > 0);
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * Read a CD and then read the ProductGroup for the CD
  -	 */
  -	public void testInversePathExpression()
  -	{
  -
  -		try
  -		{
  -			QueryByCriteria query;
  -			Criteria crit;
  -			CdArticle cd;
  -			ProductGroupProxy pg, cdPg;
  -
  -			crit = new Criteria();
  -			crit.addEqualTo("articleId", new Integer(200));
  -			query = new QueryByCriteria(CdArticle.class, crit);
  -			cd = (CdArticle) broker.getObjectByQuery(query);
  -			cdPg = (ProductGroupProxy) cd.getProductGroup();
  -
  -			crit = new Criteria();
  -			crit.addEqualTo("allArticlesInGroup.articleId", new Integer(cd.getArticleId()));
  -			query = new QueryByCriteria(ProductGroup.class, crit);
  -			query.addPathClass("allArticlesInGroup", CdArticle.class);
  -			pg = (ProductGroupProxy) broker.getObjectByQuery(query);
  -
  -			// this test can only succeed in singlevm mode:
  -			if (broker instanceof PersistenceBrokerImpl)
  -			{
  -				assertTrue("ProductGroups should be the same", cdPg.getRealSubject() == pg.getRealSubject());
  -			}
  -		}
  -		catch (Throwable t)
  -		{
  -			fail(t.getMessage());
  -		}
  +            fail(t.getMessage());
  +        }
  +    }
   
  -	}
  +    /**
  +     * test Like Criteria
  +     */
  +    public void testLikeCriteria()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addLike("firstname", "%o%");
  +            Query q = QueryFactory.newQuery(Person.class, crit);
  +
  +            Collection results = broker.getCollectionByQuery(q);
  +            assertNotNull(results);
  +            assertTrue(results.size() > 0);
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * test Null Criteria
  +     */
  +    public void testNullCriteria()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addIsNull("firstname");
  +            Query q = QueryFactory.newQuery(Person.class, crit);
  +
  +            Collection results = broker.getCollectionByQuery(q);
  +            assertNotNull(results);
  +            assertTrue(results.size() == 0);
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * test Between Criteria
  +     */
  +    public void testBetweenCriteria()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addBetween("id", new Integer(1), new Integer(5));
  +            Query q = QueryFactory.newQuery(Person.class, crit);
  +
  +            Collection results = broker.getCollectionByQuery(q);
  +            assertNotNull(results);
  +            assertTrue(results.size() == 5);
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * test In Criteria
  +     */
  +    public void testInCriteria()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            Collection ids = new Vector();
  +            ids.add(new Integer(1));
  +            ids.add(new Integer(3));
  +            ids.add(new Integer(5));
  +
  +            crit.addIn("id", ids);
  +            Query q = QueryFactory.newQuery(Person.class, crit);
  +
  +            Collection results = broker.getCollectionByQuery(q);
  +            assertNotNull(results);
  +            assertTrue(results.size() == 3);
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Single Path Expression
  +     */
  +    public void testPathExpressions()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addEqualTo("productGroup.groupName", "Liquors");
  +            Query q = QueryFactory.newQuery(Article.class, crit);
  +            //System.out.println(q.toString());
  +
  +            Collection results = broker.getCollectionByQuery(q);
  +            //System.out.println(results.toString());
  +            assertNotNull(results);
  +            assertTrue(results.size() > 0);
  +
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Multi Path Expression over decomposed m:n
  +     */
  +    public void testPathExpressionsMtoNDecomposed()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addEqualTo("roles.project.title", "HSQLDB");
  +            // use decomposed m:n
  +            Query q = QueryFactory.newQuery(Person.class, crit);
  +
  +            Collection results = broker.getCollectionByQuery(q);
  +            assertNotNull(results);
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Multi Path Expression over nondecomposed m:n
  +     */
  +    public void testPathExpressionsMtoN()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addEqualTo("projects.title", "HSQLDB"); // direct m:n
  +            Query q = QueryFactory.newQuery(Person.class, crit);
  +
  +            Collection results = broker.getCollectionByQuery(q);
  +            assertNotNull(results);
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Simple ReportQuery returning rows with 2 columns of Person
  +     */
  +    public void testReportQuery()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            Collection results = new Vector();
  +            crit.addLike("firstname", "%o%");
  +            ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit);
  +            q.setColumns(new String[]{"id", "firstname"});
  +
  +            Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +            assertNotNull(iter);
  +            while (iter.hasNext())
  +            {
  +                results.add(iter.next());
  +            }
  +            assertTrue(results.size() > 0);
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * ReportQuery returning rows with some "Liquor" data ordered by price
  +     */
  +    public void testReportQueryOrderBy()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            Collection results = new Vector();
  +            crit.addEqualTo("productGroup.groupName", "Liquors");
  +            ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class, crit);
  +            q.setColumns(new String[]{"articleId", "articleName", "price"});
  +            crit.addOrderByAscending("price");
  +
  +            Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +            assertNotNull(iter);
  +            while (iter.hasNext())
  +            {
  +                results.add(iter.next());
  +            }
  +            assertTrue(results.size() > 0);
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * ReportQuery returning rows with summed stock and price per article group
  +     */
  +    public void testReportQueryGroupBy()
  +    {
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            Collection results = new Vector();
  +            ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit);
  +            q.setColumns(
  +                    new String[]{"groupName", "sum(allArticlesInGroup.stock)", "sum(allArticlesInGroup.price)"});
  +            crit.addGroupBy("groupName");
  +
  +            Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +            assertNotNull(iter);
  +            while (iter.hasNext())
  +            {
  +                results.add(iter.next());
  +            }
  +            assertTrue(results.size() > 0);
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Read a CD and then read the ProductGroup for the CD
  +     */
  +    public void testInversePathExpression()
  +    {
  +
  +        try
  +        {
  +            QueryByCriteria query;
  +            Criteria crit;
  +            CdArticle cd;
  +            ProductGroupProxy pg, cdPg;
  +
  +            crit = new Criteria();
  +            crit.addEqualTo("articleId", new Integer(200));
  +            query = new QueryByCriteria(CdArticle.class, crit);
  +            cd = (CdArticle) broker.getObjectByQuery(query);
  +            cdPg = (ProductGroupProxy) cd.getProductGroup();
  +
  +            crit = new Criteria();
  +            crit.addEqualTo("allArticlesInGroup.articleId", new Integer(cd.getArticleId()));
  +            query = new QueryByCriteria(ProductGroup.class, crit);
  +            query.addPathClass("allArticlesInGroup", CdArticle.class);
  +            pg = (ProductGroupProxy) broker.getObjectByQuery(query);
  +
  +            // this test can only succeed in singlevm mode:
  +            if (!BrokerHelper.isRunningInServerMode())
  +            {
  +                assertTrue("ProductGroups should be the same", cdPg.getRealSubject() == pg.getRealSubject());
  +            }
  +        }
  +        catch (Throwable t)
  +        {
  +            fail(t.getMessage());
  +        }
  +
  +    }
   
       /**
        * prefetch Articles for ProductGroupsWithArray,
        * Does not yet work with Arrays
  -     */ 
  +     */
       public void tesXPrefetchedArraySingleKey()
  -    {     
  +    {
           fail("Prefetch does not yet work with arrays");
  -               
  -        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroupWithArray.class); 
  -        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class); 
  +
  +        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroupWithArray.class);
  +        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
           Class productGroupProxy = cldProductGroup.getProxyClass();
           Class articleProxy = cldArticle.getProxyClass();
  -      
  +
           try
  -        {          
  +        {
               //
               // use ProductGroup and Articles with disabled Proxy
  -            //           
  +            //
               broker.clearCache();
               cldProductGroup.setProxyClassName(null);
               cldArticle.setProxyClassName(null);
  -            
  +
               Criteria crit = new Criteria();
               crit.addLessOrEqualThan("groupId", new Integer(5));
               crit.addOrderByDescending("groupId");
  @@ -466,13 +466,13 @@
               Collection results = broker.getCollectionByQuery(q);
               assertNotNull(results);
               assertTrue(results.size() > 0);
  -            ProductGroupWithArray pg = (ProductGroupWithArray)results.toArray()[0];
  +            ProductGroupWithArray pg = (ProductGroupWithArray) results.toArray()[0];
               int articleSize = pg.getAllArticles().length;
               String articleString = pg.getAllArticles().toString();
   
               //
               // use ProductGroupWithArray and Articles with original Proxy settings
  -            // 
  +            //
               broker.clearCache();
               cldProductGroup.setProxyClassName(productGroupProxy.getName());
               cldArticle.setProxyClassName(articleProxy.getName());
  @@ -481,38 +481,38 @@
               crit.addEqualTo("groupId", new Integer(5));
               q = QueryFactory.newQuery(ProductGroupWithArray.class, crit);
               results = broker.getCollectionByQuery(q);
  -            ProductGroupWithArray pg2 = (ProductGroupWithArray)results.toArray()[0];
  +            ProductGroupWithArray pg2 = (ProductGroupWithArray) results.toArray()[0];
               int articleSize2 = pg2.getAllArticles().length;
               String articleString2 = pg2.getAllArticles().toString();
  -        
  +
  +            //
  +            // compare prefetched and 'normal' data
               //
  -            // compare prefetched and 'normal' data 
  -            //     
  -            assertEquals("Check size",articleSize,articleSize2);
  -            assertEquals("Check content",articleString,articleString2);
  +            assertEquals("Check size", articleSize, articleSize2);
  +            assertEquals("Check content", articleString, articleString2);
           }
           catch (Throwable t)
           {
               t.printStackTrace();
               fail(t.getMessage());
  -        }        
  -    }    
  -    
  -	/**
  +        }
  +    }
  +
  +    /**
        * prefetch Articles for ProductGroups
        */
       public void testPrefetchedCollectionSingleKey()
  -    { 
  -        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class); 
  -        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class); 
  +    {
  +        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
  +        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
           Class productGroupProxy = cldProductGroup.getProxyClass();
           Class articleProxy = cldArticle.getProxyClass();
  -        
  +
           try
  -        {          
  +        {
               //
               // use ProductGroup and Articles with disabled Proxy
  -            //           
  +            //
               broker.clearCache();
               cldProductGroup.setProxyClass(null);
               cldProductGroup.setProxyClassName(null);
  @@ -520,7 +520,7 @@
               cldArticle.setProxyClassName(null);
               broker.setClassDescriptor(cldProductGroup);
               broker.setClassDescriptor(cldArticle);
  -            
  +
               Criteria crit = new Criteria();
               crit.addLessOrEqualThan("groupId", new Integer(5));
               crit.addOrderByDescending("groupId");
  @@ -530,13 +530,13 @@
               Collection results = broker.getCollectionByQuery(q);
               assertNotNull(results);
               assertTrue(results.size() > 0);
  -            InterfaceProductGroup pg = (InterfaceProductGroup)results.toArray()[0];
  +            InterfaceProductGroup pg = (InterfaceProductGroup) results.toArray()[0];
               int articleSize = pg.getAllArticles().size();
               String articleString = pg.getAllArticles().toString();
   
               //
               // use ProductGroup and Articles with original Proxy settings
  -            // 
  +            //
               broker.clearCache();
               cldProductGroup.setProxyClass(productGroupProxy);
               cldProductGroup.setProxyClassName(productGroupProxy.getName());
  @@ -550,128 +550,128 @@
               crit.addEqualTo("groupId", new Integer(5));
               q = QueryFactory.newQuery(ProductGroup.class, crit);
               results = broker.getCollectionByQuery(q);
  -            InterfaceProductGroup pg2 = (InterfaceProductGroup)results.toArray()[0];
  +            InterfaceProductGroup pg2 = (InterfaceProductGroup) results.toArray()[0];
               int articleSize2 = pg2.getAllArticles().size();
               String articleString2 = pg2.getAllArticles().toString();
  -        
  +
               //
  -            // compare prefetched and 'normal' data 
  -            //     
  -            assertEquals("Check size",articleSize,articleSize2);
  -            assertEquals("Check content",articleString,articleString2);
  +            // compare prefetched and 'normal' data
  +            //
  +            assertEquals("Check size", articleSize, articleSize2);
  +            assertEquals("Check content", articleString, articleString2);
  +        }
  +        catch (Throwable t)
  +        {
  +            t.printStackTrace();
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Test nested joins using pathExpressions
  +     */
  +    public void testNestedJoins()
  +    {
  +        ArrayList list = new java.util.ArrayList();
  +
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit, true);
  +
  +            q.setColumns(new String[]{"roles.roleName", "roles.project.title", "firstname", });
  +
  +            Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +            while (iter.hasNext())
  +            {
  +                list.add(iter.next());
  +            }
  +
  +            assertTrue(list.size() > 0);
  +
  +        }
  +        catch (Throwable t)
  +        {
  +            t.printStackTrace();
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Test multiple non nested joins using pathExpressions
  +     */
  +    public void testMultipleJoins()
  +    {
  +        ArrayList list = new java.util.ArrayList();
  +
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            ReportQueryByCriteria q = QueryFactory.newReportQuery(Role.class, crit, true);
  +
  +            q.setColumns(new String[]{"roleName", "project.title", "person.firstname", });
  +
  +            Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +            while (iter.hasNext())
  +            {
  +                list.add(iter.next());
  +            }
  +
  +            assertTrue(list.size() > 0);
  +
  +        }
  +        catch (Throwable t)
  +        {
  +            t.printStackTrace();
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Test nested joins using pathExpressions
  +     * *** Fails under hsqldb because of join using multiple keys ***
	 */
  +    public void tesXNestedJoins2()
  +    {
  +        ArrayList list = new java.util.ArrayList();
  +
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            ReportQueryByCriteria q = QueryFactory.newReportQuery(Task.class, crit);
  +
  +            q.setColumns(new String[]{"role.roleName", "role.project.title", "role.person.firstname", });
  +
  +            Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +            while (iter.hasNext())
  +            {
  +                list.add(iter.next());
  +            }
  +
  +            assertTrue(list.size() > 0);
  +
           }
           catch (Throwable t)
           {
               t.printStackTrace();
               fail(t.getMessage());
  -        }        
  -    }    
  -
  -	/**
  -	 * Test nested joins using pathExpressions
  -	 */
  -	public void testNestedJoins()
  -	{
  -		ArrayList list = new java.util.ArrayList();
  -
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit, true);
  -
  -			q.setColumns(new String[] { "roles.roleName", "roles.project.title", "firstname", });
  -
  -			Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -			while (iter.hasNext())
  -			{
  -				list.add(iter.next());
  -			}
  -
  -			assertTrue(list.size() > 0);
  -
  -		}
  -		catch (Throwable t)
  -		{
  -			t.printStackTrace();
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * Test multiple non nested joins using pathExpressions
  -	 */
  -	public void testMultipleJoins()
  -	{
  -		ArrayList list = new java.util.ArrayList();
  -
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			ReportQueryByCriteria q = QueryFactory.newReportQuery(Role.class, crit, true);
  -
  -			q.setColumns(new String[] { "roleName", "project.title", "person.firstname", });
  -
  -			Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -			while (iter.hasNext())
  -			{
  -				list.add(iter.next());
  -			}
  -
  -			assertTrue(list.size() > 0);
  -
  -		}
  -		catch (Throwable t)
  -		{
  -			t.printStackTrace();
  -			fail(t.getMessage());
  -		}
  -	}
  -
  -	/**
  -	 * Test nested joins using pathExpressions
  -	 * *** Fails under hsqldb because of join using multiple keys ***
	 */
  -	public void tesXNestedJoins2()
  -	{
  -		ArrayList list = new java.util.ArrayList();
  -
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			ReportQueryByCriteria q = QueryFactory.newReportQuery(Task.class, crit);
  -
  -			q.setColumns(new String[] { "role.roleName", "role.project.title", "role.person.firstname", });
  -
  -			Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -			while (iter.hasNext())
  -			{
  -				list.add(iter.next());
  -			}
  -
  -			assertTrue(list.size() > 0);
  -
  -		}
  -		catch (Throwable t)
  -		{
  -			t.printStackTrace();
  -			fail(t.getMessage());
  -		}
  -	}
  +        }
  +    }
   
  -	/**
  +    /**
        * prefetch ProductGroups for Articles
        */
       public void testPrefetchedReferencesSingleKey()
  -    { 
  -        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class); 
  -        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class); 
  +    {
  +        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
  +        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
           Class productGroupProxy = cldProductGroup.getProxyClass();
           Class articleProxy = cldArticle.getProxyClass();
  -        
  +
           try
  -        {          
  +        {
               //
               // use ProductGroup and Articles with disabled Proxy
  -            //           
  +            //
               broker.clearCache();
               cldProductGroup.setProxyClass(null);
               cldProductGroup.setProxyClassName(null);
  @@ -679,7 +679,7 @@
               cldArticle.setProxyClassName(null);
               broker.setClassDescriptor(cldProductGroup);
               broker.setClassDescriptor(cldArticle);
  -            
  +
               Criteria crit = new Criteria();
               crit.addNotNull("productGroupId");
               crit.addLessOrEqualThan("productGroupId", new Integer(5));
  @@ -691,17 +691,17 @@
               Set pgs = new HashSet();
               Iterator iter = results.iterator();
               while (iter.hasNext())
  -			{
  -				InterfaceArticle a = (InterfaceArticle)iter.next();
  -				pgs.add(a.getProductGroup().getName());					
  -			}
  -            
  +            {
  +                InterfaceArticle a = (InterfaceArticle) iter.next();
  +                pgs.add(a.getProductGroup().getName());
  +            }
  +
               assertTrue(pgs.size() > 0);
               String pgsString = pgs.toString();
   
               //
               // use ProductGroup and Articles with original Proxy settings
  -            // 
  +            //
               broker.clearCache();
               cldProductGroup.setProxyClass(productGroupProxy);
               cldProductGroup.setProxyClassName(productGroupProxy.getName());
  @@ -721,132 +721,133 @@
               Set pgs2 = new HashSet();
               iter = results.iterator();
               while (iter.hasNext())
  -			{
  -				InterfaceArticle a = (InterfaceArticle)iter.next();
  -				pgs2.add(a.getProductGroup().getName());					
  -			}
  - 
  +            {
  +                InterfaceArticle a = (InterfaceArticle) iter.next();
  +                pgs2.add(a.getProductGroup().getName());
  +            }
  +
               assertTrue(pgs2.size() > 0);
               String pgsString2 = pgs2.toString();
  -       
  +
               //
  -            // compare prefetched and 'normal' data 
  -            //     
  -            assertEquals("Check size",pgs.size(),pgs2.size());
  -            assertEquals("Check content",pgsString,pgsString2);
  +            // compare prefetched and 'normal' data
  +            //
  +            assertEquals("Check size", pgs.size(), pgs2.size());
  +            assertEquals("Check content", pgsString, pgsString2);
           }
           catch (Throwable t)
           {
               t.printStackTrace();
               fail(t.getMessage());
  -        }        
  -    }    
  +        }
  +    }
   
  -	/**
  -	 * test PathExpression pointing to abstract class
  -	 * BRJ: throws a NullPointerException
	 */
  -	public void tesXPathExpressionAbstract()
  -	{
  -		ArrayList list = new java.util.ArrayList();
  +    /**
  +     * test PathExpression pointing to abstract class
  +     * BRJ: throws a NullPointerException
	 */
  +    public void tesXPathExpressionAbstract()
  +    {
  +        ArrayList list = new java.util.ArrayList();
   
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addEqualTo("groupId", new Integer(5));
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addEqualTo("groupId", new Integer(5));
   
  -			ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroupWithAbstractArticles.class, crit, true);
  -			q.setColumns(new String[] { "groupId", "groupName", "allArticlesInGroup.articleId","allArticlesInGroup.articleName"});
  +            ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroupWithAbstractArticles.class, crit, true);
  +            q.setColumns(new String[]{"groupId", "groupName", "allArticlesInGroup.articleId", "allArticlesInGroup.articleName"});
   
  -			Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -			while (iter.hasNext())
  -			{
  -				list.add(iter.next());
  -			}
  +            Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +            while (iter.hasNext())
  +            {
  +                list.add(iter.next());
  +            }
   
  -			// 7 Articles, 2 Books, 3 Cds
  +            // 7 Articles, 2 Books, 3 Cds
               //	assertEquals("check size", list.size(), 12);
               //
               //  BRJ: path expression is not yet extent aware
  -            
  -			assertEquals("check size", list.size(), 7);
   
  -		}
  -		catch (Throwable t)
  -		{
  -			t.printStackTrace();
  -			fail(t.getMessage());
  -		}
  -	}
  - 
  - 	/**
  - 	 * Test pathExpression and Extents
 	 */
  -	public void testReportPathExpressionForExtents()
  -	{
  -		ArrayList list = new java.util.ArrayList();
  -
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addEqualTo("groupId", new Integer(5));
  -
  -			ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit, true);
  -			q.setColumns(new String[] { "groupId", "groupName", "allArticlesInGroup.articleId","allArticlesInGroup.articleName"});
  -
  -			Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -			while (iter.hasNext())
  -			{
  -				list.add(iter.next());
  -			}
  +            assertEquals("check size", list.size(), 7);
  +
  +        }
  +        catch (Throwable t)
  +        {
  +            t.printStackTrace();
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Test pathExpression and Extents
 	 */
  +    public void testReportPathExpressionForExtents()
  +    {
  +        ArrayList list = new java.util.ArrayList();
   
  -			// 7 Articles, 2 Books, 3 Cds
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addEqualTo("groupId", new Integer(5));
  +
  +            ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit, true);
  +            q.setColumns(new String[]{"groupId", "groupName", "allArticlesInGroup.articleId", "allArticlesInGroup.articleName"});
  +
  +            Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +            while (iter.hasNext())
  +            {
  +                list.add(iter.next());
  +            }
  +
  +            // 7 Articles, 2 Books, 3 Cds
               //	assertEquals("check size", list.size(), 12);
               //
               //  BRJ: path expression is not yet extent aware for columns
  -            
  -			assertEquals("check size", list.size(), 7);
   
  -		}
  -		catch (Throwable t)
  -		{
  -			t.printStackTrace();
  -			fail(t.getMessage());
  -		}
  -	}
  - 	/**
  - 	 * Test pathExpression and Extents
  - 	 */
  -	public void testPathExpressionForExtents()
  -	{
  -		ArrayList list = new java.util.ArrayList();
  -
  -		try
  -		{
  -			Criteria crit = new Criteria();
  -			crit.addEqualTo("allArticlesInGroup.productGroupId", new Integer(5));
  -
  -			Query q = QueryFactory.newQuery(ProductGroup.class, crit, true);
  -
  -			Iterator iter = broker.getIteratorByQuery(q);
  -			while (iter.hasNext())
  -			{
  -				list.add(iter.next());
  -			}
  -
  -			// BRJ : should return 1 product group
  -			// returns 3 because of implementation of extent aware path expression
  - 			//
  - 			// SQL: SELECT DISTINCT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0 INNER JOIN Artikel A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr WHERE A1.Kategorie_Nr =  ? 
  -			// SQL: SELECT DISTINCT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0 INNER JOIN BOOKS A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr WHERE A1.Kategorie_Nr =  ? 
  -			// SQL: SELECT DISTINCT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0 INNER JOIN CDS A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr WHERE A1.Kategorie_Nr =  ? 
  -        
  -			assertEquals("check size", list.size(), 3);
  -
  -		}
  -		catch (Throwable t)
  -		{
  -			t.printStackTrace();
  -			fail(t.getMessage());
  -		}
  -	}
  -     
  +            assertEquals("check size", list.size(), 7);
  +
  +        }
  +        catch (Throwable t)
  +        {
  +            t.printStackTrace();
  +            fail(t.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Test pathExpression and Extents
  +     */
  +    public void testPathExpressionForExtents()
  +    {
  +        ArrayList list = new java.util.ArrayList();
  +
  +        try
  +        {
  +            Criteria crit = new Criteria();
  +            crit.addEqualTo("allArticlesInGroup.productGroupId", new Integer(5));
  +
  +            Query q = QueryFactory.newQuery(ProductGroup.class, crit, true);
  +
  +            Iterator iter = broker.getIteratorByQuery(q);
  +            while (iter.hasNext())
  +            {
  +                list.add(iter.next());
  +            }
  +
  +            // BRJ : should return 1 product group
  +            // returns 3 because of implementation of extent aware path expression
  +            //
  +            // SQL: SELECT DISTINCT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0 INNER JOIN Artikel A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr WHERE A1.Kategorie_Nr =  ?
  +            // SQL: SELECT DISTINCT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0 INNER JOIN BOOKS A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr WHERE A1.Kategorie_Nr =  ?
  +            // SQL: SELECT DISTINCT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0 INNER JOIN CDS A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr WHERE A1.Kategorie_Nr =  ?
  +
  +            assertEquals("check size", list.size(), 3);
  +
  +        }
  +        catch (Throwable t)
  +        {
  +            t.printStackTrace();
  +            fail(t.getMessage());
  +        }
  +    }
  +
   }
  
  
  
  1.12      +3 -4      jakarta-ojb/src/test/org/apache/ojb/odmg/ScrollableQueryResultsTest.java
  
  Index: ScrollableQueryResultsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/odmg/ScrollableQueryResultsTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ScrollableQueryResultsTest.java	28 Nov 2002 22:33:02 -0000	1.11
  +++ ScrollableQueryResultsTest.java	29 Nov 2002 13:54:36 -0000	1.12
  @@ -6,7 +6,6 @@
   import org.apache.ojb.broker.PersistenceBrokerFactory;
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.singlevm.PersistenceBrokerConfiguration;
  -import org.apache.ojb.broker.singlevm.PersistenceBrokerImpl;
   import org.apache.ojb.broker.util.configuration.ConfigurationException;
   import org.apache.ojb.odmg.oql.EnhancedOQLQuery;
   import org.odmg.Database;
  @@ -325,7 +324,7 @@
       {
           // only perform this test in singlevm mode
           if (((PersistenceBrokerConfiguration) PersistenceBrokerFactory.getConfigurator().getConfigurationFor(null)).
  -                    isRunningInServerMode())
  +                isRunningInServerMode())
           {
               return;
           }
  @@ -380,7 +379,7 @@
               }
               tx.commit();
               // check that we got the right amount back.
  -            if (count != (CONTROL_SIZE - start +1)) /* +1 because the last row is inclusive */
  +            if (count != (CONTROL_SIZE - start + 1)) /* +1 because the last row is inclusive */
               {
                   fail(
                           "count not right, found <"
  
  
  

Mime
View raw message