[infinispan-commits] Infinispan SVN: r1266 - in trunk/query/src: test/java/org/infinispan/query/blackbox and 1 other directory.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Wed Dec 9 13:40:30 EST 2009
Author: manik.surtani at jboss.com
Date: 2009-12-09 13:40:29 -0500 (Wed, 09 Dec 2009)
New Revision: 1266
Modified:
trunk/query/src/main/java/org/infinispan/query/backend/QueryHelper.java
trunk/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java
trunk/query/src/test/java/org/infinispan/query/blackbox/KeyTypeTest.java
trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java
trunk/query/src/test/java/org/infinispan/query/blackbox/MarshalledValueClusteredQueryTest.java
trunk/query/src/test/java/org/infinispan/query/blackbox/MarshalledValueQueryTest.java
Log:
Updated to use config bean and break reliance on system properties.
Modified: trunk/query/src/main/java/org/infinispan/query/backend/QueryHelper.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/backend/QueryHelper.java 2009-12-09 18:16:53 UTC (rev 1265)
+++ trunk/query/src/main/java/org/infinispan/query/backend/QueryHelper.java 2009-12-09 18:40:29 UTC (rev 1266)
@@ -6,6 +6,7 @@
import org.infinispan.AdvancedCache;
import org.infinispan.Cache;
import org.infinispan.CacheException;
+import org.infinispan.config.Configuration;
import org.infinispan.factories.ComponentRegistry;
import org.infinispan.factories.InterceptorChainFactory;
import org.infinispan.interceptors.LockingInterceptor;
@@ -36,9 +37,6 @@
public class QueryHelper {
- public static final String QUERY_ENABLED_PROPERTY = "infinispan.query.enabled";
- public static final String QUERY_INDEX_LOCAL_ONLY_PROPERTY = "infinispan.query.indexLocalOnly";
-
private Cache cache;
private Properties properties;
private Class[] classes;
@@ -86,7 +84,7 @@
SearchConfiguration cfg = new SearchableCacheConfiguration(classes, properties);
searchFactory = new SearchFactoryImpl(cfg);
- applyProperties();
+ applyProperties(cache.getConfiguration().getQueryConfigurationBean());
}
/**
@@ -104,24 +102,17 @@
* indexed.
*/
- private void applyProperties() {
+ private void applyProperties(Configuration.QueryConfigurationBean qcb) {
if (log.isDebugEnabled()) log.debug("Entered QueryHelper.applyProperties()");
- // If the query property is set to true, i.e. we want to query objects in the cache, then we need to add the QueryInterceptor.
- boolean query = Boolean.getBoolean(QUERY_ENABLED_PROPERTY);
+ if (qcb.isEnabled()) {
- if (query) {
-
- boolean indexLocal = Boolean.getBoolean(QUERY_INDEX_LOCAL_ONLY_PROPERTY);
-
try {
- if (indexLocal) {
+ if (qcb.isIndexLocalOnly()) {
// Add a LocalQueryInterceptor to the chain
initComponents(LocalQueryInterceptor.class);
- }
- // We're indexing data even if it comes from other sources
-
- else {
+ } else {
+ // We're indexing data even if it comes from other sources
// Add in a QueryInterceptor to the chain
initComponents(QueryInterceptor.class);
}
Modified: trunk/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java 2009-12-09 18:16:53 UTC (rev 1265)
+++ trunk/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java 2009-12-09 18:40:29 UTC (rev 1266)
@@ -6,9 +6,11 @@
import org.apache.lucene.search.Query;
import org.infinispan.Cache;
import org.infinispan.config.Configuration;
+import org.infinispan.interceptors.base.CommandInterceptor;
import org.infinispan.query.CacheQuery;
import org.infinispan.query.QueryFactory;
import org.infinispan.query.backend.QueryHelper;
+import org.infinispan.query.backend.QueryInterceptor;
import org.infinispan.query.helper.TestQueryHelperFactory;
import org.infinispan.query.test.Person;
import org.infinispan.test.MultipleCacheManagersTest;
@@ -46,7 +48,6 @@
}
protected void createCacheManagers() throws Throwable {
-
Configuration cacheCfg = new Configuration();
cacheCfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
cacheCfg.setFetchInMemoryState(false);
@@ -55,17 +56,20 @@
cache1 = caches.get(0);
cache2 = caches.get(1);
- }
- @BeforeMethod
- public void setUp() {
+ Configuration.QueryConfigurationBean qcb = new Configuration.QueryConfigurationBean();
+ qcb.setEnabled(true);
+
// We will put objects into cache1 and then try and run the queries on cache2. This would mean that indexLocal
// must be set to false.
+ qcb.setIndexLocalOnly(false);
+ cache1.getConfiguration().setQueryConfigurationBean(qcb);
+ cache2.getConfiguration().setQueryConfigurationBean(qcb);
+ }
- System.setProperty(QueryHelper.QUERY_ENABLED_PROPERTY, "true");
- System.setProperty(QueryHelper.QUERY_INDEX_LOCAL_ONLY_PROPERTY, "false");
-
+ @BeforeMethod
+ public void setUp() {
qh = TestQueryHelperFactory.createTestQueryHelperInstance(cache2, Person.class);
TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
@@ -119,14 +123,21 @@
}
+ private void assertQueryInterceptorPresent(Cache<?, ?> c) {
+ CommandInterceptor i = TestingUtil.findInterceptor(c, QueryInterceptor.class);
+ assert i != null : "Expected to find a QueryInterceptor, only found " + c.getAdvancedCache().getInterceptorChain();
+ }
+
public void testModified() throws ParseException {
+ assertQueryInterceptorPresent(cache2);
+
queryParser = new QueryParser("blurb", new StandardAnalyzer());
luceneQuery = queryParser.parse("playing");
cacheQuery = new QueryFactory(cache2, qh).getQuery(luceneQuery);
found = cacheQuery.list();
- assert found.size() == 1;
+ assert found.size() == 1 : "Expected list of size 1, was of size " + found.size();
assert found.get(0).equals(person1);
person1.setBlurb("Likes pizza");
Modified: trunk/query/src/test/java/org/infinispan/query/blackbox/KeyTypeTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/blackbox/KeyTypeTest.java 2009-12-09 18:16:53 UTC (rev 1265)
+++ trunk/query/src/test/java/org/infinispan/query/blackbox/KeyTypeTest.java 2009-12-09 18:40:29 UTC (rev 1266)
@@ -38,14 +38,15 @@
protected CacheManager createCacheManager() throws Exception {
Configuration c = new Configuration();
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ Configuration.QueryConfigurationBean qcb = new Configuration.QueryConfigurationBean();
+ qcb.setEnabled(true);
+ qcb.setIndexLocalOnly(false);
+ c.setQueryConfigurationBean(qcb);
return TestCacheManagerFactory.createCacheManager(c, true);
}
@BeforeMethod (alwaysRun = true)
public void setUp() throws Exception{
- System.setProperty(QueryHelper.QUERY_ENABLED_PROPERTY, "true");
- System.setProperty(QueryHelper.QUERY_INDEX_LOCAL_ONLY_PROPERTY, "true");
-
CacheManager manager = createCacheManager();
cache = manager.getCache();
qh = new QueryHelper(cache, new Properties(), Person.class);
Modified: trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java 2009-12-09 18:16:53 UTC (rev 1265)
+++ trunk/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java 2009-12-09 18:40:29 UTC (rev 1266)
@@ -2,7 +2,6 @@
import org.infinispan.config.Configuration;
import org.infinispan.manager.CacheManager;
-import org.infinispan.query.backend.QueryHelper;
import org.infinispan.query.helper.TestQueryHelperFactory;
import org.infinispan.query.test.Person;
import org.infinispan.test.fwk.TestCacheManagerFactory;
@@ -20,16 +19,16 @@
protected CacheManager createCacheManager() throws Exception {
Configuration c = new Configuration();
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ Configuration.QueryConfigurationBean qcb = new Configuration.QueryConfigurationBean();
+ qcb.setEnabled(true);
+ qcb.setIndexLocalOnly(false);
+ c.setQueryConfigurationBean(qcb);
return TestCacheManagerFactory.createCacheManager(c, true);
}
@BeforeMethod
public void setUp() throws Exception {
- System.setProperty(QueryHelper.QUERY_ENABLED_PROPERTY, "true");
- System.setProperty(QueryHelper.QUERY_INDEX_LOCAL_ONLY_PROPERTY, "true");
-
-
cache = createCacheManager().getCache();
qh = TestQueryHelperFactory.createTestQueryHelperInstance(cache, Person.class);
Modified: trunk/query/src/test/java/org/infinispan/query/blackbox/MarshalledValueClusteredQueryTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/blackbox/MarshalledValueClusteredQueryTest.java 2009-12-09 18:16:53 UTC (rev 1265)
+++ trunk/query/src/test/java/org/infinispan/query/blackbox/MarshalledValueClusteredQueryTest.java 2009-12-09 18:40:29 UTC (rev 1266)
@@ -32,6 +32,14 @@
cache1 = caches.get(0);
cache2 = caches.get(1);
+ Configuration.QueryConfigurationBean qcb = new Configuration.QueryConfigurationBean();
+ qcb.setEnabled(true);
+
+
+ // We will put objects into cache1 and then try and run the queries on cache2. This would mean that indexLocal
+ // must be set to false.
+ qcb.setIndexLocalOnly(false);
+ cache1.getConfiguration().setQueryConfigurationBean(qcb);
+ cache2.getConfiguration().setQueryConfigurationBean(qcb);
}
-
}
Modified: trunk/query/src/test/java/org/infinispan/query/blackbox/MarshalledValueQueryTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/blackbox/MarshalledValueQueryTest.java 2009-12-09 18:16:53 UTC (rev 1265)
+++ trunk/query/src/test/java/org/infinispan/query/blackbox/MarshalledValueQueryTest.java 2009-12-09 18:40:29 UTC (rev 1266)
@@ -24,6 +24,9 @@
Configuration c = new Configuration();
c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
c.setUseLazyDeserialization(true);
+ Configuration.QueryConfigurationBean qcb = new Configuration.QueryConfigurationBean();
+ qcb.setEnabled(true);
+ c.setQueryConfigurationBean(qcb);
return TestCacheManagerFactory.createCacheManager(c, true);
}
More information about the infinispan-commits
mailing list