You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2007/07/21 01:03:22 UTC

svn commit: r558191 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields: NonstandardMappingEntity.java TestPersistentMapTableConfiguration.java

Author: pcl
Date: Fri Jul 20 16:03:21 2007
New Revision: 558191

URL: http://svn.apache.org/viewvc?view=rev&rev=558191
Log:
Test that @ContainerTable annotation is properly read.

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/NonstandardMappingEntity.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/TestPersistentMapTableConfiguration.java

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/NonstandardMappingEntity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/NonstandardMappingEntity.java?view=auto&rev=558191
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/NonstandardMappingEntity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/NonstandardMappingEntity.java Fri Jul 20 16:03:21 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.fields;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.persistence.Entity;
+
+import org.apache.openjpa.persistence.PersistentMap;
+import org.apache.openjpa.persistence.jdbc.ContainerTable;
+
+@Entity
+public class NonstandardMappingEntity {
+    @PersistentMap
+    @ContainerTable(name="NONSTD_MAPPING_MAP")
+    private Map<String, String> map = new HashMap<String, String>();
+
+    public Map<String, String> getMap() {
+        return map;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/TestPersistentMapTableConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/TestPersistentMapTableConfiguration.java?view=auto&rev=558191
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/TestPersistentMapTableConfiguration.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fields/TestPersistentMapTableConfiguration.java Fri Jul 20 16:03:21 2007
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.fields;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.jdbc.meta.ClassMapping;
+
+public class TestPersistentMapTableConfiguration
+    extends SQLListenerTestCase {
+
+    public void setUp() {
+        setUp(NonstandardMappingEntity.class);
+    }
+
+    public void testPersistentMapMetaData() {
+        ClassMapping cm = (ClassMapping) OpenJPAPersistence.getMetaData(emf,
+            NonstandardMappingEntity.class);
+        assertEquals("NONSTD_MAPPING_MAP",
+            cm.getFieldMapping("map").getTable().getName());
+    }
+
+    public void testPersistentMapInsert() {
+        NonstandardMappingEntity e = new NonstandardMappingEntity();
+        OpenJPAEntityManager em = emf.createEntityManager();
+        em.getIdGenerator(NonstandardMappingEntity.class).allocate(1);
+        sql.clear();
+        try {
+            em.getTransaction().begin();
+            em.persist(e);
+            e.getMap().put("foo", "bar");
+            em.flush();
+            assertEquals(2, sql.size());
+            assertSQL(".*NONSTD_MAPPING_MAP.*");
+        } finally {
+            if (em.getTransaction().isActive())
+                em.getTransaction().rollback();
+        }
+    }
+}
\ No newline at end of file