cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1101604 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java
Date Tue, 10 May 2011 19:18:01 GMT
Author: aadamchik
Date: Tue May 10 19:18:00 2011
New Revision: 1101604

URL: http://svn.apache.org/viewvc?rev=1101604&view=rev
Log:
CAY-1564 CayenneCase unit tests conversion(4)

patch by Dzmitry Kazimirchyk - DataContextBlobTest

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java?rev=1101604&r1=1101603&r2=1101604&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextBlobTest.java
Tue May 10 19:18:00 2011
@@ -22,28 +22,38 @@ package org.apache.cayenne.access;
 import java.util.List;
 
 import org.apache.cayenne.access.types.ByteArrayTypeTest;
+import org.apache.cayenne.configuration.server.ServerRuntime;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.testdo.testmap.BlobTestEntity;
-import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.AccessStackAdapter;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
-public class DataContextBlobTest extends CayenneCase {
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class DataContextBlobTest extends ServerCase {
 
-    protected DataContext ctxt;
+    @Inject
+    private DataContext context;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+    @Inject
+    private DataContext context2;
 
-        deleteTestData();
-        ctxt = createDataContext();
-    }
+    @Inject
+    private DataContext context3;
+
+    @Inject
+    protected ServerRuntime runtime;
+
+    @Inject
+    private AccessStackAdapter accessStackAdapter;
 
     protected boolean skipTests() {
-        return !getAccessStackAdapter().supportsLobs();
+        return accessStackAdapter.supportsLobs();
     }
 
     protected boolean skipEmptyLOBTests() {
-        return !getAccessStackAdapter().handlesNullVsEmptyLOBs();
+        return accessStackAdapter.handlesNullVsEmptyLOBs();
     }
 
     public void testEmptyBlob() throws Exception {
@@ -84,12 +94,12 @@ public class DataContextBlobTest extends
         };
 
         // insert new blob
-        ctxt.newObject(BlobTestEntity.class);
-        ctxt.commitChanges();
+        context.newObject(BlobTestEntity.class);
+        context.commitChanges();
 
         // read the BLOB in the new context
-        DataContext ctxt2 = createDataContext();
-        List<?> objects2 = ctxt2.performQuery(new SelectQuery(BlobTestEntity.class));
+
+        List<?> objects2 = context2.performQuery(new SelectQuery(BlobTestEntity.class));
         assertEquals(1, objects2.size());
 
         BlobTestEntity blobObj2 = (BlobTestEntity) objects2.get(0);
@@ -97,11 +107,10 @@ public class DataContextBlobTest extends
 
         // update and save Blob
         blobObj2.setBlobCol(bytes2);
-        ctxt2.commitChanges();
+        context2.commitChanges();
 
         // read into yet another context and check for changes
-        DataContext ctxt3 = createDataContext();
-        List<?> objects3 = ctxt3.performQuery(new SelectQuery(BlobTestEntity.class));
+        List<?> objects3 = context3.performQuery(new SelectQuery(BlobTestEntity.class));
         assertEquals(1, objects3.size());
 
         BlobTestEntity blobObj3 = (BlobTestEntity) objects3.get(0);
@@ -111,7 +120,7 @@ public class DataContextBlobTest extends
 
     protected void runWithBlobSize(int sizeBytes) throws Exception {
         // insert new clob
-        BlobTestEntity blobObj1 = ctxt.newObject(BlobTestEntity.class);
+        BlobTestEntity blobObj1 = context.newObject(BlobTestEntity.class);
 
         // init BLOB of a specified size
         byte[] bytes = new byte[sizeBytes];
@@ -120,26 +129,24 @@ public class DataContextBlobTest extends
         }
 
         blobObj1.setBlobCol(bytes);
-        ctxt.commitChanges();
+        context.commitChanges();
 
         // read the CLOB in the new context
-        DataContext ctxt2 = createDataContext();
-        List<?> objects2 = ctxt2.performQuery(new SelectQuery(BlobTestEntity.class));
+        List<?> objects2 = context2.performQuery(new SelectQuery(BlobTestEntity.class));
         assertEquals(1, objects2.size());
 
         BlobTestEntity blobObj2 = (BlobTestEntity) objects2.get(0);
         ByteArrayTypeTest.assertByteArraysEqual(blobObj1.getBlobCol(), blobObj2
                 .getBlobCol());
 
-        // update and save Clob
+        // update and save Blob
         blobObj2.setBlobCol(new byte[] {
                 '1', '2'
         });
-        ctxt2.commitChanges();
+        context2.commitChanges();
 
         // read into yet another context and check for changes
-        DataContext ctxt3 = createDataContext();
-        List<?> objects3 = ctxt3.performQuery(new SelectQuery(BlobTestEntity.class));
+        List<?> objects3 = context3.performQuery(new SelectQuery(BlobTestEntity.class));
         assertEquals(1, objects3.size());
 
         BlobTestEntity blobObj3 = (BlobTestEntity) objects3.get(0);



Mime
View raw message