openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtyle...@apache.org
Subject svn commit: r895040 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats: AbstractLobTest.java TestInputStreamLob.java
Date Fri, 01 Jan 2010 17:39:29 GMT
Author: mtylenda
Date: Fri Jan  1 17:39:28 2010
New Revision: 895040

URL: http://svn.apache.org/viewvc?rev=895040&view=rev
Log:
OPENJPA-1248: Test case refactored for easier control of LOB data creation, increased amount
of LOB data to a more realistic value (but still under MySQL default BLOB limit - 64 kB).

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/TestInputStreamLob.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java?rev=895040&r1=895039&r2=895040&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java
Fri Jan  1 17:39:28 2010
@@ -27,6 +27,7 @@
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.datacache.DataCachePCData;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
@@ -39,7 +40,7 @@
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 /**
- * This abstract class defines all the tests for LOBS.
+ * This abstract class defines all the tests for LOB streaming.
  *
  * @author Ignacio Andreu
  * @since 1.1.0
@@ -72,11 +73,11 @@
     }
 
     public void testInsert() {
-        insert(newLobEntity("oOOOOOo", 1));
+        insert(newLobEntity(createLobData(), 1));
     }
 
     public void testInsertAndSelect() throws IOException {
-        String s = "oooOOOooo";
+        String s = createLobData();
         insert(newLobEntity(s, 1));
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
@@ -100,11 +101,11 @@
     }
 
     public void testUpdate() throws IOException {
-        insert(newLobEntity("oOOOOOo", 1));
+        insert(newLobEntity(createLobData(), 1));
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
         LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1);
-        String string = "iIIIIIi";
+        String string = createLobData2();
         changeStream(entity, string);
         em.getTransaction().commit();
         em.close();
@@ -117,7 +118,7 @@
     }
 
     public void testUpdateWithNull() {
-        insert(newLobEntity("oOOOOOo", 1));
+        insert(newLobEntity(createLobData(), 1));
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
         LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1);
@@ -137,7 +138,7 @@
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
         LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1);
-        String string = "iIIIIIi";
+        String string = createLobData2();
         changeStream(entity, string);
         em.getTransaction().commit();
         em.close();
@@ -150,7 +151,7 @@
     }
     
     public void testDelete() {
-        insert(newLobEntity("oOOOOOo", 1));
+        insert(newLobEntity(createLobData(), 1));
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
         LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1);
@@ -168,21 +169,21 @@
     public void testLifeCycleInsertFlushModify() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
-        LobEntity le = newLobEntity("oOOOOOo", 1);
+        LobEntity le = newLobEntity(createLobData(), 1);
         em.persist(le);
         em.flush();
-        changeStream(le, "iIIIIIi");
+        changeStream(le, createLobData2());
         em.getTransaction().commit();
         em.close();
     }
 
     public void testLifeCycleLoadFlushModifyFlush() {
-        insert(newLobEntity("oOOOOOo", 1));
+        insert(newLobEntity(createLobData(), 1));
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
         LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1);
         em.flush();
-        changeStream(entity, "iIIIIIi");
+        changeStream(entity, createLobData2());
         em.flush();
         em.getTransaction().commit();
         em.close();
@@ -190,11 +191,11 @@
 
     public void testReadingMultipleTimesWithASingleConnection()
         throws IOException {
-        insert(newLobEntity("oOOOOOo", 1));
+        insert(newLobEntity(createLobData(), 1));
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
         LobEntity le = (LobEntity) em.find(getLobEntityClass(), 1);
-        String string = "iIIIIIi";
+        String string = createLobData2();
         changeStream(le, string);
         em.getTransaction().commit();
         em.close();
@@ -202,7 +203,7 @@
         em.getTransaction().begin();
         le = (LobEntity) em.find(getLobEntityClass(), 1);
         assertNotNull(le.getStream());
-        LobEntity entity = newLobEntity("oOOOOOo", 2);
+        LobEntity entity = newLobEntity(createLobData(), 2);
         em.persist(entity);
         assertEquals(string, getStreamContentAsString(le.getStream()));
         em.getTransaction().commit();
@@ -213,7 +214,7 @@
         OpenJPAEntityManager em = emf.createEntityManager();
 
         em.getTransaction().begin();
-        LobEntity le = newLobEntity("oOOOOOo", 1);
+        LobEntity le = newLobEntity(createLobData(), 1);
         em.persist(le);
         em.getTransaction().commit();
         OpenJPAConfiguration conf = emf.getConfiguration();
@@ -230,16 +231,17 @@
     public void testSetResetAndFlush() throws IOException {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
-        LobEntity le = newLobEntity("oOOOOOo", 1);
+        LobEntity le = newLobEntity(createLobData(), 1);
         em.persist(le);
-        changeStream(le, "iIIIIIi");
+        String string = createLobData2();
+        changeStream(le, string);
         em.flush();
         em.getTransaction().commit();
         em.close();
         em = emf.createEntityManager();
         em.getTransaction().begin();
         LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1);
-        assertEquals("iIIIIIi", getStreamContentAsString(entity.getStream()));
+        assertEquals(string, getStreamContentAsString(entity.getStream()));
         em.getTransaction().commit();
         em.close();
     }
@@ -247,16 +249,25 @@
     public void testSetFlushAndReset() throws IOException {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
-        LobEntity le = newLobEntity("oOOOOOo", 1);
+        LobEntity le = newLobEntity(createLobData(), 1);
         em.persist(le);
         em.flush();
-        changeStream(le, "iIIIIIi");
+        String string = createLobData2();
+        changeStream(le, string);
         LobEntity entity = (LobEntity) em.find(getLobEntityClass(), 1);
-        assertEquals("iIIIIIi", getStreamContentAsString(entity.getStream()));
+        assertEquals(string, getStreamContentAsString(entity.getStream()));
         em.getTransaction().commit();
         em.close();
     }
 
+    protected String createLobData() {
+        return StringUtils.repeat("ooOOOOoo, ", 3000);
+    }
+
+    protected String createLobData2() {
+        return StringUtils.repeat("iiIIIIii, ", 1000);
+    }
+
     protected abstract Class getLobEntityClass();
 
     protected abstract String getStreamContentAsString(Object o)

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/TestInputStreamLob.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/TestInputStreamLob.java?rev=895040&r1=895039&r2=895040&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/TestInputStreamLob.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/TestInputStreamLob.java
Fri Jan  1 17:39:28 2010
@@ -25,7 +25,7 @@
 import org.apache.openjpa.jdbc.sql.PostgresDictionary;
 
 /**
- * Defines all the abstract methods from AbstractLobTest to tests the
+ * Defines all the abstract methods from AbstractLobTest to test
  * the LOB support with an InputStream.
  *
  * @author Ignacio Andreu
@@ -69,7 +69,7 @@
     protected String getStreamContentAsString(Object o) throws IOException {
         InputStream is = (InputStream) o;
         String content = "";
-        byte[] bs = new byte[4];
+        byte[] bs = new byte[1024];
         int read = -1;
         do {
             read = is.read(bs);



Mime
View raw message