openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r492027 - in /incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc: ./ meta/ meta/TestMappingToolAutoDelete.java
Date Wed, 03 Jan 2007 02:50:45 GMT
Author: pcl
Date: Tue Jan  2 18:50:44 2007
New Revision: 492027

URL: http://svn.apache.org/viewvc?view=rev&rev=492027
Log:
adding forgotten new file for previous commit

Added:
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolAutoDelete.java

Added: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolAutoDelete.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolAutoDelete.java?view=auto&rev=492027
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolAutoDelete.java
(added)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingToolAutoDelete.java
Tue Jan  2 18:50:44 2007
@@ -0,0 +1,61 @@
+package org.apache.openjpa.jdbc.meta;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Persistence;
+
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.schema.SchemaTool;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.simple.AllFieldTypes;
+
+import junit.framework.TestCase;
+
+
+public class TestMappingToolAutoDelete
+    extends TestCase {
+
+    private JDBCConfiguration _conf;
+    private OpenJPAEntityManagerFactory emf;
+
+    public void setUp() {
+        Map props = new HashMap();
+        props.put("openjpa.MetaDataFactory",
+            "jpa(Types=" + AllFieldTypes.class.getName() + ")");
+        emf = OpenJPAPersistence.cast( 
+            Persistence.createEntityManagerFactory("test", props));
+        _conf = (JDBCConfiguration) emf.getConfiguration();
+        
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.persist(new AllFieldTypes());
+        em.getTransaction().commit();
+        em.close();
+    }
+    
+    public void tearDown() {
+        emf.close();
+    }
+
+    public void testMappingToolAutoDelete() 
+        throws IOException, SQLException {
+        MappingTool.Flags flags = new MappingTool.Flags();
+        
+        // indirect validation that comma-separated schema actions work
+        flags.schemaAction = SchemaTool.ACTION_ADD + "," 
+            + SchemaTool.ACTION_DELETE_TABLE_CONTENTS;
+        
+        MappingTool.run(_conf, new String[0], flags, null);
+
+        EntityManager em = emf.createEntityManager();
+        assertEquals(Long.valueOf(0), 
+            em.createQuery("select count(o) from AllFieldTypes o")
+                .getSingleResult());
+        em.close();
+    }
+}



Mime
View raw message