You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/03/01 19:25:54 UTC
[isis] branch master updated: ISIS-1886 porting QueryResultCache
back into applib
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 5aee57b ISIS-1886 porting QueryResultCache back into applib
5aee57b is described below
commit 5aee57bcd5ed9815ab8477a859b920d4383d55fa
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Mar 1 20:25:51 2018 +0100
ISIS-1886 porting QueryResultCache back into applib
(from applib-legacy)
---
.../queryresultscache/QueryResultCacheControl.java | 23 +++
.../QueryResultsCacheInternal.java} | 59 +------
.../QueryResultsCacheControlUsingAxon.java | 56 ++++++
.../QueryResultsCacheUsingAxonTest.java} | 26 +--
.../QueryResultsCacheControlUsingGuava.java | 56 ++++++
.../QueryResultsCacheUsingGuava.java | 188 ---------------------
...t.java => QueryResultsCacheUsingGuavaTest.java} | 26 +--
7 files changed, 165 insertions(+), 269 deletions(-)
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultCacheControl.java b/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultCacheControl.java
new file mode 100644
index 0000000..8e9000e
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultCacheControl.java
@@ -0,0 +1,23 @@
+/*
+ * 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.isis.applib.services.queryresultscache;
+
+public interface QueryResultCacheControl {
+
+ public boolean isFixturesInstalling();
+
+}
diff --git a/core/plugins/eventbus-axon/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxon.java b/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheInternal.java
similarity index 69%
rename from core/plugins/eventbus-axon/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxon.java
rename to core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheInternal.java
index 8bffb59..12e994e 100644
--- a/core/plugins/eventbus-axon/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxon.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheInternal.java
@@ -1,33 +1,13 @@
-/*
- * 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.isis.applib.services.queryresultscache;
-
import java.util.Map;
import java.util.concurrent.Callable;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
-import org.apache.isis.applib.AbstractSubscriber;
import org.apache.isis.applib.annotation.DomainService;
import org.apache.isis.applib.annotation.NatureOfService;
import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.fixturescripts.events.FixturesInstalledEvent;
-import org.apache.isis.applib.fixturescripts.events.FixturesInstallingEvent;
import org.apache.isis.applib.internal.base._Casts;
import org.apache.isis.applib.internal.collections._Maps;
import org.apache.isis.applib.services.WithTransactionScope;
@@ -49,9 +29,9 @@ import org.slf4j.LoggerFactory;
menuOrder = "" + Integer.MAX_VALUE
)
@RequestScoped
-public class QueryResultsCacheUsingAxon implements QueryResultsCache, WithTransactionScope {
+public class QueryResultsCacheInternal implements QueryResultsCache, WithTransactionScope {
- private static final Logger LOG = LoggerFactory.getLogger(QueryResultsCacheUsingAxon.class);
+ private static final Logger LOG = LoggerFactory.getLogger(QueryResultsCacheInternal.class);
private final Map<Key, Value<?>> cache = _Maps.newHashMap();
@@ -150,39 +130,8 @@ public class QueryResultsCacheUsingAxon implements QueryResultsCache, WithTransa
cache.clear();
}
- /**
- * In separate class because {@link QueryResultsCache} itself is request-scoped
- */
- @DomainService(
- nature = NatureOfService.DOMAIN,
- menuOrder = "" + Integer.MAX_VALUE
- )
- public static class Control extends AbstractSubscriber {
-
- @Programmatic
- //@com.google.common.eventbus.Subscribe
- @org.axonframework.eventhandling.annotation.EventHandler
- public void on(FixturesInstallingEvent ev) {
- fixturesInstalling = true;
- }
-
- @Programmatic
- //@com.google.common.eventbus.Subscribe
- @org.axonframework.eventhandling.annotation.EventHandler
- public void on(FixturesInstalledEvent ev) {
- fixturesInstalling = false;
- }
-
- private boolean fixturesInstalling;
- @Programmatic
- public boolean isFixturesInstalling() {
- return fixturesInstalling;
- }
- }
-
@Inject
- protected Control control;
-
+ protected QueryResultCacheControl control;
-}
+}
\ No newline at end of file
diff --git a/core/plugins/eventbus-axon/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheControlUsingAxon.java b/core/plugins/eventbus-axon/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheControlUsingAxon.java
new file mode 100644
index 0000000..687e455
--- /dev/null
+++ b/core/plugins/eventbus-axon/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheControlUsingAxon.java
@@ -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.isis.applib.services.queryresultscache;
+
+import org.apache.isis.applib.AbstractSubscriber;
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.fixturescripts.events.FixturesInstalledEvent;
+import org.apache.isis.applib.fixturescripts.events.FixturesInstallingEvent;
+
+
+/**
+ * In separate class because {@link QueryResultsCache} itself is request-scoped
+ */
+@DomainService(
+ nature = NatureOfService.DOMAIN,
+ menuOrder = "" + Integer.MAX_VALUE
+ )
+public class QueryResultsCacheControlUsingAxon extends AbstractSubscriber implements QueryResultCacheControl {
+
+ @Programmatic
+ //@com.google.common.eventbus.Subscribe
+ @org.axonframework.eventhandling.annotation.EventHandler
+ public void on(FixturesInstallingEvent ev) {
+ fixturesInstalling = true;
+ }
+
+ @Programmatic
+ //@com.google.common.eventbus.Subscribe
+ @org.axonframework.eventhandling.annotation.EventHandler
+ public void on(FixturesInstalledEvent ev) {
+ fixturesInstalling = false;
+ }
+
+ private boolean fixturesInstalling;
+ @Programmatic
+ @Override
+ public boolean isFixturesInstalling() {
+ return fixturesInstalling;
+ }
+}
diff --git a/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheTest.java b/core/plugins/eventbus-axon/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxonTest.java
similarity index 81%
copy from core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheTest.java
copy to core/plugins/eventbus-axon/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxonTest.java
index 16508e5..2731000 100644
--- a/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheTest.java
+++ b/core/plugins/eventbus-axon/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingAxonTest.java
@@ -27,16 +27,16 @@ import org.apache.isis.applib.services.fixturespec.FixtureScriptsDefault;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public class QueryResultsCacheTest {
+public class QueryResultsCacheUsingAxonTest {
- private QueryResultsCacheUsingGuava queryResultsCache;
+ private QueryResultsCacheInternal queryResultsCache;
- QueryResultsCacheUsingGuava.Control control;
+ QueryResultsCacheControlUsingAxon control;
@Before
public void setUp() throws Exception {
- queryResultsCache = new QueryResultsCacheUsingGuava();
- control = new QueryResultsCacheUsingGuava.Control();
+ queryResultsCache = new QueryResultsCacheInternal();
+ control = new QueryResultsCacheControlUsingAxon();
queryResultsCache.control = control;
}
@@ -50,7 +50,7 @@ public class QueryResultsCacheTest {
return "foo";
}
- }, QueryResultsCacheTest.class, "execute");
+ }, QueryResultsCacheUsingAxonTest.class, "execute");
assertThat(value, is("foo"));
}
@@ -70,21 +70,21 @@ public class QueryResultsCacheTest {
};
assertThat(i[0], is(0));
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingAxonTest.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(1));
// should be a cache hit
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingAxonTest.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(1));
// changing any of the keys results in a cache miss
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "XXXcaching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingAxonTest.class, "XXXcaching", "a","b",1,2), is("foo"));
assertThat(i[0], is(2));
assertThat(queryResultsCache.execute(callable, QueryResultsCache.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(3));
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "XXX","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingAxonTest.class, "caching", "XXX","b",1,2), is("foo"));
assertThat(i[0], is(4));
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2, "x"), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingAxonTest.class, "caching", "a","b",1,2, "x"), is("foo"));
assertThat(i[0], is(5));
}
@@ -108,11 +108,11 @@ public class QueryResultsCacheTest {
// when, then (a cache miss)
assertThat(i[0], is(0));
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingAxonTest.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(1));
// when, then should also be a cache miss - would've been a hit previously
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingAxonTest.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(2));
}
diff --git a/core/plugins/eventbus-guava/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheControlUsingGuava.java b/core/plugins/eventbus-guava/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheControlUsingGuava.java
new file mode 100644
index 0000000..86d23ec
--- /dev/null
+++ b/core/plugins/eventbus-guava/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheControlUsingGuava.java
@@ -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.isis.applib.services.queryresultscache;
+
+import org.apache.isis.applib.AbstractSubscriber;
+import org.apache.isis.applib.annotation.DomainService;
+import org.apache.isis.applib.annotation.NatureOfService;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.fixturescripts.events.FixturesInstalledEvent;
+import org.apache.isis.applib.fixturescripts.events.FixturesInstallingEvent;
+
+
+/**
+ * In separate class because {@link QueryResultsCache} itself is request-scoped
+ */
+@DomainService(
+ nature = NatureOfService.DOMAIN,
+ menuOrder = "" + Integer.MAX_VALUE
+ )
+public class QueryResultsCacheControlUsingGuava extends AbstractSubscriber implements QueryResultCacheControl {
+
+ @Programmatic
+ @com.google.common.eventbus.Subscribe
+ //@org.axonframework.eventhandling.annotation.EventHandler
+ public void on(FixturesInstallingEvent ev) {
+ fixturesInstalling = true;
+ }
+
+ @Programmatic
+ @com.google.common.eventbus.Subscribe
+ //@org.axonframework.eventhandling.annotation.EventHandler
+ public void on(FixturesInstalledEvent ev) {
+ fixturesInstalling = false;
+ }
+
+ private boolean fixturesInstalling;
+ @Programmatic
+ @Override
+ public boolean isFixturesInstalling() {
+ return fixturesInstalling;
+ }
+}
diff --git a/core/plugins/eventbus-guava/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuava.java b/core/plugins/eventbus-guava/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuava.java
deleted file mode 100644
index 8ad6d25..0000000
--- a/core/plugins/eventbus-guava/src/main/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuava.java
+++ /dev/null
@@ -1,188 +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.isis.applib.services.queryresultscache;
-
-import java.util.Map;
-import java.util.concurrent.Callable;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-
-import org.apache.isis.applib.AbstractSubscriber;
-import org.apache.isis.applib.annotation.DomainService;
-import org.apache.isis.applib.annotation.NatureOfService;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.fixturescripts.events.FixturesInstalledEvent;
-import org.apache.isis.applib.fixturescripts.events.FixturesInstallingEvent;
-import org.apache.isis.applib.internal.base._Casts;
-import org.apache.isis.applib.internal.collections._Maps;
-import org.apache.isis.applib.services.WithTransactionScope;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This service (API and implementation) provides a mechanism by which idempotent query results can be cached for the duration of an interaction.
- * Most commonly this allows otherwise "naive" - eg that makes a repository call many times within a loop - to
- * be performance tuned. The benefit is that the algorithm of the business logic can remain easy to understand.
- *
- * <p>
- * This implementation has no UI and there is only one implementation (this class) in applib, it is annotated with
- * {@link org.apache.isis.applib.annotation.DomainService}. This means that it is automatically registered and
- * available for use; no further configuration is required.
- */
-@DomainService(
- nature = NatureOfService.DOMAIN,
- menuOrder = "" + Integer.MAX_VALUE
-)
-@RequestScoped
-public class QueryResultsCacheUsingGuava implements QueryResultsCache, WithTransactionScope {
-
- private static final Logger LOG = LoggerFactory.getLogger(QueryResultsCacheUsingGuava.class);
-
- private final Map<Key, Value<?>> cache = _Maps.newHashMap();
-
- @Programmatic
- @Override
- public <T> T execute(
- final Callable<T> callable,
- final Class<?> callingClass,
- final String methodName,
- final Object... keys) {
- if(control.isFixturesInstalling()) {
- try {
- return callable.call();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- final Key cacheKey = new Key(callingClass, methodName, keys);
- return executeWithCaching(callable, cacheKey);
- }
-
- @Programmatic
- private <T> T execute(final Callable<T> callable, final Key cacheKey) {
- if(control.isFixturesInstalling()) {
- try {
- return callable.call();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- return executeWithCaching(callable, cacheKey);
- }
-
- private <T> T executeWithCaching(final Callable<T> callable, final Key cacheKey) {
- try {
- final Value<?> cacheValue = cache.get(cacheKey);
- logHitOrMiss(cacheKey, cacheValue);
- if(cacheValue != null) {
- return _Casts.uncheckedCast(cacheValue.getResult());
- }
-
- // cache miss, so get the result...
- T result = callable.call();
-
- // ... and cache
- //
- // (it is possible that the callable just invoked might also have updated the cache, eg if there was
- // some sort of recursion. However, Map#put(...) is idempotent, so valid to call more than once.
- //
- // note: there's no need for thread-safety synchronization... remember that QueryResultsCache is @RequestScoped
- put(cacheKey, result);
-
- return result;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- @Programmatic
- private <T> Value<T> get(final Class<?> callingClass, final String methodName, final Object... keys) {
- return get(new Key(callingClass, methodName, keys));
- }
-
- @Programmatic
- @SuppressWarnings("unchecked")
- private <T> Value<T> get(final Key cacheKey) {
- Value<T> value = (Value<T>) cache.get(cacheKey);
- logHitOrMiss(cacheKey, value);
- return value;
- }
-
- @Programmatic
- private <T> void put(final Key cacheKey, final T result) {
- LOG.debug("PUT: {}", cacheKey);
- cache.put(cacheKey, new Value<T>(result));
- }
-
- private static void logHitOrMiss(final Key cacheKey, final Value<?> cacheValue) {
- if(!LOG.isDebugEnabled()) {
- return;
- }
- LOG.debug("{}: {}", (cacheValue != null ? "HIT" : "MISS"), cacheKey.toString());
- }
-
- /**
- * Not API: for framework to call at end of transaction, to clear out the cache.
- *
- * <p>
- * (This service really ought to be considered
- * a transaction-scoped service; since that isn't yet supported by the framework, we have to manually reset).
- * </p>
- */
- @Programmatic
- @Override
- public void resetForNextTransaction() {
- cache.clear();
- }
-
- /**
- * In separate class because {@link QueryResultsCache} itself is request-scoped
- */
- @DomainService(
- nature = NatureOfService.DOMAIN,
- menuOrder = "" + Integer.MAX_VALUE
- )
- public static class Control extends AbstractSubscriber {
-
- @Programmatic
- @com.google.common.eventbus.Subscribe
- //@org.axonframework.eventhandling.annotation.EventHandler
- public void on(FixturesInstallingEvent ev) {
- fixturesInstalling = true;
- }
-
- @Programmatic
- @com.google.common.eventbus.Subscribe
- //@org.axonframework.eventhandling.annotation.EventHandler
- public void on(FixturesInstalledEvent ev) {
- fixturesInstalling = false;
- }
-
- private boolean fixturesInstalling;
- @Programmatic
- public boolean isFixturesInstalling() {
- return fixturesInstalling;
- }
- }
-
-
- @Inject
- protected Control control;
-
-
-}
diff --git a/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheTest.java b/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuavaTest.java
similarity index 81%
rename from core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheTest.java
rename to core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuavaTest.java
index 16508e5..9d6ddf1 100644
--- a/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheTest.java
+++ b/core/plugins/eventbus-guava/src/test/java/org/apache/isis/applib/services/queryresultscache/QueryResultsCacheUsingGuavaTest.java
@@ -27,16 +27,16 @@ import org.apache.isis.applib.services.fixturespec.FixtureScriptsDefault;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public class QueryResultsCacheTest {
+public class QueryResultsCacheUsingGuavaTest {
- private QueryResultsCacheUsingGuava queryResultsCache;
+ private QueryResultsCacheInternal queryResultsCache;
- QueryResultsCacheUsingGuava.Control control;
+ QueryResultsCacheControlUsingGuava control;
@Before
public void setUp() throws Exception {
- queryResultsCache = new QueryResultsCacheUsingGuava();
- control = new QueryResultsCacheUsingGuava.Control();
+ queryResultsCache = new QueryResultsCacheInternal();
+ control = new QueryResultsCacheControlUsingGuava();
queryResultsCache.control = control;
}
@@ -50,7 +50,7 @@ public class QueryResultsCacheTest {
return "foo";
}
- }, QueryResultsCacheTest.class, "execute");
+ }, QueryResultsCacheUsingGuavaTest.class, "execute");
assertThat(value, is("foo"));
}
@@ -70,21 +70,21 @@ public class QueryResultsCacheTest {
};
assertThat(i[0], is(0));
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingGuavaTest.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(1));
// should be a cache hit
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingGuavaTest.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(1));
// changing any of the keys results in a cache miss
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "XXXcaching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingGuavaTest.class, "XXXcaching", "a","b",1,2), is("foo"));
assertThat(i[0], is(2));
assertThat(queryResultsCache.execute(callable, QueryResultsCache.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(3));
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "XXX","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingGuavaTest.class, "caching", "XXX","b",1,2), is("foo"));
assertThat(i[0], is(4));
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2, "x"), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingGuavaTest.class, "caching", "a","b",1,2, "x"), is("foo"));
assertThat(i[0], is(5));
}
@@ -108,11 +108,11 @@ public class QueryResultsCacheTest {
// when, then (a cache miss)
assertThat(i[0], is(0));
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingGuavaTest.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(1));
// when, then should also be a cache miss - would've been a hit previously
- assertThat(queryResultsCache.execute(callable, QueryResultsCacheTest.class, "caching", "a","b",1,2), is("foo"));
+ assertThat(queryResultsCache.execute(callable, QueryResultsCacheUsingGuavaTest.class, "caching", "a","b",1,2), is("foo"));
assertThat(i[0], is(2));
}
--
To stop receiving notification emails like this one, please contact
ahuber@apache.org.