cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [12/30] cayenne git commit: CAY-2377. Cleanup org.apache.cayenne.cache
Date Thu, 07 Dec 2017 10:09:41 GMT
CAY-2377. Cleanup org.apache.cayenne.cache


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/47a8795f
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/47a8795f
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/47a8795f

Branch: refs/heads/master
Commit: 47a8795fd2f8b396bb67ac61c0423681d581ff24
Parents: a10d4ba
Author: Arseni Bulatski <ancarseni@gmail.com>
Authored: Thu Nov 9 08:59:16 2017 +0300
Committer: Arseni Bulatski <ancarseni@gmail.com>
Committed: Wed Nov 15 10:27:47 2017 +0300

----------------------------------------------------------------------
 .../apache/cayenne/cache/EhCacheQueryCache.java | 198 ---------
 .../org/apache/cayenne/cache/OSQueryCache.java  | 401 -------------------
 .../DataContextQueryCachingEhCacheIT.java       |  60 ---
 .../DataContextQueryCachingOSCacheIT.java       |  48 ---
 .../cayenne/cache/EhCacheQueryCacheTest.java    | 132 ------
 .../cache/EhCacheQueryCache_WithConfigTest.java |  90 -----
 .../apache/cayenne/cache/OSQueryCacheTest.java  | 138 -------
 docs/doc/src/main/resources/UPGRADE.txt         |   5 +-
 8 files changed, 2 insertions(+), 1070 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/47a8795f/cayenne-server/src/main/java/org/apache/cayenne/cache/EhCacheQueryCache.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/cache/EhCacheQueryCache.java
b/cayenne-server/src/main/java/org/apache/cayenne/cache/EhCacheQueryCache.java
deleted file mode 100644
index 5eff2cd..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/cache/EhCacheQueryCache.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*****************************************************************
- *   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.cayenne.cache;
-
-import java.util.List;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.di.BeforeScopeEnd;
-import org.apache.cayenne.query.QueryMetadata;
-import org.slf4j.Logger;
-
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-import org.slf4j.LoggerFactory;
-
-/**
- * @deprecated since 4.0 please use JCacheQueryCache (provided by "cayenne-jcache" module)
- */
-@Deprecated
-public class EhCacheQueryCache implements QueryCache {
-
-    /**
-     * Default cache group name.
-     */
-    private static final String DEFAULT_CACHE_NAME = "cayenne.default.cachegroup";
-
-    private static final Logger logger = LoggerFactory.getLogger(EhCacheQueryCache.class);
-
-    protected CacheManager cacheManager;
-
-    public EhCacheQueryCache() {
-        cacheManager = new CacheManager();
-        init();
-    }
-
-    public EhCacheQueryCache(String configFile) {
-        cacheManager = new CacheManager(configFile);
-        init();
-    }
-
-    public EhCacheQueryCache(CacheManager cacheManager) {
-        if (cacheManager != null) {
-            this.cacheManager = cacheManager;
-            init();
-        } else {
-            throw new CayenneRuntimeException("CacheManager cannot be null.");
-        }
-    }
-
-    private void init() {
-        cacheManager.addCacheIfAbsent(DEFAULT_CACHE_NAME);
-    }
-
-    @SuppressWarnings("rawtypes")
-    public List get(QueryMetadata metadata) {
-        String key = metadata.getCacheKey();
-        if (key == null) {
-            return null;
-        }
-
-        String cacheName = cacheName(metadata);
-        Ehcache cache = cacheManager.getCache(cacheName);
-
-        if (cache == null) {
-            return null;
-        }
-
-        Element result = cache.get(key);
-        return result != null ? (List) result.getObjectValue() : null;
-    }
-
-    @SuppressWarnings("rawtypes")
-    public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
-
-        String key = metadata.getCacheKey();
-        if (key == null) {
-            // TODO: we should really throw here... The method declares that it
-            // never returns null
-            return null;
-        }
-
-        String cacheName = cacheName(metadata);
-
-        // create empty cache for cache group here, as we have a factory to
-        // create an object, and should never ever return null from this
-        // method.
-        Ehcache cache = cacheManager.addCacheIfAbsent(cacheName);
-        Element result = cache.get(key);
-
-        if (result != null) {
-            return (List) result.getObjectValue();
-        }
-
-        // if no result in cache locking the key to write
-        // and putting it to the cache
-        cache.acquireWriteLockOnKey(key);
-        try {
-
-            // now that we locked the key, let's reread the cache again, in case
-            // an object appeared there already
-            result = cache.get(key);
-
-            if (result != null) {
-                return (List) result.getObjectValue();
-            }
-
-            // if not succeeded in reading again putting
-            // object to the cache ourselves
-            List object = factory.createObject();
-            if (object == null) {
-                throw new CayenneRuntimeException("Null object created: %s", metadata.getCacheKey());
-            }
-
-            cache.put(new Element(key, object));
-            return object;
-
-        } finally {
-            cache.releaseWriteLockOnKey(key);
-        }
-    }
-
-    /**
-     * @since 4.0
-     */
-	protected String cacheName(QueryMetadata metadata) {
-		if (metadata.getCacheGroup() != null) {
-			return metadata.getCacheGroup();
-		}
-
-		return DEFAULT_CACHE_NAME;
-	}
-
-    @SuppressWarnings("rawtypes")
-    public void put(QueryMetadata metadata, List results) {
-        String key = metadata.getCacheKey();
-        if (key != null) {
-            String cacheName = cacheName(metadata);
-            Ehcache cache = cacheManager.addCacheIfAbsent(cacheName);
-            cache.put(new Element(key, results));
-        }
-    }
-
-    public void remove(String key) {
-        if (key != null) {
-            for (String cache : cacheManager.getCacheNames()) {
-                cacheManager.getCache(cache).remove(key);
-            }
-        }
-    }
-
-    public void removeGroup(String groupKey) {
-        Ehcache cache = cacheManager.getEhcache(groupKey);
-        if(cache != null) {
-            cache.removeAll();
-        }
-    }
-
-    public void removeGroup(String groupKey, Class<?> keyType, Class<?> valueType)
{
-        removeGroup(groupKey);
-    }
-
-    public void clear() {
-        cacheManager.removalAll();
-    }
-
-    public int size() {
-        int size = 0;
-        for (String cache : cacheManager.getCacheNames()) {
-            size += cacheManager.getCache(cache).getSize();
-        }
-        return size;
-    }
-
-    /**
-     * Shuts down EhCache CacheManager
-     */
-    @BeforeScopeEnd
-    public void shutdown() {
-        cacheManager.shutdown();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47a8795f/cayenne-server/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/cache/OSQueryCache.java b/cayenne-server/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
deleted file mode 100644
index 70e1bb0..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
+++ /dev/null
@@ -1,401 +0,0 @@
-/*****************************************************************
- *   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.cayenne.cache;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.di.BeforeScopeEnd;
-import org.apache.cayenne.query.QueryMetadata;
-
-import com.opensymphony.oscache.base.CacheEntry;
-import com.opensymphony.oscache.base.NeedsRefreshException;
-import com.opensymphony.oscache.general.GeneralCacheAdministrator;
-
-/**
- * A {@link QueryCache} implementation based on OpenSymphony OSCache. Query cache
- * parameters are initialized from "/oscache.properties" file per <a
- * href="http://www.opensymphony.com/oscache/wiki/Configuration.html">OSCache</a>
- * documentation. In addition to the standard OSCache parameters, Cayenne provider allows
- * to setup global cache expiration parameters, and parameters matching the main query
- * cache group (i.e. the cache groups specified first). A sample oscache.properties may
- * look like this:
- * 
- * <pre>
- * # OSCache configuration file
- *                        
- * # OSCache standard configuration per
- * #     http://www.opensymphony.com/oscache/wiki/Configuration.html
- * # ---------------------------------------------------------------
- *                        
- * #cache.memory=true
- * #cache.blocking=false
- * cache.capacity=5000
- * cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache
- *                        
- * # Cayenne specific properties
- * # ---------------------------------------------------------------
- *                        
- * # Default refresh period in seconds:
- * cayenne.default.refresh = 60
- *                        
- * # Default expiry specified as cron expressions per
- * #    http://www.opensymphony.com/oscache/wiki/Cron%20Expressions.html
- * # expire entries every hour on the 10's minute
- * cayenne.default.cron = 10 * * * *
- *                        
- * # Same parameters can be overridden per query
- * cayenne.group.xyz.refresh = 120
- * cayenne.group.xyz.cron = 10 1 * * *
- * </pre>
- * 
- * Further extension of OSQueryCache is possible by using OSCache listener API.
- * 
- * @since 3.0
- * @deprecated since 4.0 as OSCache project is abandoned
- */
-@Deprecated
-public class OSQueryCache implements QueryCache {
-
-    public static final int DEFAULT_REFRESH_PERIOD = CacheEntry.INDEFINITE_EXPIRY;
-
-    static String DEFAULT_REFRESH_KEY = "cayenne.default.refresh";
-    static String DEFAULT_CRON_KEY = "cayenne.default.cron";
-
-    static String GROUP_PREFIX = "cayenne.group.";
-    static String REFRESH_SUFFIX = ".refresh";
-    static String CRON_SUFFIX = ".cron";
-
-    protected GeneralCacheAdministrator osCache;
-
-    RefreshSpecification defaultRefreshSpecification;
-    Map<String, RefreshSpecification> refreshSpecifications;
-    Properties properties;
-
-    public OSQueryCache() {
-        OSCacheAdministrator admin = new OSCacheAdministrator();
-        init(admin, admin.getProperties());
-    }
-
-    public OSQueryCache(GeneralCacheAdministrator cache, Properties properties) {
-        init(cache, properties);
-    }
-
-    /**
-     * Returns a collection of group names that have been configured explicitly via
-     * properties.
-     */
-    @SuppressWarnings("rawtypes")
-    public Collection getGroupNames() {
-        return refreshSpecifications != null
-                ? Collections.unmodifiableCollection(refreshSpecifications.keySet())
-                : Collections.EMPTY_SET;
-    }
-
-    public String getCronExpression(String groupName) {
-
-        RefreshSpecification spec = null;
-
-        if (refreshSpecifications != null) {
-            spec = refreshSpecifications.get(groupName);
-        }
-
-        if (spec == null) {
-            spec = defaultRefreshSpecification;
-        }
-
-        return spec.cronExpression;
-    }
-
-    public int getRrefreshPeriod(String groupName) {
-
-        RefreshSpecification spec = null;
-
-        if (refreshSpecifications != null) {
-            spec = refreshSpecifications.get(groupName);
-        }
-
-        if (spec == null) {
-            spec = defaultRefreshSpecification;
-        }
-
-        return spec.refreshPeriod;
-    }
-
-    /**
-     * Returns the underlying OSCache manager object.
-     */
-    public GeneralCacheAdministrator getOsCache() {
-        return osCache;
-    }
-
-    /**
-     * Returns configuration properties. Usually this is the contents of
-     * "oscache.properties" file.
-     */
-    public Properties getProperties() {
-        return properties;
-    }
-
-    void init(GeneralCacheAdministrator cache, Properties properties) {
-        this.properties = properties;
-        this.osCache = cache;
-        this.defaultRefreshSpecification = new RefreshSpecification();
-
-        // load defaults and per-query settings
-        if (properties != null) {
-
-            // first extract defaults...
-            String defaultRefresh = properties.getProperty(DEFAULT_REFRESH_KEY);
-            if (defaultRefresh != null) {
-                defaultRefreshSpecification.setRefreshPeriod(defaultRefresh);
-            }
-
-            String defaultCron = properties.getProperty(DEFAULT_CRON_KEY);
-            if (defaultCron != null) {
-                defaultRefreshSpecification.cronExpression = defaultCron;
-            }
-
-            // now check for per-query settings
-            for (final Map.Entry<Object, Object> entry : properties.entrySet()) {
-
-                if (entry.getKey() == null || entry.getValue() == null) {
-                    continue;
-                }
-
-                String key = entry.getKey().toString();
-                if (key.startsWith(GROUP_PREFIX)) {
-
-                    if (key.endsWith(REFRESH_SUFFIX)) {
-                        String name = key.substring(GROUP_PREFIX.length(), key.length()
-                                - REFRESH_SUFFIX.length());
-
-                        initRefreshPolicy(name, entry.getValue());
-                    }
-                    else if (key.endsWith(CRON_SUFFIX)) {
-                        String name = key.substring(GROUP_PREFIX.length(), key.length()
-                                - CRON_SUFFIX.length());
-
-                        initCronPolicy(name, entry.getValue());
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Called internally for each group that is configured with cron policy in the
-     * properties. Exposed mainly for the benefit of subclasses. When overriding, call
-     * 'super'.
-     */
-    protected void initCronPolicy(String groupName, Object value) {
-        nonNullSpec(groupName).cronExpression = value != null ? value.toString() : null;
-    }
-
-    /**
-     * Called internally for each group that is configured with refresh policy in the
-     * properties. Exposed mainly for the benefit of subclasses. When overriding, call
-     * 'super'.
-     */
-    protected void initRefreshPolicy(String groupName, Object value) {
-        nonNullSpec(groupName).setRefreshPeriod(value);
-    }
-
-    private RefreshSpecification nonNullSpec(String name) {
-        if (refreshSpecifications == null) {
-            refreshSpecifications = new HashMap<>();
-        }
-
-        RefreshSpecification spec = refreshSpecifications.get(name);
-        if (spec == null) {
-            spec = new RefreshSpecification();
-            spec.cronExpression = defaultRefreshSpecification.cronExpression;
-            spec.refreshPeriod = defaultRefreshSpecification.refreshPeriod;
-            refreshSpecifications.put(name, spec);
-        }
-
-        return spec;
-    }
-
-    @SuppressWarnings("rawtypes")
-    public List get(QueryMetadata metadata) {
-        String key = metadata.getCacheKey();
-        if (key == null) {
-            return null;
-        }
-
-        RefreshSpecification refresh = getRefreshSpecification(metadata);
-
-        try {
-            return (List) osCache.getFromCache(
-                    key,
-                    refresh.refreshPeriod,
-                    refresh.cronExpression);
-        }
-        catch (NeedsRefreshException e) {
-            osCache.cancelUpdate(key);
-            return null;
-        }
-    }
-
-    /**
-     * Returns a non-null cached value. If it is not present in the cache, it is obtained
-     * by calling {@link QueryCacheEntryFactory#createObject()}. Whether the cache
-     * provider will block on the entry update or not is controlled by "cache.blocking"
-     * configuration property and is "false" by default.
-     */
-    @SuppressWarnings("rawtypes")
-    public List get(QueryMetadata metadata, QueryCacheEntryFactory factory) {
-        String key = metadata.getCacheKey();
-        if (key == null) {
-            return null;
-        }
-
-        RefreshSpecification refresh = getRefreshSpecification(metadata);
-
-        try {
-            return (List) osCache.getFromCache(
-                    key,
-                    refresh.refreshPeriod,
-                    refresh.cronExpression);
-        }
-        catch (NeedsRefreshException e) {
-            boolean updated = false;
-            try {
-                List result = factory.createObject();
-                if (result == null) {
-                    throw new CayenneRuntimeException("Null on cache rebuilding: %s", metadata.getCacheKey());
-                }
-                put(metadata, result);
-                updated = true;
-                return result;
-            } finally {
-                if (!updated) {
-                    // It is essential that cancelUpdate is called if the
-                    // cached content could not be rebuilt
-                    osCache.cancelUpdate(key);
-                }
-            }
-        }
-    }
-
-    /**
-     * Returns non-null RefreshSpecification for the QueryMetadata.
-     */
-    RefreshSpecification getRefreshSpecification(QueryMetadata metadata) {
-
-        RefreshSpecification refresh = null;
-
-        if (refreshSpecifications != null) {
-            String group = metadata.getCacheGroup();
-            if (group != null) {
-                refresh = refreshSpecifications.get(group);
-            }
-        }
-
-        return refresh != null ? refresh : defaultRefreshSpecification;
-    }
-
-    @SuppressWarnings("rawtypes")
-    public void put(QueryMetadata metadata, List results) {
-        String key = metadata.getCacheKey();
-        if (key != null) {
-            osCache.putInCache(key, results, new String[]{metadata.getCacheGroup()});
-        }
-    }
-
-    public void remove(String key) {
-        if (key != null) {
-            osCache.removeEntry(key);
-        }
-    }
-
-    public void removeGroup(String groupKey) {
-        if (groupKey != null) {
-            osCache.flushGroup(groupKey);
-        }
-    }
-
-    public void removeGroup(String groupKey, Class<?> keyType, Class<?> valueType)
{
-        removeGroup(groupKey);
-    }
-
-    public void clear() {
-        osCache.flushAll();
-    }
-
-    public int size() {
-        return osCache.getCache().getSize();
-    }
-
-    public int capacity() {
-        return osCache.getCache().getCapacity();
-    }
-    
-    /**
-     * Shuts down EhCache CacheManager
-     */
-    @BeforeScopeEnd
-    public void shutdown() {
-        osCache.destroy();
-    }
-
-    final static class RefreshSpecification {
-
-        int refreshPeriod;
-        String cronExpression;
-
-        RefreshSpecification() {
-            this.refreshPeriod = DEFAULT_REFRESH_PERIOD;
-        }
-
-        RefreshSpecification(int refrehsPeriod, String cronExpression) {
-            this.refreshPeriod = refrehsPeriod;
-            this.cronExpression = cronExpression;
-        }
-
-        void setRefreshPeriod(Object value) {
-            try {
-                refreshPeriod = Integer.parseInt(value.toString());
-            }
-            catch (NumberFormatException e) {
-                // ignore...
-            }
-        }
-    }
-
-    final static class OSCacheAdministrator extends GeneralCacheAdministrator {
-
-        OSCacheAdministrator() {
-        }
-
-        OSCacheAdministrator(Properties properties) {
-            super(properties);
-        }
-
-        Properties getProperties() {
-            return super.config.getProperties();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47a8795f/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextQueryCachingEhCacheIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextQueryCachingEhCacheIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextQueryCachingEhCacheIT.java
deleted file mode 100644
index 129de52..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextQueryCachingEhCacheIT.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*****************************************************************
- *   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.cayenne.access;
-
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.unit.di.server.CayenneProjects;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-import org.junit.After;
-import org.junit.Before;
-
-@SuppressWarnings("deprecation")
-@UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
-public class DataContextQueryCachingEhCacheIT extends DataContextQueryCachingIT {
-    
-    protected org.apache.cayenne.cache.EhCacheQueryCache domainCache;
-    protected org.apache.cayenne.cache.EhCacheQueryCache contextCache;
-
-    @Before
-    public void setUp() throws Exception {
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
-
-        tPainting = new TableHelper(dbHelper, "PAINTING");
-        tPainting.setColumns(
-                "PAINTING_ID",
-                "PAINTING_TITLE",
-                "ARTIST_ID",
-                "ESTIMATED_PRICE");
-
-        domain = context.getParentDataDomain();
-        oldCache = domain.getQueryCache();
-        
-        domainCache = new org.apache.cayenne.cache.EhCacheQueryCache();
-        contextCache = new org.apache.cayenne.cache.EhCacheQueryCache();
-        domain.setQueryCache(domainCache);
-        context.setQueryCache(contextCache);
-    }
-    
-    @After
-    public void tearDown() throws Exception {
-        domainCache.shutdown();
-        contextCache.shutdown();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47a8795f/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextQueryCachingOSCacheIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextQueryCachingOSCacheIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextQueryCachingOSCacheIT.java
deleted file mode 100644
index 0d7a8bb..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextQueryCachingOSCacheIT.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*****************************************************************
- *   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.cayenne.access;
-
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.unit.di.server.CayenneProjects;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-import org.junit.Before;
-
-@SuppressWarnings("deprecation")
-@UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
-public class DataContextQueryCachingOSCacheIT extends DataContextQueryCachingIT {
-
-    // runs super tests with a different setup...
-    @Before
-    public void setUp() throws Exception {
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
-
-        tPainting = new TableHelper(dbHelper, "PAINTING");
-        tPainting.setColumns(
-                "PAINTING_ID",
-                "PAINTING_TITLE",
-                "ARTIST_ID",
-                "ESTIMATED_PRICE");
-
-        domain = context.getParentDataDomain();
-        oldCache = domain.getQueryCache();
-        domain.setQueryCache(new org.apache.cayenne.cache.OSQueryCache());
-        context.setQueryCache(new org.apache.cayenne.cache.OSQueryCache());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47a8795f/cayenne-server/src/test/java/org/apache/cayenne/cache/EhCacheQueryCacheTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/cache/EhCacheQueryCacheTest.java
b/cayenne-server/src/test/java/org/apache/cayenne/cache/EhCacheQueryCacheTest.java
deleted file mode 100644
index cd6e96b..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/cache/EhCacheQueryCacheTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*****************************************************************
- *   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.cayenne.cache;
-
-import net.sf.ehcache.CacheManager;
-import org.apache.cayenne.query.QueryMetadata;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@SuppressWarnings("deprecation")
-public class EhCacheQueryCacheTest {
-
-    private CacheManager cacheManager;
-
-    @Before
-    public void setUp() throws Exception {
-        cacheManager = new CacheManager();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cacheManager.shutdown();
-    }
-
-    @Test
-    public void testGet() {
-
-        EhCacheQueryCache cache = new EhCacheQueryCache(cacheManager);
-
-        QueryMetadata md = mock(QueryMetadata.class);
-        when(md.getCacheKey()).thenReturn("k1");
-
-        assertNull(cache.get(md));
-
-        List<?> results = new ArrayList<Object>();
-        cache.put(md, results);
-        assertSame(results, cache.get(md));
-    }
-
-    @Test
-    public void testGet_WithFactory() {
-
-        EhCacheQueryCache cache = new EhCacheQueryCache(cacheManager);
-
-        ArrayList[] lists = new ArrayList[] { new ArrayList<>(), new ArrayList<>(),
new ArrayList<>() };
-        QueryCacheEntryFactory factory = mock(QueryCacheEntryFactory.class);
-        when(factory.createObject()).thenReturn(lists[0], lists[1], lists[2]);
-
-        QueryMetadata md = mock(QueryMetadata.class);
-        when(md.getCacheKey()).thenReturn("k1");
-
-        assertEquals(lists[0], cache.get(md, factory));
-        assertEquals(lists[0], cache.get(md, factory));
-        assertEquals(lists[0], cache.get(md, factory));
-
-        List<?> results = new ArrayList<Object>();
-        cache.put(md, results);
-        assertSame(results, cache.get(md));
-    }
-
-    @Test
-    public void testGet_WithFactory_WithCacheGroups() {
-
-        EhCacheQueryCache cache = new EhCacheQueryCache(cacheManager);
-
-        ArrayList[] lists = new ArrayList[] { new ArrayList<>(), new ArrayList<>(),
new ArrayList<>() };
-        QueryCacheEntryFactory factory = mock(QueryCacheEntryFactory.class);
-        when(factory.createObject()).thenReturn(lists[0], lists[1], lists[2]);
-
-        QueryMetadata md = mock(QueryMetadata.class);
-        when(md.getCacheKey()).thenReturn("k1");
-        when(md.getCacheGroup()).thenReturn("cg1");
-
-        assertEquals(lists[0], cache.get(md, factory));
-        assertEquals(lists[0], cache.get(md, factory));
-        assertEquals(lists[0], cache.get(md, factory));
-
-        List<?> results = new ArrayList<Object>();
-        cache.put(md, results);
-        assertSame(results, cache.get(md));
-    }
-
-    @Test
-    public void testRemoveGroup_WithFactory_WithCacheGroups() {
-
-        EhCacheQueryCache cache = new EhCacheQueryCache(cacheManager);
-
-        ArrayList[] lists = new ArrayList[] { new ArrayList<>(), new ArrayList<>(),
new ArrayList<>() };
-        QueryCacheEntryFactory factory = mock(QueryCacheEntryFactory.class);
-        when(factory.createObject()).thenReturn(lists[0], lists[1], lists[2]);
-
-        QueryMetadata md = mock(QueryMetadata.class);
-        when(md.getCacheKey()).thenReturn("k1");
-        when(md.getCacheGroup()).thenReturn("cg1");
-
-        assertEquals(lists[0], cache.get(md, factory));
-        assertEquals(lists[0], cache.get(md, factory));
-
-        cache.removeGroup("cg0");
-        assertEquals(lists[0], cache.get(md, factory));
-
-        cache.removeGroup("cg1");
-        assertEquals(lists[1], cache.get(md, factory));
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47a8795f/cayenne-server/src/test/java/org/apache/cayenne/cache/EhCacheQueryCache_WithConfigTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/cache/EhCacheQueryCache_WithConfigTest.java
b/cayenne-server/src/test/java/org/apache/cayenne/cache/EhCacheQueryCache_WithConfigTest.java
deleted file mode 100644
index 1596119..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/cache/EhCacheQueryCache_WithConfigTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*****************************************************************
- *   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.cayenne.cache;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import org.apache.cayenne.query.QueryMetadata;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.net.URL;
-import java.util.ArrayList;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@SuppressWarnings("deprecation")
-public class EhCacheQueryCache_WithConfigTest {
-
-    protected CacheManager cacheManager;
-
-    @Before
-    public void setUp() throws Exception {
-        URL config = getClass().getResource("test-ehcache.xml");
-        assertNotNull(config);
-        cacheManager = new CacheManager(config);
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        cacheManager.shutdown();
-    }
-
-    @Test
-    public void testRemoveGroup_WithFactory_WithCacheGroups() {
-
-        EhCacheQueryCache cache = new EhCacheQueryCache(cacheManager);
-
-        ArrayList[] lists = new ArrayList[] { new ArrayList<>(), new ArrayList<>(),
new ArrayList<>() };
-        QueryCacheEntryFactory factory = mock(QueryCacheEntryFactory.class);
-        when(factory.createObject()).thenReturn(lists[0], lists[1], lists[2]);
-
-        QueryMetadata md = mock(QueryMetadata.class);
-        when(md.getCacheKey()).thenReturn("k1");
-        when(md.getCacheGroup()).thenReturn("cg1");
-
-        assertEquals(lists[0], cache.get(md, factory));
-        assertEquals(lists[0], cache.get(md, factory));
-
-        Cache c1 = cache.cacheManager.getCache("cg1");
-        assertEquals(201, c1.getCacheConfiguration().getTimeToLiveSeconds());
-
-        // remove non-existing
-        cache.removeGroup("cg0");
-        assertEquals(lists[0], cache.get(md, factory));
-
-        Cache c2 = cache.cacheManager.getCache("cg1");
-        assertSame(c1, c2);
-        assertEquals(201, c2.getCacheConfiguration().getTimeToLiveSeconds());
-
-        cache.removeGroup("cg1");
-        assertEquals(lists[1], cache.get(md, factory));
-
-        // make sure the cache still has all the configured settings after
-        // 'removeGroup'
-        Cache c3 = cache.cacheManager.getCache("cg1");
-        assertSame(c1, c3);
-        assertEquals(201, c3.getCacheConfiguration().getTimeToLiveSeconds());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47a8795f/cayenne-server/src/test/java/org/apache/cayenne/cache/OSQueryCacheTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/cache/OSQueryCacheTest.java b/cayenne-server/src/test/java/org/apache/cayenne/cache/OSQueryCacheTest.java
deleted file mode 100644
index 45aaa1b..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/cache/OSQueryCacheTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*****************************************************************
- *   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.cayenne.cache;
-
-import com.opensymphony.oscache.base.CacheEntry;
-import com.opensymphony.oscache.general.GeneralCacheAdministrator;
-import org.apache.cayenne.query.MockQueryMetadata;
-import org.apache.cayenne.query.QueryMetadata;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-@SuppressWarnings("deprecation")
-public class OSQueryCacheTest {
-
-    @Test
-    public void testDefaults() {
-        OSQueryCache cache = new OSQueryCache();
-
-        assertNull(cache.refreshSpecifications);
-        assertNull(cache.defaultRefreshSpecification.cronExpression);
-        assertEquals(
-                CacheEntry.INDEFINITE_EXPIRY,
-                cache.defaultRefreshSpecification.refreshPeriod);
-    }
-
-    @Test
-    public void testDefaultOverrides() {
-
-        Properties props = new Properties();
-        props.put(OSQueryCache.DEFAULT_REFRESH_KEY, "15");
-        props.put(OSQueryCache.DEFAULT_CRON_KEY, "9 * * * * *");
-        OSQueryCache cache = new OSQueryCache(new GeneralCacheAdministrator(), props);
-
-        assertNull(cache.refreshSpecifications);
-        assertEquals("9 * * * * *", cache.defaultRefreshSpecification.cronExpression);
-        assertEquals(15, cache.defaultRefreshSpecification.refreshPeriod);
-    }
-
-    @Test
-    public void testQueryOverrides() {
-
-        Properties props = new Properties();
-        props.put(OSQueryCache.GROUP_PREFIX + "ABC" + OSQueryCache.REFRESH_SUFFIX, "25");
-        props.put(
-                OSQueryCache.GROUP_PREFIX + "ABC" + OSQueryCache.CRON_SUFFIX,
-                "12 * * * * *");
-        props.put(OSQueryCache.GROUP_PREFIX + "XYZ" + OSQueryCache.REFRESH_SUFFIX, "35");
-        props.put(
-                OSQueryCache.GROUP_PREFIX + "XYZ" + OSQueryCache.CRON_SUFFIX,
-                "24 * * * * *");
-
-        OSQueryCache cache = new OSQueryCache(new GeneralCacheAdministrator(), props);
-
-        assertNotNull(cache.refreshSpecifications);
-        assertEquals(2, cache.refreshSpecifications.size());
-
-        org.apache.cayenne.cache.OSQueryCache.RefreshSpecification abc = cache.refreshSpecifications.get("ABC");
-        assertNotNull(abc);
-        assertEquals("12 * * * * *", abc.cronExpression);
-        assertEquals(25, abc.refreshPeriod);
-
-        org.apache.cayenne.cache.OSQueryCache.RefreshSpecification xyz = cache.refreshSpecifications.get("XYZ");
-        assertNotNull(xyz);
-        assertEquals("24 * * * * *", xyz.cronExpression);
-        assertEquals(35, xyz.refreshPeriod);
-    }
-
-    @Test
-    public void testGroupNames() {
-
-        Properties props = new Properties();
-        OSQueryCache c1 = new OSQueryCache(new GeneralCacheAdministrator(), props);
-        assertTrue(c1.getGroupNames().isEmpty());
-
-        props.put(OSQueryCache.GROUP_PREFIX + "ABC" + OSQueryCache.REFRESH_SUFFIX, "25");
-        props.put(
-                OSQueryCache.GROUP_PREFIX + "XYZ" + OSQueryCache.CRON_SUFFIX,
-                "24 * * * * *");
-
-        OSQueryCache c2 = new OSQueryCache(new GeneralCacheAdministrator(), props);
-
-        assertEquals(2, c2.getGroupNames().size());
-
-        assertTrue(c2.getGroupNames().contains("ABC"));
-        assertTrue(c2.getGroupNames().contains("XYZ"));
-    }
-
-    @Test
-    public void testSize() {
-        OSQueryCache cache = new OSQueryCache();
-
-        List r1 = new ArrayList();
-        QueryMetadata m1 = new MockQueryMetadata() {
-
-            @Override
-            public String getCacheKey() {
-                return "a";
-            }
-        };
-        cache.put(m1, r1);
-        assertEquals(1, cache.size());
-        
-        List r2 = new ArrayList();
-        QueryMetadata m2 = new MockQueryMetadata() {
-
-            @Override
-            public String getCacheKey() {
-                return "b";
-            }
-        };
-        cache.put(m2, r2);
-        assertEquals(2, cache.size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47a8795f/docs/doc/src/main/resources/UPGRADE.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/UPGRADE.txt b/docs/doc/src/main/resources/UPGRADE.txt
index 14b8711..676d529 100644
--- a/docs/doc/src/main/resources/UPGRADE.txt
+++ b/docs/doc/src/main/resources/UPGRADE.txt
@@ -204,9 +204,6 @@ UPGRADING TO 4.1.M2
       - removed DataMap dataMap in org.apache.cayenne.query.QueryChain;
       - removed DataMap dataMap in org.apache.cayenne.query.BatchQuery;
       - removed void setDataMap(DataMap dataMap) in org.apache.cayenne.query.BatchQuery;
-      - change in void testGet_WithFactory_WithCacheGroups() from getCacheGroups() to getCacheGroup()
in org.apache.cayenne.cache.EhCacheQueryCacheTest;
-      - change in void testRemoveGroup_WithFactory_WithCacheGroups() from getCacheGroups()
to getCacheGroup() in org.apache.cayenne.cache.EhCacheQueryCacheTest;
-      - change in void testRemoveGroup_WithFactory_WithCacheGroups() from getCacheGroups()
to getCacheGroup() in org.apache.cayenne.cache.EhCacheQueryCacheTest_WithConfigTest;
       - change in void testUseSharedCache(): removed getCacheGroups() in org.apache.cayenne.query.SelectQueryCacheKeyIT;
       - removed in void testCreateReplacementQuery_Bare()  getCacheGroups() in org.apache.cayenne.queryObjectSelect_CompileIT;
       - removed in void testCreateReplacementQuery_Full()  getCacheGroups() in org.apache.cayenne.queryObjectSelect_CompileIT;
@@ -240,6 +237,8 @@ UPGRADING TO 4.1.M2
       - removed void getDataSourceLocation(String dataSourceLocation) from org.apache.cayenne.access.MockDataNode;
       - removed void getDataSourceLocation(String dataSourceLocation) {since 4.0. This information
is irrelevant at the DataNode level} from
       org.apache.cayenne.access.DataNode;
+      - removed OSQueryCache in org.apache.cayenne.cache with tests;
+      - removed EhCacheQueryCache in org.apache.cayenne.cache with tests;
 
 UPGRADING TO 4.1.M1
 


Mime
View raw message