openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jrba...@apache.org
Subject svn commit: r915838 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test: java/org/apache/openjpa/persistence/cache/jpa/ resources/META-INF/
Date Wed, 24 Feb 2010 16:01:27 GMT
Author: jrbauer
Date: Wed Feb 24 16:01:26 2010
New Revision: 915838

URL: http://svn.apache.org/viewvc?rev=915838&view=rev
Log:
OPENJPA-1529 Committing L2 shared cache mode test cases contributed by Dianne Richards.

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeAll.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeDisableSelective.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeEnableSelective.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeInvalid.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeNone.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeUnspecified.java
  (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/caching-persistence-invalid.xml
  (with props)
Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/AbstractCacheTestCase.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeAll.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeDisableSelective.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEmpty.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEnableSelective.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeNone.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeUnspecified.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/AbstractCacheTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/AbstractCacheTestCase.java?rev=915838&r1=915837&r2=915838&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/AbstractCacheTestCase.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/AbstractCacheTestCase.java
Wed Feb 24 16:01:26 2010
@@ -19,6 +19,8 @@
 package org.apache.openjpa.persistence.cache.jpa;
 
 import java.lang.reflect.Modifier;
+import java.util.Map;
+import java.util.Set;
 
 import javax.persistence.EntityManager;
 
@@ -60,13 +62,21 @@
         em.close();
     }
 
-    public OpenJPAEntityManagerFactorySPI createEntityManagerFactory(String puName) {
+    public OpenJPAEntityManagerFactorySPI createEntityManagerFactory(String puName,
+        Map<String, Object> additionalProperties) {
+        Map<String, Object> propertiesMap = getPropertiesMap("openjpa.DataCache", "true",
+            "openjpa.QueryCache", "true",
+            "openjpa.RemoteCommitProvider", "sjvm", persistentTypes, 
+            "openjpa.jdbc.JDBCListeners", new JDBCListener [] { getListener() });
+        if (additionalProperties != null) {
+            Set<String> keys = additionalProperties.keySet();
+            for (String key : keys) {
+                propertiesMap.put(key, additionalProperties.get(key));
+            }
+        }
         OpenJPAEntityManagerFactorySPI emf =
             (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory(puName,
-                "META-INF/caching-persistence.xml", getPropertiesMap("openjpa.DataCache",
"true",
-                    "openjpa.QueryCache", "true",
-                    "openjpa.RemoteCommitProvider", "sjvm", persistentTypes, 
-                    "openjpa.jdbc.JDBCListeners", new JDBCListener [] { getListener() } ));
+                "META-INF/caching-persistence.xml", propertiesMap );
         return emf;
     }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeAll.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeAll.java?rev=915838&r1=915837&r2=915838&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeAll.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeAll.java
Wed Feb 24 16:01:26 2010
@@ -39,7 +39,7 @@
     @Override
     public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
         if (emf == null) {
-            emf = createEntityManagerFactory("cache-mode-all");
+            emf = createEntityManagerFactory("cache-mode-all",null);
             assertNotNull(emf);
             cache = emf.getCache();
             assertNotNull(cache);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeDisableSelective.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeDisableSelective.java?rev=915838&r1=915837&r2=915838&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeDisableSelective.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeDisableSelective.java
Wed Feb 24 16:01:26 2010
@@ -47,7 +47,7 @@
     @Override
     public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
         if (emf == null) {
-            emf = createEntityManagerFactory("cache-mode-disable");
+            emf = createEntityManagerFactory("cache-mode-disable", null);
             assertNotNull(emf);
             cache = emf.getCache();
             assertNotNull(cache);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEmpty.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEmpty.java?rev=915838&r1=915837&r2=915838&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEmpty.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEmpty.java
Wed Feb 24 16:01:26 2010
@@ -38,7 +38,7 @@
     @Override
     public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
         if (emf == null) {
-            emf = createEntityManagerFactory("cache-mode-empty");
+            emf = createEntityManagerFactory("cache-mode-empty", null);
             assertNotNull(emf);
             cache = emf.getCache();
             assertNotNull(cache);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEnableSelective.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEnableSelective.java?rev=915838&r1=915837&r2=915838&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEnableSelective.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeEnableSelective.java
Wed Feb 24 16:01:26 2010
@@ -47,7 +47,7 @@
     @Override
     public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
         if (emf == null) {
-            emf = createEntityManagerFactory("cache-mode-enable");
+            emf = createEntityManagerFactory("cache-mode-enable", null);
             assertNotNull(emf);
             cache = emf.getCache();
             assertNotNull(cache);

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java?rev=915838&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java
Wed Feb 24 16:01:26 2010
@@ -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.cache.jpa;
+
+import java.util.Map;
+
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+
+public class TestCacheModeInvalid extends AbstractCacheTestCase {
+
+    private static OpenJPAEntityManagerFactorySPI emf = null;
+    
+    @Override
+    public void setUp() {}
+    
+    public void testInvalidElement() {
+        try {
+            Map<String, Object> propertiesMap = getPropertiesMap("openjpa.DataCache",
"true",
+                "openjpa.QueryCache", "true",
+                "openjpa.RemoteCommitProvider", "sjvm", persistentTypes, 
+                "openjpa.jdbc.JDBCListeners", new JDBCListener [] { getListener() });
+            emf = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory("cache-mode-invalid",
+                "META-INF/caching-persistence-invalid.xml", propertiesMap );
+        } catch (Throwable e) {
+            assertException(e, org.apache.openjpa.util.GeneralException.class);
+            String msg = e.getMessage();
+            assertTrue(msg.contains("org.xml.sax.SAXException"));
+        }
+    }
+
+    @Override
+    public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
+        return null;
+    }
+
+    @Override
+    public JDBCListener getListener() {
+        return null;
+    }
+ 
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeInvalid.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeNone.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeNone.java?rev=915838&r1=915837&r2=915838&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeNone.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeNone.java
Wed Feb 24 16:01:26 2010
@@ -39,7 +39,7 @@
     @Override
     public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
         if (emf == null) {
-            emf = createEntityManagerFactory("cache-mode-none");
+            emf = createEntityManagerFactory("cache-mode-none",null);
             assertNotNull(emf);
             cache = emf.getCache();
             assertNotNull(cache);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeUnspecified.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeUnspecified.java?rev=915838&r1=915837&r2=915838&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeUnspecified.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestCacheModeUnspecified.java
Wed Feb 24 16:01:26 2010
@@ -38,7 +38,7 @@
     @Override
     public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
         if (emf == null) {
-            emf = createEntityManagerFactory("cache-mode-unspecified");
+            emf = createEntityManagerFactory("cache-mode-unspecified", null);
             assertNotNull(emf);
             cache = emf.getCache();
             assertNotNull(cache);

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeAll.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeAll.java?rev=915838&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeAll.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeAll.java
Wed Feb 24 16:01:26 2010
@@ -0,0 +1,86 @@
+/*
+ * 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.cache.jpa;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.Cache;
+
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+
+public class TestPropertyCacheModeAll extends AbstractCacheModeTestCase {
+
+    private static OpenJPAEntityManagerFactorySPI emf = null;
+    private static Cache cache = null;
+    private static List<String> sql = new ArrayList<String>();
+    private static JDBCListener listener;
+    
+    private static Class<?>[] expectedInCache = persistentTypes;
+    private static Class<?>[] expectedNotInCache = {};
+
+    @Override
+    public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
+        if (emf == null) {
+            Map<String, Object> propertyMap = new HashMap<String, Object>();
+            propertyMap.put("javax.persistence.sharedCache.mode", "ALL");
+            emf = createEntityManagerFactory("cache-mode-empty",propertyMap);
+            assertNotNull(emf);
+            cache = emf.getCache();
+            assertNotNull(cache);
+        }
+        return emf;
+    }
+
+    public JDBCListener getListener() {
+        if (listener == null) {
+            listener = new Listener();
+        }
+        return listener;
+    }
+    
+    public List<String> getSql() { 
+        return sql;
+    }
+    
+    public void testCacheables() {
+        assertCacheables(cache, true);
+    }
+
+    public void testUncacheables() {
+        assertUncacheables(cache, true);
+    }
+
+    public void testUnspecified() {
+        assertUnspecified(cache, true);
+    }
+
+    @Override
+    protected Class<?>[] getExpectedInCache() {
+        return expectedInCache;
+    }
+
+    @Override
+    protected Class<?>[] getExpectedNotInCache() {
+        return expectedNotInCache;
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeDisableSelective.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeDisableSelective.java?rev=915838&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeDisableSelective.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeDisableSelective.java
Wed Feb 24 16:01:26 2010
@@ -0,0 +1,94 @@
+/*
+ * 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.cache.jpa;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.Cache;
+
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.cache.jpa.model.CacheableEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.NegatedUncacheableEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.UncacheableEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.UnspecifiedEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.XmlCacheableEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.XmlUncacheableEntity;
+
+public class TestPropertyCacheModeDisableSelective extends AbstractCacheModeTestCase {
+
+    private static OpenJPAEntityManagerFactorySPI emf = null;
+    private static Cache cache = null;
+    private static List<String> sql = new ArrayList<String>();
+    private static JDBCListener listener;
+    
+    private static Class<?>[] expectedInCache =
+        { CacheableEntity.class, XmlCacheableEntity.class, NegatedUncacheableEntity.class,
UnspecifiedEntity.class, };
+    private static Class<?>[] expectedNotInCache =
+        { UncacheableEntity.class, XmlUncacheableEntity.class, };
+
+    @Override
+    public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
+        if (emf == null) {
+            Map<String, Object> propertyMap = new HashMap<String, Object>();
+            propertyMap.put("javax.persistence.sharedCache.mode", "DISABLE_SELECTIVE");
+            emf = createEntityManagerFactory("cache-mode-empty", propertyMap);
+            assertNotNull(emf);
+            cache = emf.getCache();
+            assertNotNull(cache);
+        }
+        return emf;
+    }
+
+    public JDBCListener getListener() {
+        if (listener == null) {
+            listener = new Listener();
+        }
+        return listener;
+    }
+
+    public List<String> getSql() {
+        return sql;
+    }
+
+    public void testCacheables() {
+        assertCacheables(cache, true);
+    }
+
+    public void testUncacheables() {
+        assertUncacheables(cache, false);
+    }
+
+    public void testUnspecified() {
+        assertUnspecified(cache, true);
+    }
+    
+    @Override
+    protected Class<?>[] getExpectedInCache() {
+        return expectedInCache;
+    }
+
+    @Override
+    protected Class<?>[] getExpectedNotInCache() {
+        return expectedNotInCache;
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeDisableSelective.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeEnableSelective.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeEnableSelective.java?rev=915838&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeEnableSelective.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeEnableSelective.java
Wed Feb 24 16:01:26 2010
@@ -0,0 +1,99 @@
+/*
+ * 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.cache.jpa;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.Cache;
+
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.cache.jpa.model.CacheableEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.NegatedUncacheableEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.UncacheableEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.UnspecifiedEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.XmlCacheableEntity;
+import org.apache.openjpa.persistence.cache.jpa.model.XmlUncacheableEntity;
+
+public class TestPropertyCacheModeEnableSelective extends AbstractCacheModeTestCase {
+
+    private static OpenJPAEntityManagerFactorySPI emf = null;
+    private static Cache cache = null;
+    private static List<String> sql = new ArrayList<String>();
+    private static JDBCListener listener;
+
+    private static Class<?>[] expectedInCache =
+        { CacheableEntity.class, XmlCacheableEntity.class, NegatedUncacheableEntity.class,
};
+    private static Class<?>[] expectedNotInCache =
+        { UncacheableEntity.class, XmlUncacheableEntity.class, UnspecifiedEntity.class, };
+
+    @Override
+    public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
+        if (emf == null) {
+            Map<String, Object> propertyMap = new HashMap<String, Object>();
+            propertyMap.put("javax.persistence.sharedCache.mode", "ENABLE_SELECTIVE");
+            emf = createEntityManagerFactory("cache-mode-empty", propertyMap);
+            assertNotNull(emf);
+            cache = emf.getCache();
+            assertNotNull(cache);
+        }
+        return emf;
+    }
+
+    public JDBCListener getListener() {
+        if (listener == null) {
+            listener = new Listener();
+        }
+        return listener;
+    }
+
+    public List<String> getSql() {
+        return sql;
+    }
+
+    @Override
+    protected Class<?>[] getExpectedInCache() {
+        return expectedInCache;
+    }
+
+    @Override
+    protected Class<?>[] getExpectedNotInCache() {
+        return expectedNotInCache;
+    }
+    
+    // =======================================================================
+    // Tests
+    // =======================================================================
+    
+    public void testCacheables() {
+        assertCacheables(cache, true);
+    }
+
+    public void testUncacheables() {
+        assertUncacheables(cache, false);
+    }
+
+    public void testUnspecified() {
+        assertUnspecified(cache, false);
+    }
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeEnableSelective.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeInvalid.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeInvalid.java?rev=915838&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeInvalid.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeInvalid.java
Wed Feb 24 16:01:26 2010
@@ -0,0 +1,56 @@
+/*
+ * 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.cache.jpa;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+
+public class TestPropertyCacheModeInvalid extends AbstractCacheTestCase {
+
+    private static OpenJPAEntityManagerFactorySPI emf = null;
+    
+    @Override
+    public void setUp() {}
+    
+    public void testInvalidPropertyValue() {
+        try {
+            Map<String, Object> propertyMap = new HashMap<String, Object>();
+            propertyMap.put("javax.persistence.sharedCache.mode", "INVALID");
+            emf = createEntityManagerFactory("cache-mode-empty",propertyMap);
+        } catch (Throwable e) {
+            assertException(e, java.lang.IllegalArgumentException.class);
+            String msg = e.getMessage();
+            assertTrue(msg.contains("javax.persistence.SharedCacheMode.INVALID"));
+        }
+    }
+
+    @Override
+    public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
+        return null;
+    }
+
+    @Override
+    public JDBCListener getListener() {
+        return null;
+    }
+ 
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeInvalid.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeNone.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeNone.java?rev=915838&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeNone.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeNone.java
Wed Feb 24 16:01:26 2010
@@ -0,0 +1,92 @@
+/*
+ * 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.cache.jpa;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.Cache;
+
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+
+public class TestPropertyCacheModeNone extends AbstractCacheModeTestCase {
+
+    private static OpenJPAEntityManagerFactorySPI emf = null;
+    private static Cache cache = null;
+    private static List<String> sql = new ArrayList<String>();
+    private static JDBCListener listener;
+    
+    private static Class<?>[] expectedInCache = {}; 
+    private static Class<?>[] expectedNotInCache = persistentTypes;
+
+    @Override
+    public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
+        if (emf == null) {
+            Map<String, Object> propertyMap = new HashMap<String, Object>();
+            propertyMap.put("javax.persistence.sharedCache.mode", "NONE");
+            emf = createEntityManagerFactory("cache-mode-empty", propertyMap);
+            assertNotNull(emf);
+            cache = emf.getCache();
+            assertNotNull(cache);
+        }
+        return emf;
+    }
+
+    public JDBCListener getListener() {
+        if (listener == null) {
+            listener = new Listener();
+        }
+        return listener;
+    }
+
+    public List<String> getSql() {
+        return sql;
+    }
+    
+    @Override
+    public boolean getCacheEnabled() {
+        return false;
+    }
+
+    public void testCacheables() {
+        assertCacheables(cache, false);
+    }
+
+    public void testUncacheables() {
+        assertUncacheables(cache, false);
+    }
+
+    public void testUnspecified() {
+        assertUnspecified(cache, false);
+    }
+    
+    @Override
+    protected Class<?>[] getExpectedInCache() {
+        return expectedInCache;
+    }
+
+    @Override
+    protected Class<?>[] getExpectedNotInCache() {
+        return expectedNotInCache;
+    }
+
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeNone.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeUnspecified.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeUnspecified.java?rev=915838&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeUnspecified.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeUnspecified.java
Wed Feb 24 16:01:26 2010
@@ -0,0 +1,85 @@
+/*
+ * 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.cache.jpa;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.Cache;
+
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+
+public class TestPropertyCacheModeUnspecified extends AbstractCacheModeTestCase {
+    private static OpenJPAEntityManagerFactorySPI emf = null;
+    private static Cache cache = null;
+    private static List<String> sql = new ArrayList<String>();
+    private static JDBCListener listener;
+    
+    private static Class<?>[] expectedInCache = persistentTypes;
+    private static Class<?>[] expectedNotInCache = {};
+
+    @Override
+    public OpenJPAEntityManagerFactorySPI getEntityManagerFactory() {
+        if (emf == null) {
+            Map<String, Object> propertyMap = new HashMap<String, Object>();
+            propertyMap.put("javax.persistence.sharedCache.mode", "UNSPECIFIED");
+            emf = createEntityManagerFactory("cache-mode-empty", propertyMap);
+            assertNotNull(emf);
+            cache = emf.getCache();
+            assertNotNull(cache);
+        }
+        return emf;
+    }
+
+    public JDBCListener getListener() {
+        if (listener == null) {
+            listener = new Listener();
+        }
+        return listener;
+    }
+    
+    public List<String> getSql() { 
+        return sql;
+    }
+    
+    public void testCacheables() {
+        assertCacheables(cache, true);
+    }
+
+    public void testUncacheables() {
+        assertUncacheables(cache, true);
+    }
+
+    public void testUnspecified() {
+        assertUnspecified(cache, true);
+    }
+
+    @Override
+    protected Class<?>[] getExpectedInCache() {
+        return expectedInCache;
+    }
+
+    @Override
+    protected Class<?>[] getExpectedNotInCache() {
+        return expectedNotInCache;
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/cache/jpa/TestPropertyCacheModeUnspecified.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/caching-persistence-invalid.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/caching-persistence-invalid.xml?rev=915838&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/caching-persistence-invalid.xml
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/caching-persistence-invalid.xml
Wed Feb 24 16:01:26 2010
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.   
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+    version="2.0">
+    <!--  Caching Persistence Units -->
+    <persistence-unit name="cache-mode-invalid">
+        <mapping-file>META-INF/caching-orm.xml</mapping-file>
+        <shared-cache-mode>INVALID</shared-cache-mode>
+        <properties>
+            <!-- Connection info is passed in via system properties -->
+            <!-- Cache configuration ie openjpa.DataCache is passed in at EMF initialization
-->
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"
/>
+        </properties>
+    </persistence-unit>
+</persistence>

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/caching-persistence-invalid.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message