db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r452264 - in /db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb: broker/PathTest.java broker/QueryTest.java odmg/LockingMultithreadedTest.java
Date Mon, 02 Oct 2006 23:36:56 GMT
Author: arminw
Date: Mon Oct  2 16:36:55 2006
New Revision: 452264

URL: http://svn.apache.org/viewvc?view=rev&rev=452264
Log:
fix, cleanup tests

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PathTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingMultithreadedTest.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PathTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PathTest.java?view=diff&rev=452264&r1=452263&r2=452264
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PathTest.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/PathTest.java Mon Oct 
2 16:36:55 2006
@@ -9,20 +9,24 @@
 import java.util.Collection;
 import java.util.Iterator;
 
-import junit.framework.TestCase;
+import org.apache.commons.lang.SystemUtils;
 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.query.QueryFactory;
 import org.apache.ojb.broker.query.UserAlias;
+import org.apache.ojb.junit.PBTestCase;
 
-public class PathTest extends TestCase
+public class PathTest extends PBTestCase
 {
+    // set true to enable test output
+    private static boolean PRINT_TESTINFO = false;
+    private StringBuffer output;
+    private static String eol = SystemUtils.LINE_SEPARATOR;
 
     private static Class CLASS = PathTest.class;
-    private int COUNT = 10;
-    private int id_filter = 10000;
-    private PersistenceBroker broker = null;
+    //private int COUNT = 10;
+    // private int id_filter = 10000;
 
     public static void main(String[] args)
     {
@@ -30,28 +34,16 @@
         junit.textui.TestRunner.main(arr);
     }
 
-    /**
-     * Insert the method's description here.
-     * Creation date: (06.12.2000 21:58:53)
-     */
-    public void setUp()
+    public void setUp() throws Exception
     {
-        try
-        {
-            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
-        }
-        catch (PBFactoryException e)
-        {
-        }
+        super.setUp();
+        output = new StringBuffer();
     }
 
-    /**
-     * Insert the method's description here.
-     * Creation date: (06.12.2000 21:59:14)
-     */
-    public void tearDown()
+    public void tearDown() throws Exception
     {
-        broker.close();
+        super.tearDown();
+        if(PRINT_TESTINFO) System.out.println(output.toString());
     }
 
     public PathTest(String name)
@@ -116,13 +108,13 @@
         {
             A a = new A(A_OFFSET + A_OFFSET * ia);
             broker.store(a);
-            System.out.println("A - " + a.getaAttrib());
+            output.append(eol +"A - " + a.getaAttrib());
             for (int ib = 0; ib < NUM_B_PER_A; ib++)
             {
                 B b = new B(A_OFFSET + B_OFFSET * ib);
                 b.setA(a);
                 broker.store(b);
-                System.out.println("\tB - " + b.getbAttrib());
+                output.append(eol +"\tB - " + b.getbAttrib());
                 for (int ic = 0; ic < NUM_C_PER_B; ic++)
                 {
                     C c = new C(A_OFFSET + B_OFFSET * ib + C_OFFSET * ic);
@@ -133,8 +125,8 @@
                         c.setD(d);
                         broker.store(d);
                         broker.store(c);
-                        System.out.println("\t\tC - " + c.getcAttrib());
-                        System.out.println("\t\t\tD - " + d.getdAttrib());
+                        output.append(eol +"\t\tC - " + c.getcAttrib());
+                        output.append(eol +"\t\t\tD - " + d.getdAttrib());
                     }
                 }
                 for (int ic = 0; ic < NUM_C1_PER_B; ic++)
@@ -148,8 +140,8 @@
                         c1.setC1Attrib(c1.getcAttrib() + 1);
                         broker.store(d);
                         broker.store(c1);
-                        System.out.println("\t\tC1 - " + c1.getC1Attrib());
-                        System.out.println("\t\t\tD - " + d.getdAttrib());
+                        output.append(eol +"\t\tC1 - " + c1.getC1Attrib());
+                        output.append(eol +"\t\t\tD - " + d.getdAttrib());
                     }
                 }
             }
@@ -236,32 +228,24 @@
 	 */
 	public void testPathClassOnSegment1() throws Exception
 	{
-		try
-		{
-			// c1 criteria 
-			Criteria crit1 = new Criteria();
-			crit1.addEqualTo("cSet.c1Attrib", new Integer("10001"));
-			crit1.addPathClass("cSet", C1.class);
-			
-			Query query = new QueryByCriteria(B.class, crit1);
-
-			Collection allBs = broker.getCollectionByQuery(query);
-
-			java.util.Iterator itr = allBs.iterator();
-
-			assertEquals(1 * NUM_A, allBs.size());
-			System.out.println("testPathClassOnSegment1() iteration size:" + allBs.size());
-			while (itr.hasNext())
-			{
-				B b = (B) itr.next();
-				System.out.println("Found B:  " + b.getId() + " " + b.getbAttrib());
-			}
-		}
-		catch (Throwable t)
-		{
-			t.printStackTrace(System.out);
-			fail("testPathClassOnSegment1: " + t.getMessage());
-		}
+		// c1 criteria
+        Criteria crit1 = new Criteria();
+        crit1.addEqualTo("cSet.c1Attrib", new Integer("10001"));
+        crit1.addPathClass("cSet", C1.class);
+
+        Query query = QueryFactory.newQuery(B.class, crit1);
+
+        Collection allBs = broker.getCollectionByQuery(query);
+
+        java.util.Iterator itr = allBs.iterator();
+
+        assertEquals(1 * NUM_A, allBs.size());
+        output.append(eol +"testPathClassOnSegment1() iteration size:" + allBs.size());
+        while (itr.hasNext())
+        {
+            B b = (B) itr.next();
+            output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
+        }
 	}
 	
 	/*
@@ -270,32 +254,24 @@
 	 */
 	public void testPathClassOnSegment2() throws Exception
 	{
-		try
-		{
-			// c1 criteria 
-			Criteria crit1 = new Criteria();
-			crit1.addEqualTo("bSet.cSet.c1Attrib", new Integer("10001"));
-			crit1.addPathClass("bSet.cSet", C1.class);
-			
-			Query query = new QueryByCriteria(A.class, crit1);
-
-			Collection allAs = broker.getCollectionByQuery(query);
-
-			java.util.Iterator itr = allAs.iterator();
-
-			assertEquals(allAs.size(), 1 * NUM_A);
-			System.out.println("testPathClassOnSegment2() iteration size:" + allAs.size());
-			while (itr.hasNext())
-			{
-				A a = (A) itr.next();
-				System.out.println("Found A:  " + a.getId() + " " + a.getaAttrib());
-			}
-		}
-		catch (Throwable t)
-		{
-			t.printStackTrace(System.out);
-			fail("testPathClassOnSegment2: " + t.getMessage());
-		}
+		// c1 criteria
+        Criteria crit1 = new Criteria();
+        crit1.addEqualTo("bSet.cSet.c1Attrib", new Integer("10001"));
+        crit1.addPathClass("bSet.cSet", C1.class);
+
+        Query query = QueryFactory.newQuery(A.class, crit1);
+
+        Collection allAs = broker.getCollectionByQuery(query);
+
+        java.util.Iterator itr = allAs.iterator();
+
+        assertEquals(allAs.size(), 1 * NUM_A);
+        output.append(eol +"testPathClassOnSegment2() iteration size:" + allAs.size());
+        while (itr.hasNext())
+        {
+            A a = (A) itr.next();
+            output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
+        }
 	}
 	
 	/*
@@ -304,33 +280,25 @@
 	 */
 	public void testSingleAlias() throws Exception
 	{
-		try
-		{
-			// d1 criteria 
-			Criteria crit1 = new Criteria();
-			crit1.setAlias("cToD1", "cSet");  // unnecessary, but its use should not
-											// cause incorrect results
-			crit1.addEqualTo("cSet.d.dAttrib", new Integer("10010"));
-
-			Query query = new QueryByCriteria(B.class, crit1);
-
-			Collection allBs = broker.getCollectionByQuery(query);
-
-			java.util.Iterator itr = allBs.iterator();
-
-			assertEquals(2 * NUM_A, allBs.size());
-			System.out.println("testSingleAlias() iteration size:" + allBs.size());
-			while (itr.hasNext())
-			{
-				B b = (B) itr.next();
-				System.out.println("Found B:  " + b.getId() + " " + b.getbAttrib());
-			}
-		}
-		catch (Throwable t)
-		{
-			t.printStackTrace(System.out);
-			fail("testSingleAlias: " + t.getMessage());
-		}
+		// d1 criteria
+        Criteria crit1 = new Criteria();
+        crit1.setAlias("cToD1", "cSet");  // unnecessary, but its use should not
+                                        // cause incorrect results
+        crit1.addEqualTo("cSet.d.dAttrib", new Integer("10010"));
+
+        Query query = QueryFactory.newQuery(B.class, crit1);
+
+        Collection allBs = broker.getCollectionByQuery(query);
+
+        java.util.Iterator itr = allBs.iterator();
+
+        assertEquals(2 * NUM_A, allBs.size());
+        output.append(eol +"testSingleAlias() iteration size:" + allBs.size());
+        while (itr.hasNext())
+        {
+            B b = (B) itr.next();
+            output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
+        }
 	}
 	
 	/*
@@ -339,39 +307,31 @@
 	 */
 	public void testTwoAliasesTwoSegments() throws Exception
 	{
-		try
-		{
-			// d1 criteria 
-			Criteria crit1 = new Criteria();
-			crit1.setAlias("cToD1", "cSet.d");
-			crit1.addEqualTo("cSet.d.dAttrib", new Integer("10010"));
-
-			// d2 criteria
-			Criteria crit2 = new Criteria();
-			crit2.setAlias("cToD2", "cSet.d");
-			crit2.addEqualTo("cSet.d.dAttrib", new Integer("10110"));
-
-			crit1.addAndCriteria(crit2);
-
-			Query query = new QueryByCriteria(B.class, crit1);
-
-			Collection allBs = broker.getCollectionByQuery(query);
-
-			java.util.Iterator itr = allBs.iterator();
-
-			assertEquals(4 * NUM_A, allBs.size());
-			System.out.println("testTwoAliasesTwoSegments() iteration size:" + allBs.size());
-			while (itr.hasNext())
-			{
-				B b = (B) itr.next();
-				System.out.println("Found B:  " + b.getId() + " " + b.getbAttrib());
-			}
-		}
-		catch (Throwable t)
-		{
-			t.printStackTrace(System.out);
-			fail("testTwoAliasesTwoSegments: " + t.getMessage());
-		}
+		// d1 criteria
+        Criteria crit1 = new Criteria();
+        crit1.setAlias("cToD1", "cSet.d");
+        crit1.addEqualTo("cSet.d.dAttrib", new Integer("10010"));
+
+        // d2 criteria
+        Criteria crit2 = new Criteria();
+        crit2.setAlias("cToD2", "cSet.d");
+        crit2.addEqualTo("cSet.d.dAttrib", new Integer("10110"));
+
+        crit1.addAndCriteria(crit2);
+
+        Query query = QueryFactory.newQuery(B.class, crit1);
+
+        Collection allBs = broker.getCollectionByQuery(query);
+
+        Iterator itr = allBs.iterator();
+
+        assertEquals(4 * NUM_A, allBs.size());
+        output.append(eol +"testTwoAliasesTwoSegments() iteration size:" + allBs.size());
+        while (itr.hasNext())
+        {
+            B b = (B) itr.next();
+            output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
+        }
 	}
 	
 	/*
@@ -380,40 +340,31 @@
 	 */
 	public void testTwoAliasesThreeSegments() throws Exception
 	{
-		try
-		{
-			// d1 criteria 
-			Criteria crit1 = new Criteria();
-			crit1.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10010"));
-			crit1.setAlias("bToCToD1", "cSet.d");
-
-			// d2 criteria
-			Criteria crit2 = new Criteria();
-			crit2.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10110"));
-			crit2.setAlias("bToCToD2", "cSet.d");
-
-			crit1.addAndCriteria(crit2);
-
-			boolean isDistinct = true;
-			Query query = new QueryByCriteria(A.class, crit1, true);
-
-			Collection allAs = broker.getCollectionByQuery(query);
-
-			java.util.Iterator itr = allAs.iterator();
-
-			assertEquals(1 * NUM_A, allAs.size());
-			System.out.println("testTwoAliasesThreeSegments() iteration size:" + allAs.size());
-			while (itr.hasNext())
-			{
-				A a = (A) itr.next();
-				System.out.println("Found A:  " + a.getId() + " " + a.getaAttrib());
-			}
-		}
-		catch (Throwable t)
-		{
-			t.printStackTrace(System.out);
-			fail("testTwoAliasesThreeSegments: " + t.getMessage());
-		}
+		// d1 criteria
+        Criteria crit1 = new Criteria();
+        crit1.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10010"));
+        crit1.setAlias("bToCToD1", "cSet.d");
+
+        // d2 criteria
+        Criteria crit2 = new Criteria();
+        crit2.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10110"));
+        crit2.setAlias("bToCToD2", "cSet.d");
+
+        crit1.addAndCriteria(crit2);
+
+        Query query = QueryFactory.newQuery(A.class, crit1, true);
+
+        Collection allAs = broker.getCollectionByQuery(query);
+
+        java.util.Iterator itr = allAs.iterator();
+
+        assertEquals(1 * NUM_A, allAs.size());
+        output.append(eol +"testTwoAliasesThreeSegments() iteration size:" + allAs.size());
+        while (itr.hasNext())
+        {
+            A a = (A) itr.next();
+            output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
+        }
 	}	
 	
 	/*
@@ -421,40 +372,32 @@
 	 */
     public void testPathClassPerCriteria() throws Exception
     {
-        try
-        {
-            // C criteria
-            Criteria crit1 = new Criteria();
-            crit1.addEqualTo("cSet.cAttrib", new Integer("10200"));
-            crit1.addPathClass("cSet", C.class);
-			crit1.setAlias("alias1");
+        // C criteria
+        Criteria crit1 = new Criteria();
+        crit1.addEqualTo("cSet.cAttrib", new Integer("10200"));
+        crit1.addPathClass("cSet", C.class);
+        crit1.setAlias("alias1");
 
-            // C1 criteria (subclass of C)
-            Criteria crit2 = new Criteria();
-            crit2.addEqualTo("cSet.c1Attrib", new Integer("10001"));
-            crit2.addPathClass("cSet", C1.class);
-			crit2.setAlias("alias2");
+        // C1 criteria (subclass of C)
+        Criteria crit2 = new Criteria();
+        crit2.addEqualTo("cSet.c1Attrib", new Integer("10001"));
+        crit2.addPathClass("cSet", C1.class);
+        crit2.setAlias("alias2");
 
-            crit1.addAndCriteria(crit2);
+        crit1.addAndCriteria(crit2);
 
-            Query query = new QueryByCriteria(B.class, crit1);
+        Query query = QueryFactory.newQuery(B.class, crit1);
 
-            Collection allBs = broker.getCollectionByQuery(query);
+        Collection allBs = broker.getCollectionByQuery(query);
 
-            java.util.Iterator itr = allBs.iterator();
+        java.util.Iterator itr = allBs.iterator();
 
-            assertEquals(1 * NUM_A, allBs.size());
-            System.out.println("testPathClassPerCriteria() iteration size:" + allBs.size());
-            while (itr.hasNext())
-            {
-                B b = (B) itr.next();
-                System.out.println("Found B:  " + b.getId() + " " + b.getbAttrib());
-            }
-        }
-        catch (Throwable t)
+        assertEquals(1 * NUM_A, allBs.size());
+        output.append(eol +"testPathClassPerCriteria() iteration size:" + allBs.size());
+        while (itr.hasNext())
         {
-            t.printStackTrace(System.out);
-            fail("testPathClassPerCriteria: " + t.getMessage());
+            B b = (B) itr.next();
+            output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
         }
     }
     
@@ -464,42 +407,34 @@
 	 */
 	public void testPathClassPerQuery() throws Exception
 	{
-		try
-		{
-			// c1_a criteria 
-			Criteria crit1 = new Criteria();
-			crit1.addEqualTo("cSet.c1Attrib", new Integer("12001"));
-			//crit1.addPathClass("cSet", C1.class); // can use 1 query setting instead
-			crit1.setAlias("alias1");
-
-			// c2_b criteria
-			Criteria crit2 = new Criteria();
-			crit2.addEqualTo("cSet.c1Attrib", new Integer("12101"));
-			//crit2.addPathClass("cSet", C1.class); // can use 1 query setting instead
-			crit2.setAlias("alias2");
-
-			crit1.addAndCriteria(crit2);
-
-			QueryByCriteria query = new QueryByCriteria(B.class, crit1);
-			query.addPathClass("cSet", C1.class);
-
-			Collection allBs = broker.getCollectionByQuery(query);
-
-			java.util.Iterator itr = allBs.iterator();
-
-			assertEquals(1 * NUM_A, allBs.size());
-			System.out.println("testPathClassPerQuery() iteration size:" + allBs.size());
-			while (itr.hasNext())
-			{
-				B b = (B) itr.next();
-				System.out.println("Found B:  " + b.getId() + " " + b.getbAttrib());
-			}
-		}
-		catch (Throwable t)
-		{
-			t.printStackTrace(System.out);
-			fail("testPathClassPerQuery: " + t.getMessage());
-		}
+		// c1_a criteria
+        Criteria crit1 = new Criteria();
+        crit1.addEqualTo("cSet.c1Attrib", new Integer("12001"));
+        //crit1.addPathClass("cSet", C1.class); // can use 1 query setting instead
+        crit1.setAlias("alias1");
+
+        // c2_b criteria
+        Criteria crit2 = new Criteria();
+        crit2.addEqualTo("cSet.c1Attrib", new Integer("12101"));
+        //crit2.addPathClass("cSet", C1.class); // can use 1 query setting instead
+        crit2.setAlias("alias2");
+
+        crit1.addAndCriteria(crit2);
+
+        QueryByCriteria query = QueryFactory.newQuery(B.class, crit1);
+        query.addPathClass("cSet", C1.class);
+
+        Collection allBs = broker.getCollectionByQuery(query);
+
+        java.util.Iterator itr = allBs.iterator();
+
+        assertEquals(1 * NUM_A, allBs.size());
+        output.append(eol +"testPathClassPerQuery() iteration size:" + allBs.size());
+        while (itr.hasNext())
+        {
+            B b = (B) itr.next();
+            output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
+        }
 	}
 	
 	/*
@@ -508,40 +443,32 @@
 	 */
 	public void testThreeSegmentsAliasOnSegment2And3() throws Exception
 	{
-		try
-		{
-			// d1 criteria 
-			Criteria crit1 = new Criteria();
-			crit1.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10010"));
-			crit1.setAlias("bToCToD1", "cSet.d");
-
-			// d2 criteria
-			Criteria crit2 = new Criteria();
-			crit2.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10110"));
-			crit2.setAlias("bToCToD2", "cSet.d");
-
-			crit1.addAndCriteria(crit2);
-
-			boolean isDistinct = true;
-			Query query = new QueryByCriteria(A.class, crit1, isDistinct);
-
-			Collection allAs = broker.getCollectionByQuery(query);
-
-			java.util.Iterator itr = allAs.iterator();
-
-			assertEquals(1 * NUM_A, allAs.size());
-			System.out.println("testThreeSegmentsAliasOnSegment2And3() iteration size:" + allAs.size());
-			while (itr.hasNext())
-			{
-				A a = (A) itr.next();
-				System.out.println("Found A:  " + a.getId() + " " + a.getaAttrib());
-			}
-		}
-		catch (Throwable t)
-		{
-			t.printStackTrace(System.out);
-			fail("testThreeSegmentsAliasOnSegment2And3: " + t.getMessage());
-		}
+		// d1 criteria
+        Criteria crit1 = new Criteria();
+        crit1.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10010"));
+        crit1.setAlias("bToCToD1", "cSet.d");
+
+        // d2 criteria
+        Criteria crit2 = new Criteria();
+        crit2.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10110"));
+        crit2.setAlias("bToCToD2", "cSet.d");
+
+        crit1.addAndCriteria(crit2);
+
+        boolean isDistinct = true;
+        Query query = QueryFactory.newQuery(A.class, crit1, isDistinct);
+
+        Collection allAs = broker.getCollectionByQuery(query);
+
+        java.util.Iterator itr = allAs.iterator();
+
+        assertEquals(1 * NUM_A, allAs.size());
+        output.append(eol +"testThreeSegmentsAliasOnSegment2And3() iteration size:" + allAs.size());
+        while (itr.hasNext())
+        {
+            A a = (A) itr.next();
+            output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
+        }
 	}	
 	
 	/*
@@ -549,48 +476,40 @@
 	 */
 	public void testThreeSegmentsAliasOnSegment2And3UserAlias() throws Exception
 	{
-		try
-		{
-			UserAlias userAlias1 = new UserAlias("alias1");
-			userAlias1.add("bSet.cSet");
-			userAlias1.add("bSet.cSet.d");
-			
-			// d1 criteria 
-			Criteria crit1 = new Criteria();
-			crit1.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10010"));
-			crit1.setAlias(userAlias1);
-
-			// d2 criteria
-			UserAlias userAlias2 = new UserAlias("alias2");
-			userAlias2.add("bSet.cSet");
-			userAlias2.add("bSet.cSet.d");
-
-			Criteria crit2 = new Criteria();
-			crit2.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10110"));
-			crit2.setAlias(userAlias2);
-
-			crit1.addAndCriteria(crit2);
-
-			boolean isDistinct = true;
-			Query query = new QueryByCriteria(A.class, crit1, isDistinct);
-
-			Collection allAs = broker.getCollectionByQuery(query);
-
-			java.util.Iterator itr = allAs.iterator();
-
-			assertEquals(1 * NUM_A, allAs.size());
-			System.out.println("testThreeSegmentsAliasOnSegment2And3UserAlias() iteration size:" +
allAs.size());
-			while (itr.hasNext())
-			{
-				A a = (A) itr.next();
-				System.out.println("Found A:  " + a.getId() + " " + a.getaAttrib());
-			}
-		}
-		catch (Throwable t)
-		{
-			t.printStackTrace(System.out);
-			fail("testThreeSegmentsAliasOnSegment2And3UserAlias: " + t.getMessage());
-		}
+        UserAlias userAlias1 = new UserAlias("alias1");
+        userAlias1.add("bSet.cSet");
+        userAlias1.add("bSet.cSet.d");
+
+        // d1 criteria
+        Criteria crit1 = new Criteria();
+        crit1.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10010"));
+        crit1.setAlias(userAlias1);
+
+        // d2 criteria
+        UserAlias userAlias2 = new UserAlias("alias2");
+        userAlias2.add("bSet.cSet");
+        userAlias2.add("bSet.cSet.d");
+
+        Criteria crit2 = new Criteria();
+        crit2.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10110"));
+        crit2.setAlias(userAlias2);
+
+        crit1.addAndCriteria(crit2);
+
+        boolean isDistinct = true;
+	    Query query = QueryFactory.newQuery(A.class, crit1, isDistinct);
+
+        Collection allAs = broker.getCollectionByQuery(query);
+
+        java.util.Iterator itr = allAs.iterator();
+
+        assertEquals(1 * NUM_A, allAs.size());
+			output.append(eol +"testThreeSegmentsAliasOnSegment2And3UserAlias() iteration size:" +
allAs.size());
+        while (itr.hasNext())
+        {
+            A a = (A) itr.next();
+				output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
+        }
 	}	
 	
 	public void testSubQueryExists()
@@ -599,14 +518,14 @@
         Criteria subCrit = new Criteria();
         subCrit.addEqualTo(Criteria.PARENT_QUERY_PREFIX + "bSet.cSet.d.dAttrib", new Integer("10011"));
         //	    subCrit.setAlias("subAlias", "cSet.d");
-        QueryByCriteria subQuery = new QueryByCriteria(A.class, subCrit);
+        QueryByCriteria subQuery = QueryFactory.newQuery(A.class, subCrit);
 
         // parent query
         Criteria crit = new Criteria();
         crit.addEqualTo("bSet.cSet.d.dAttrib", new Integer("10010"));
         //	    crit.setAlias("alias", "cSet.d");
         crit.addNotExists(subQuery);
-        QueryByCriteria query = new QueryByCriteria(A.class, crit,true);
+        QueryByCriteria query = QueryFactory.newQuery(A.class, crit,true);
 
         Collection result = broker.getCollectionByQuery(query);
 		assertEquals(1 * NUM_A, result.size());
@@ -615,7 +534,7 @@
 		while (itr.hasNext())
 		{
 			A a = (A) itr.next();
-			System.out.println("Found A:  " + a.getId() + " " + a.getaAttrib());
+			output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
 		}
     }
 	

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java?view=diff&rev=452264&r1=452263&r2=452264
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java Mon Oct
 2 16:36:55 2006
@@ -105,7 +105,7 @@
             Object[] row = (Object[]) iter.next();
             assertEquals(3, row.length);
             results.add(row);
-            result += ((Integer) row[2]).intValue();
+            result += ((Number) row[2]).intValue();
             //System.out.println("Result_1: " + ArrayUtils.toString(row));
         }
         assertEquals(2, result);
@@ -128,7 +128,7 @@
             Object[] row = (Object[]) iter.next();
             assertEquals(3, row.length);
             results.add(row);
-            result += ((Integer) row[2]).intValue();
+            result += ((Number) row[2]).intValue();
             //System.out.println("Result_2: " + ArrayUtils.toString(row));
         }
         assertEquals(3, result);

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingMultithreadedTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingMultithreadedTest.java?view=diff&rev=452264&r1=452263&r2=452264
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingMultithreadedTest.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingMultithreadedTest.java
Mon Oct  2 16:36:55 2006
@@ -28,8 +28,8 @@
     // number of updates each thread performs against the object
     private final int objectUpdates = 30;
     // max number of attemps to get a lock
-    private static final int maxAttempts = 150;
-    private static final int nearMax = (int) (maxAttempts * 0.75);
+    private static final int maxAttempts = 200;
+    private static final int nearMax = (int) (maxAttempts * 0.90);
 
 
     public static void main(String[] args)
@@ -167,7 +167,7 @@
                                 + ". This can be a result of low hardware.");
                     try
                     {
-                        Thread.sleep(30);
+                        Thread.sleep((long) Math.random() * 100);
                     }
                     catch(InterruptedException e1)
                     {



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message