cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r991287 [2/2] - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/access/ java/org/apache/cayenne/ashwood/ java/org/apache/cayenne/dba/ java/org/apache/cayenne/map/ resources/dml/
Date Tue, 31 Aug 2010 18:44:01 GMT
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java?rev=991287&r1=991286&r2=991287&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
Tue Aug 31 18:44:00 2010
@@ -20,25 +20,35 @@ package org.apache.cayenne.access;
 
 import java.util.Arrays;
 
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.ExtendedTypeEntity;
 import org.apache.cayenne.testdo.testmap.StringET1;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class DataContextExtendedTypeOperationsTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextExtendedTypeOperationsTest extends ServerCase {
+
+    @Inject
+    protected ObjectContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
 
     @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        deleteTestData();
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("EXTENDED_TYPE_TEST");
     }
 
     public void testStoreExtendedType() {
-        ExtendedTypeEntity e1 = createDataContext().newObject(ExtendedTypeEntity.class);
+        ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
         e1.setName(new StringET1("X"));
         e1.getObjectContext().commitChanges();
 
@@ -51,7 +61,7 @@ public class DataContextExtendedTypeOper
     }
 
     public void testInExpressionExtendedTypeArray() {
-        ExtendedTypeEntity e1 = createDataContext().newObject(ExtendedTypeEntity.class);
+        ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
         e1.setName(new StringET1("X"));
 
         ExtendedTypeEntity e2 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);
@@ -64,13 +74,14 @@ public class DataContextExtendedTypeOper
 
         Expression in = ExpressionFactory.inExp(
                 ExtendedTypeEntity.NAME_PROPERTY,
-                new StringET1("X"), new StringET1("Y"));
+                new StringET1("X"),
+                new StringET1("Y"));
         SelectQuery query = new SelectQuery(ExtendedTypeEntity.class, in);
         assertEquals(2, e1.getObjectContext().performQuery(query).size());
     }
 
     public void testInExpressionExtendedTypeList() {
-        ExtendedTypeEntity e1 = createDataContext().newObject(ExtendedTypeEntity.class);
+        ExtendedTypeEntity e1 = context.newObject(ExtendedTypeEntity.class);
         e1.setName(new StringET1("X"));
 
         ExtendedTypeEntity e2 = e1.getObjectContext().newObject(ExtendedTypeEntity.class);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/TransactionThreadTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/TransactionThreadTest.java?rev=991287&r1=991286&r2=991287&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/TransactionThreadTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/TransactionThreadTest.java
Tue Aug 31 18:44:00 2010
@@ -21,12 +21,30 @@ package org.apache.cayenne.access;
 
 import java.sql.Connection;
 
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class TransactionThreadTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class TransactionThreadTest extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST");
+    }
 
     public void testThreadConnectionReuseOnSelect() throws Exception {
 
@@ -38,12 +56,12 @@ public class TransactionThreadTest exten
         try {
 
             SelectQuery q1 = new SelectQuery(Artist.class);
-            createDataContext().performQuery(q1);
+            context.performQuery(q1);
             assertEquals(1, delegate.connectionCount);
 
             // delegate will fail if the second query opens a new connection
             SelectQuery q2 = new SelectQuery(Artist.class);
-            createDataContext().performQuery(q2);
+            context.performQuery(q2);
 
         }
         finally {
@@ -53,9 +71,8 @@ public class TransactionThreadTest exten
     }
 
     public void testThreadConnectionReuseOnQueryFromWillCommit() throws Exception {
-        deleteTestData();
 
-        Artist a = createDataContext().newObject(Artist.class);
+        Artist a = context.newObject(Artist.class);
         a.setArtistName("aaa");
 
         Delegate delegate = new Delegate() {
@@ -67,24 +84,22 @@ public class TransactionThreadTest exten
                 SQLTemplate template = new SQLTemplate(
                         Artist.class,
                         "insert into ARTIST (ARTIST_ID, ARTIST_NAME) values (1, 'bbb')");
-                createDataContext().performNonSelectingQuery(template);
+                context.performNonSelectingQuery(template);
 
                 return true;
             }
         };
 
-        getDomain().setTransactionDelegate(delegate);
+        context.getParentDataDomain().setTransactionDelegate(delegate);
 
         try {
             a.getObjectContext().commitChanges();
         }
         finally {
-            getDomain().setTransactionDelegate(null);
+            context.getParentDataDomain().setTransactionDelegate(null);
         }
 
-        assertEquals(2, createDataContext()
-                .performQuery(new SelectQuery(Artist.class))
-                .size());
+        assertEquals(2, context.performQuery(new SelectQuery(Artist.class)).size());
     }
 
     class Delegate implements TransactionDelegate {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/UUIDTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/UUIDTest.java?rev=991287&r1=991286&r2=991287&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/UUIDTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/UUIDTest.java
Tue Aug 31 18:44:00 2010
@@ -21,21 +21,29 @@ package org.apache.cayenne.access;
 import java.util.UUID;
 
 import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
 import org.apache.cayenne.testdo.testmap.UuidTestEntity;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class UUIDTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class UUIDTest extends ServerCase {
+
+    @Inject
+    private ObjectContext context;
+
+    @Inject
+    private DBHelper dbHelper;
 
     @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        deleteTestData();
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("UUID_TEST");
     }
 
     public void testUUID() throws Exception {
 
-        ObjectContext context = createDataContext();
         UuidTestEntity test = context.newObject(UuidTestEntity.class);
 
         UUID id = UUID.randomUUID();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/UserTransactionTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/UserTransactionTest.java?rev=991287&r1=991286&r2=991287&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/UserTransactionTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/UserTransactionTest.java
Tue Aug 31 18:44:00 2010
@@ -21,13 +21,19 @@ package org.apache.cayenne.access;
 
 import java.sql.Connection;
 
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class UserTransactionTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class UserTransactionTest extends ServerCase {
+
+    @Inject
+    protected ObjectContext context;
 
     public void testCommit() throws Exception {
-        DataContext context = createDataContext();
 
         Artist a = context.newObject(Artist.class);
         a.setArtistName("AAA");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ashwood/AshwoodEntitySorterTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ashwood/AshwoodEntitySorterTest.java?rev=991287&r1=991286&r2=991287&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ashwood/AshwoodEntitySorterTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/ashwood/AshwoodEntitySorterTest.java
Tue Aug 31 18:44:00 2010
@@ -22,30 +22,58 @@ package org.apache.cayenne.ashwood;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.relationship.ReflexiveAndToOne;
-import org.apache.cayenne.unit.RelationshipCase;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class AshwoodEntitySorterTest extends RelationshipCase {
+@UseServerRuntime(ServerCase.RELATIONSHIPS_PROJECT)
+public class AshwoodEntitySorterTest extends ServerCase {
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    @Inject
+    protected ObjectContext context;
+
+    protected TableHelper tRelationshipHelper;
+    protected TableHelper tReflexiveAndToOne;
 
     @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        deleteTestData();
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("REFLEXIVE_AND_TO_ONE");
+        dbHelper.deleteAll("RELATIONSHIP_HELPER");
+
+        tRelationshipHelper = new TableHelper(dbHelper, "RELATIONSHIP_HELPER");
+        tRelationshipHelper.setColumns("RELATIONSHIP_HELPER_ID", "NAME");
+
+        tReflexiveAndToOne = new TableHelper(dbHelper, "REFLEXIVE_AND_TO_ONE");
+        tReflexiveAndToOne.setColumns(
+                "REFLEXIVE_AND_TO_ONE_ID",
+                "PARENT_ID",
+                "RELATIONSHIP_HELPER_ID",
+                "NAME");
     }
 
     public void testSortObjectsForEntityReflexiveWithFaults() throws Exception {
-        createTestData("testSortObjectsForEntityDeletedWithFaults");
 
+        tRelationshipHelper.insert(1, "rh1");
+        tReflexiveAndToOne.insert(1, null, 1, "r1");
+        tReflexiveAndToOne.insert(2, 1, 1, "r2");
+        tReflexiveAndToOne.insert(3, 2, 1, "r3");
+        
         AshwoodEntitySorter sorter = new AshwoodEntitySorter();
-        sorter.setDataMaps(getDomain().getDataMaps());
+        sorter.setDataMaps(context.getEntityResolver().getDataMaps());
 
-        ObjEntity entity = getDomain().getEntityResolver().lookupObjEntity(
+        ObjEntity entity = context.getEntityResolver().lookupObjEntity(
                 ReflexiveAndToOne.class);
 
-        List<?> objects = createDataContext().performQuery(
-                new SelectQuery(ReflexiveAndToOne.class));
+        List<?> objects = context.performQuery(new SelectQuery(ReflexiveAndToOne.class));
         Collections.shuffle(objects);
         assertEquals(3, objects.size());
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java?rev=991287&r1=991286&r2=991287&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
Tue Aug 31 18:44:00 2010
@@ -26,63 +26,88 @@ import java.sql.ResultSet;
 import java.sql.Types;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
-import java.util.Iterator;
 import java.util.List;
 
+import javax.sql.DataSource;
+
 import org.apache.cayenne.MockSerializable;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.unit.di.server.ServerCase;
+
+public class TypesMappingTest extends ServerCase {
 
-public class TypesMappingTest extends CayenneCase {
+    @Inject
+    private DataSource dataSource;
 
     public void testGetSqlTypeByJava() throws Exception {
         assertEquals(Types.VARCHAR, TypesMapping.getSqlTypeByJava(String.class));
 
         // make sure we can handle arrays...
         assertEquals(Types.BINARY, TypesMapping.getSqlTypeByJava(byte[].class));
-        
+
         assertEquals(Types.TIMESTAMP, TypesMapping.getSqlTypeByJava(Calendar.class));
-        assertEquals(Types.TIMESTAMP, TypesMapping.getSqlTypeByJava(GregorianCalendar.class));
+        assertEquals(Types.TIMESTAMP, TypesMapping
+                .getSqlTypeByJava(GregorianCalendar.class));
         assertEquals(Types.BIGINT, TypesMapping.getSqlTypeByJava(BigInteger.class));
-        
-        assertEquals(Types.VARBINARY, TypesMapping.getSqlTypeByJava(MockSerializable.class));
+
+        assertEquals(Types.VARBINARY, TypesMapping
+                .getSqlTypeByJava(MockSerializable.class));
         assertEquals(Types.VARCHAR, TypesMapping.getSqlTypeByJava(char[].class));
         assertEquals(Types.VARCHAR, TypesMapping.getSqlTypeByJava(Character[].class));
         assertEquals(Types.VARBINARY, TypesMapping.getSqlTypeByJava(Byte[].class));
     }
-    
+
     public void testGetSqlTypeByJavaString() throws Exception {
         assertEquals(Types.VARCHAR, TypesMapping.getSqlTypeByJava(String.class.getName()));
 
         // make sure we can handle arrays...
         assertEquals(Types.BINARY, TypesMapping.getSqlTypeByJava("byte[]"));
-        
-        assertEquals(Types.TIMESTAMP, TypesMapping.getSqlTypeByJava(Calendar.class.getName()));
-        assertEquals(Types.TIMESTAMP, TypesMapping.getSqlTypeByJava(GregorianCalendar.class.getName()));
-        assertEquals(Types.BIGINT, TypesMapping.getSqlTypeByJava(BigInteger.class.getName()));
-        
-        assertEquals(Types.VARBINARY, TypesMapping.getSqlTypeByJava(MockSerializable.class.getName()));
-        
+
+        assertEquals(Types.TIMESTAMP, TypesMapping.getSqlTypeByJava(Calendar.class
+                .getName()));
+        assertEquals(Types.TIMESTAMP, TypesMapping
+                .getSqlTypeByJava(GregorianCalendar.class.getName()));
+        assertEquals(Types.BIGINT, TypesMapping.getSqlTypeByJava(BigInteger.class
+                .getName()));
+
+        assertEquals(Types.VARBINARY, TypesMapping
+                .getSqlTypeByJava(MockSerializable.class.getName()));
+
         assertEquals(Types.VARCHAR, TypesMapping.getSqlTypeByJava("char[]"));
-        assertEquals(Types.VARCHAR, TypesMapping.getSqlTypeByJava("java.lang.Character[]"));
+        assertEquals(Types.VARCHAR, TypesMapping
+                .getSqlTypeByJava("java.lang.Character[]"));
         assertEquals(Types.VARBINARY, TypesMapping.getSqlTypeByJava("java.lang.Byte[]"));
     }
-    
+
     public void testGetSqlTypeByJavaPrimitive() throws Exception {
         assertEquals(Types.INTEGER, TypesMapping.getSqlTypeByJava(Integer.TYPE));
         assertEquals(Types.BIGINT, TypesMapping.getSqlTypeByJava(Long.TYPE));
     }
-    
+
+    @Deprecated
     public void testGetJavaBySqlType() {
-        assertEquals(TypesMapping.JAVA_INTEGER, TypesMapping.getJavaBySqlType(Types.NUMERIC,
5, 0));
-        assertEquals(TypesMapping.JAVA_LONG, TypesMapping.getJavaBySqlType(Types.NUMERIC,
15, 0));
-        assertEquals(TypesMapping.JAVA_BIGDECIMAL, TypesMapping.getJavaBySqlType(Types.NUMERIC,
25, 0));
-        assertEquals(TypesMapping.JAVA_BIGDECIMAL, TypesMapping.getJavaBySqlType(Types.NUMERIC,
25, 5));
+        assertEquals(TypesMapping.JAVA_INTEGER, TypesMapping.getJavaBySqlType(
+                Types.NUMERIC,
+                5,
+                0));
+        assertEquals(TypesMapping.JAVA_LONG, TypesMapping.getJavaBySqlType(
+                Types.NUMERIC,
+                15,
+                0));
+        assertEquals(TypesMapping.JAVA_BIGDECIMAL, TypesMapping.getJavaBySqlType(
+                Types.NUMERIC,
+                25,
+                0));
+        assertEquals(TypesMapping.JAVA_BIGDECIMAL, TypesMapping.getJavaBySqlType(
+                Types.NUMERIC,
+                25,
+                5));
     }
 
     public void testTypeInfoCompleteness() throws Exception {
         // check counts
         // since more then 1 database type can map to a single JDBC type
-        Connection conn = getConnection();
+        Connection conn = dataSource.getConnection();
         int len = 0;
         try {
             DatabaseMetaData md = conn.getMetaData();
@@ -102,10 +127,9 @@ public class TypesMappingTest extends Ca
 
         int actualLen = 0;
         TypesMapping map = createTypesMapping();
-        Iterator it = map.databaseTypes.keySet().iterator();
-        while (it.hasNext()) {
-            List vals = map.databaseTypes.get(it.next());
-            actualLen += vals.size();
+
+        for (List<TypesMapping.TypeInfo> entry : map.databaseTypes.values()) {
+            actualLen += entry.size();
         }
 
         // this is bad assertion, since due to some hacks
@@ -115,7 +139,7 @@ public class TypesMappingTest extends Ca
     }
 
     TypesMapping createTypesMapping() throws Exception {
-        Connection conn = getConnection();
+        Connection conn = dataSource.getConnection();
 
         try {
             DatabaseMetaData md = conn.getMetaData();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/AttributeTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/AttributeTest.java?rev=991287&r1=991286&r2=991287&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/AttributeTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/AttributeTest.java
Tue Aug 31 18:44:00 2010
@@ -19,9 +19,9 @@
 
 package org.apache.cayenne.map;
 
-import org.apache.cayenne.unit.CayenneCase;
+import junit.framework.TestCase;
 
-public class AttributeTest extends CayenneCase {
+public class AttributeTest extends TestCase {
 
     public void testName() throws Exception {
         Attribute a = new MockAttribute();



Mime
View raw message