[jbosscache-commits] JBoss Cache SVN: r6724 - in searchable/trunk: src/main/java/org/jboss/cache/search and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Mon Sep 15 09:49:14 EDT 2008
Author: navssurtani
Date: 2008-09-15 09:49:14 -0400 (Mon, 15 Sep 2008)
New Revision: 6724
Added:
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheProfilerTest.java
Modified:
searchable/trunk/pom.xml
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIterator.java
searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionContext.java
searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheConfiguration.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java
Log:
Cleaned up PMD warnings from hudson
Modified: searchable/trunk/pom.xml
===================================================================
--- searchable/trunk/pom.xml 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/pom.xml 2008-09-15 13:49:14 UTC (rev 6724)
@@ -40,7 +40,13 @@
<version>1.0.4</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-pojo</artifactId>
+ <version>2.2.0.CR7</version>
+ </dependency>
+
<!-- Test dependencies -->
<dependency>
@@ -57,14 +63,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.cache</groupId>
- <artifactId>jbosscache-pojo</artifactId>
- <version>2.2.0.CR5</version>
- <scope>test</scope>
- </dependency>
-
-
</dependencies>
<build>
<plugins>
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -82,14 +82,6 @@
void setMaxResults(int numResults);
/**
- * Defines scrollable result fetch size
- *
- * @param size to be set
- */
-
- void setFetchSize(int size);
-
- /**
* Gets the integer number of results.
*
* @return integer number of results.
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.*;
import org.hibernate.HibernateException;
@@ -37,8 +36,6 @@
import org.hibernate.search.filter.ChainedFilter;
import org.hibernate.search.filter.FilterKey;
import org.hibernate.search.query.FullTextFilterImpl;
-import org.hibernate.search.reader.ReaderProvider;
-import static org.hibernate.search.reader.ReaderProviderHelper.getIndexReaders;
import org.hibernate.search.store.DirectoryProvider;
import org.hibernate.transform.ResultTransformer;
import org.jboss.cache.Cache;
@@ -73,7 +70,6 @@
private Set<Class> classesAndSubclasses;
private boolean needClassFilterClause;
private Query luceneQuery;
- private int fetchSize;
private String[] indexProjection;
private ResultTransformer resultTransformer;
CacheEntityLoader entityLoader;
@@ -360,16 +356,7 @@
}
this.maxResults = maxResults;
}
-
- public void setFetchSize(int fetchSize)
- {
- if (fetchSize <= 0)
- {
- throw new IllegalArgumentException("'fetch size' parameter less than or equals to 0");
- }
- this.fetchSize = fetchSize;
- }
-
+
private IndexSearcher buildSearcher(SearchFactoryImplementor searchFactoryImplementor)
{
Map<Class, DocumentBuilder<Object>> builders = searchFactoryImplementor.getDocumentBuilders();
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIterator.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIterator.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/LazyQueryResultIterator.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -22,7 +22,6 @@
package org.jboss.cache.search;
-import org.jboss.cache.search.CacheEntityLoader;
import org.hibernate.search.engine.DocumentExtractor;
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.apache.lucene.search.Hits;
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionContext.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionContext.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionContext.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -1,72 +1,72 @@
-///*
-// * JBoss, Home of Professional Open Source
-// * Copyright ${year}, Red Hat Middleware LLC, and individual contributors
-// * by the @authors tag. See the copyright.txt in the distribution for a
-// * full listing of individual contributors.
-// *
-// * This is free software; you can redistribute it and/or modify it
-// * under the terms of the GNU Lesser General Public License as
-// * published by the Free Software Foundation; either version 2.1 of
-// * the License, or (at your option) any later version.
-// *
-// * This software is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// * Lesser General Public License for more details.
-// *
-// * You should have received a copy of the GNU Lesser General Public
-// * License along with this software; if not, write to the Free
-// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-// * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-// */
-//
-//package org.jboss.cache.search;
-//
-//import org.hibernate.search.transaction.TransactionContext;
-//import org.jboss.cache.pojo.notification.event.Event;
-//
-//import javax.transaction.Synchronization;
-//import javax.transaction.Transaction;
-//
-///**
-// * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
-// */
-//public class PojoTransactionContext implements TransactionContext
-//{
-// Event event;
-//
-// public PojoTransactionContext(Event event)
-// {
-// if (event == null) throw new NullPointerException("event cannot be null");
-// this.event = event;
-//
-// }
-// public boolean isTxInProgress()
-// {
-// return (event.getContext().getTransaction() != null);
-//
-// }
-//
-// public Object getTransactionIdentifier()
-// {
-// return event.getContext().getTransaction();
-// }
-//
-// public void registerSynchronization(Synchronization synchronization)
-// {
-// Transaction transaction = event.getContext().getTransaction();
-//
-// if (transaction != null)
-// {
-//
-// try
-// {
-// transaction.registerSynchronization(synchronization);
-// }
-// catch (Exception e)
-// {
-// throw new RuntimeException(e);
-// }
-// }
-// }
-//}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cache.search;
+
+import org.hibernate.search.backend.TransactionContext;
+import org.jboss.cache.pojo.notification.event.Event;
+
+import javax.transaction.Synchronization;
+import javax.transaction.Transaction;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ */
+public class PojoTransactionContext implements TransactionContext
+{
+ Event event;
+
+ public PojoTransactionContext(Event event)
+ {
+ if (event == null) throw new NullPointerException("event cannot be null");
+ this.event = event;
+
+ }
+ public boolean isTransactionInProgress()
+ {
+ return (event.getContext().getTransaction() != null);
+
+ }
+
+ public Object getTransactionIdentifier()
+ {
+ return event.getContext().getTransaction();
+ }
+
+ public void registerSynchronization(Synchronization synchronization)
+ {
+ Transaction transaction = event.getContext().getTransaction();
+
+ if (transaction != null)
+ {
+
+ try
+ {
+ transaction.registerSynchronization(synchronization);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -22,7 +22,6 @@
package org.jboss.cache.search;
-import org.jboss.cache.Cache;
import java.util.List;
import java.util.NoSuchElementException;
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheConfiguration.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheConfiguration.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheConfiguration.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -23,8 +23,6 @@
package org.jboss.cache.search;
import org.hibernate.search.cfg.SearchConfiguration;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.RootClass;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import java.util.Iterator;
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -23,7 +23,6 @@
package org.jboss.cache.search;
import org.apache.lucene.search.Query;
-import org.hibernate.search.impl.SearchFactoryImpl;
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -22,7 +22,6 @@
package org.jboss.cache.search;
-import org.hibernate.search.impl.SearchFactoryImpl;
import org.hibernate.search.backend.TransactionContext;
import org.hibernate.search.backend.Work;
import org.hibernate.search.backend.WorkType;
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -1,93 +1,100 @@
-///*
-// * JBoss, Home of Professional Open Source
-// * Copyright ${year}, Red Hat Middleware LLC, and individual contributors
-// * by the @authors tag. See the copyright.txt in the distribution for a
-// * full listing of individual contributors.
-// *
-// * This is free software; you can redistribute it and/or modify it
-// * under the terms of the GNU Lesser General Public License as
-// * published by the Free Software Foundation; either version 2.1 of
-// * the License, or (at your option) any later version.
-// *
-// * This software is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// * Lesser General Public License for more details.
-// *
-// * You should have received a copy of the GNU Lesser General Public
-// * License along with this software; if not, write to the Free
-// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-// * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-// */
-//
-//package org.jboss.cache.search;
-//
-//import org.hibernate.search.impl.SearchFactoryImpl;
-//import org.jboss.cache.notifications.event.NodeModifiedEvent;
-//import org.jboss.cache.pojo.notification.annotation.*;
-//import org.jboss.cache.pojo.notification.event.AttachedEvent;
-//import org.apache.commons.logging.Log;
-//import org.apache.commons.logging.LogFactory;
-//
-//import javax.transaction.Transaction;
-//
-///**
-// * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
-// */
-//
-////@PojoCacheListener
-//public class SearchablePojoListener //extends
-//{
-//// private SearchFactoryImpl searchFactory;
-//// private static final Log log = LogFactory.getLog(SearchablePojoListener.class);
-////
-//// public SearchablePojoListener(SearchFactoryImpl searchFactory)
-//// {
-//// this.searchFactory = searchFactory;
-//// }
-//
-// /**
-// * Takes in a NodeModifiedEvent and updates the Lucene indexes using methods on the NodeModifiedEvent class.
-// *
-// * @param event that has occured - or a node that has been changed. {@link org.jboss.cache.notifications.event.NodeModifiedEvent}
-// * @throws InvalidKeyException if an invalid key is given.
-// */
-//
-//// @Attached
-//// public void handleAttach(AttachedEvent event)
-//// {
-//// Object added = event.getSource();
-//// }
-//
-//
-//// @Detached
-//// @FieldModified
-//// @ListModified
-//// @ArrayModified
-//// @SetModified
-//// @MapModified
-//// public void updateLuceneIndexes(NodeModifiedEvent event) throws InvalidKeyException
-//// {
-////
-//// if (log.isTraceEnabled()) log.trace("You have entered the PojoListener for Searchable Cache");
-//// if (!event.isPre())
-//// {
-//// if (log.isTraceEnabled()) log.trace("event.isPre is false. Going to start updating indexes");
-////
-////
-//// switch (event.getModificationType())
-//// {
-//// case PUT_MAP:
-//// case PUT_DATA:
-//// if (log.isTraceEnabled()) log.trace("put() has been called on cache. Going to handle the data.");
-//// handlePutData(event, searchFactory);
-//// break;
-//// case REMOVE_DATA:
-//// handleDeleteData(event, searchFactory);
-//// break;
-//// }
-//// }
-//// }
-//
-//
-//}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cache.search;
+
+import org.hibernate.search.impl.SearchFactoryImpl;
+import org.hibernate.search.backend.TransactionContext;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkType;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.pojo.notification.annotation.*;
+import org.jboss.cache.pojo.notification.event.AttachedEvent;
+import org.jboss.cache.pojo.notification.event.DetachedEvent;
+import org.jboss.cache.pojo.notification.event.Event;
+import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.Fqn;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.transaction.Transaction;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ */
+
+ at PojoCacheListener
+public class SearchablePojoListener
+{
+ private SearchFactoryImplementor searchFactory;
+ private static final Log log = LogFactory.getLog(SearchablePojoListener.class);
+ private String pojoKey = "pojoKey";
+
+ public SearchablePojoListener(SearchFactoryImplementor searchFactory)
+ {
+ this.searchFactory = searchFactory;
+ }
+
+ /**
+ * Takes in a NodeModifiedEvent and updates the Lucene indexes using methods on the NodeModifiedEvent class.
+ *
+ * @param event that has occured - or a node that has been changed. {@link org.jboss.cache.notifications.event.NodeModifiedEvent}
+ * @throws InvalidKeyException if an invalid key is given.
+ */
+
+ @Attached
+ public void handleAttach(AttachedEvent event) throws InvalidKeyException
+ {
+ System.out.println("Pojocache.attach() called");
+ Object added = event.getSource();
+ Fqn fqn = event.getContext().getPojoCache().getInternalFqn(added);
+
+ CacheEntityId cacheEntityId = new CacheEntityId(fqn, pojoKey);
+
+ TransactionContext ctx = new PojoTransactionContext(event);
+
+ searchFactory.getWorker().performWork(new Work(added, cacheEntityId.getDocumentId(), WorkType.ADD), ctx);
+ }
+
+
+ @Detached
+ public void handleDetach (DetachedEvent event) throws InvalidKeyException
+ {
+ Object deleted = event.getSource();
+ Fqn fqn = event.getContext().getPojoCache().getInternalFqn(deleted);
+
+ CacheEntityId cacheEntityId = new CacheEntityId(fqn, pojoKey);
+
+ TransactionContext ctx = new PojoTransactionContext(event);
+
+ searchFactory.getWorker().performWork(new Work(deleted, cacheEntityId.getDocumentId(), WorkType.DELETE), ctx);
+ }
+
+
+ //TODO: Sort out updating Lucene for the following annotations: -
+// @FieldModified
+// @ListModified
+// @ArrayModified
+// @SetModified
+
+}
Added: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheProfilerTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheProfilerTest.java (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheProfilerTest.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -0,0 +1,250 @@
+package org.jboss.cache.search.blackbox;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.queryParser.MultiFieldQueryParser;
+import org.apache.lucene.search.*;
+import org.apache.lucene.index.Term;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.search.CacheQuery;
+import org.jboss.cache.search.QueryResultIterator;
+import org.jboss.cache.search.SearchableCache;
+import org.jboss.cache.search.SearchableCacheFactory;
+import org.jboss.cache.search.helper.IndexCleanUp;
+import org.jboss.cache.search.test.Person;
+import org.testng.annotations.*;
+
+import java.util.List;
+import java.util.Iterator;
+import java.io.File;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ */
+
+ at Test(groups = "functional", enabled = false)
+public class LocalCacheProfilerTest
+{
+ SearchableCache searchableCache;
+ Person person1;
+ Person person2;
+ Person person3;
+ Person person4;
+ Person person5;
+ Person person6;
+ QueryParser queryParser;
+ Query luceneQuery;
+ CacheQuery cacheQuery;
+ List found;
+ String key1 = "Navin";
+ String key2 = "BigGoat";
+ String key3 = "MiniGoat";
+
+ @BeforeTest
+ public void setUp()
+ {
+ Cache coreCache = new DefaultCacheFactory().createCache();
+ searchableCache = new SearchableCacheFactory().createSearchableCache(coreCache, Person.class);
+
+ person1 = new Person();
+ person1.setName("Navin Surtani");
+ person1.setBlurb("Likes playing WoW");
+
+ person2 = new Person();
+ person2.setName("Big Goat");
+ person2.setBlurb("Eats grass");
+
+ person3 = new Person();
+ person3.setName("Mini Goat");
+ person3.setBlurb("Eats cheese");
+
+ person5 = new Person();
+ person5.setName("Smelly Cat");
+ person5.setBlurb("Eats fish");
+
+ //Put the 3 created objects in the searchableCache.
+ searchableCache.put(Fqn.fromString("/a/b/c"), key1, person1);
+ searchableCache.put(Fqn.fromString("/a/b/d"), key2, person2);
+ searchableCache.put(Fqn.fromString("/a/b/c"), key3, person3);
+
+ }
+
+ @AfterTest
+ public void tearDown()
+ {
+ if (searchableCache != null) searchableCache.stop();
+ IndexCleanUp.cleanUpIndexes();
+ }
+
+ @Test (invocationCount = 200000, enabled = false)
+ public void testSimple() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("playing");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ found = cacheQuery.list();
+
+ assert found.size() == 1;
+ assert found.get(0).equals(person1);
+ }
+
+ @Test (invocationCount = 200000, enabled = false)
+ public void testSimpleIterator() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("playing");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ QueryResultIterator found = cacheQuery.iterator();
+
+ assert found.isFirst();
+ assert found.isLast();
+ }
+
+ @Test (invocationCount = 200000, enabled = false)
+ public void testMultipleResults() throws ParseException
+ {
+
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
+ luceneQuery = queryParser.parse("goat");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 2;
+ assert found.get(0) == person2;
+ assert found.get(1) == person3;
+
+ }
+
+ @Test (invocationCount = 200000, enabled = false)
+ public void testModified() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("playing");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ found = cacheQuery.list();
+
+ assert found.size() == 1;
+ assert found.get(0).equals(person1);
+
+ person1.setBlurb("Likes pizza");
+ searchableCache.put(Fqn.fromString("/a/b/c/"), key1, person1);
+
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("pizza");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ found = cacheQuery.list();
+
+ assert found.size() == 1;
+ assert found.get(0).equals(person1);
+ }
+
+ @Test (invocationCount = 200000, enabled = false)
+ public void testAdded() throws ParseException
+ {
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
+ luceneQuery = queryParser.parse("Goat");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 2 : "Size of list should be 2";
+ assert found.contains(person2);
+ assert found.contains(person3);
+ assert !found.contains(person4) : "This should not contain object person4";
+
+ person4 = new Person();
+ person4.setName("Mighty Goat");
+ person4.setBlurb("Also eats grass");
+
+ searchableCache.put(Fqn.fromString("/r/a/m/"), "Ram", person4);
+
+ luceneQuery = queryParser.parse("Goat");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 3 : "Size of list should be 3";
+ assert found.contains(person2);
+ assert found.contains(person3);
+ assert found.contains(person4) : "This should now contain object person4";
+ }
+
+ @Test (invocationCount = 200000, enabled = false)
+ public void testRemoved() throws ParseException
+ {
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
+ luceneQuery = queryParser.parse("Goat");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 2;
+ assert found.contains(person2);
+ assert found.contains(person3) : "This should still contain object person3";
+
+ searchableCache.remove(Fqn.fromString("/a/b/c/"), key3);
+
+ luceneQuery = queryParser.parse("Goat");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 1;
+ assert found.contains(person2);
+ assert !found.contains(person3) : "The search should not return person3";
+
+ }
+
+ @Test (invocationCount = 200000, enabled = false)
+ public void testSetSort() throws ParseException
+ {
+ person2.setAge(35);
+ person3.setAge(12);
+
+ Sort sort = new Sort("age");
+
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
+ luceneQuery = queryParser.parse("Goat");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 2;
+
+ cacheQuery.setSort(sort);
+
+ found = cacheQuery.list();
+
+ assert found.size() == 2;
+ assert found.get(0).equals(person2);
+ assert found.get(1).equals(person3);
+ }
+
+ @Test (invocationCount = 200000, enabled = false)
+ public void testSetFilter() throws ParseException
+ {
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
+ luceneQuery = queryParser.parse("goat");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+
+ assert found.size() == 2;
+
+ Filter filter = new PrefixFilter(new Term("blurb", "cheese"));
+
+ cacheQuery.setFilter(filter);
+
+ found = cacheQuery.list();
+
+ assert found.size() == 1;
+
+ }
+
+}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -43,7 +43,7 @@
String key2 = "BigGoat";
String key3 = "MiniGoat";
- @BeforeTest
+ @BeforeMethod
public void setUp()
{
Cache coreCache = new DefaultCacheFactory().createCache();
@@ -72,7 +72,7 @@
}
- @AfterTest
+ @AfterMethod
public void tearDown()
{
if (searchableCache != null) searchableCache.stop();
@@ -103,8 +103,6 @@
assert found.isLast();
}
-
- @Test (invocationCount = 200000)
public void testMultipleResults() throws ParseException
{
@@ -242,4 +240,17 @@
}
+ public void testLazyIterator() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("playing");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ QueryResultIterator found = cacheQuery.lazyIterator();
+
+ assert found.isFirst();
+ assert found.isLast();
+
+ }
+
}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java 2008-09-15 13:27:53 UTC (rev 6723)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java 2008-09-15 13:49:14 UTC (rev 6724)
@@ -31,7 +31,7 @@
* @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
*/
- at Test(groups = "functional", enabled = false)
+ at Test(groups = "functional", enabled = true)
public class LocalPOJOCacheTest
{
SearchableCache searchableCache;
@@ -90,20 +90,6 @@
found = cacheQuery.list();
- assert found.size() == 1;
-
- if (found.get(0) == null)
- {
- if (log.isTraceEnabled()) log.warn("found.get(0) is null");
-
- }
-
- if (person1 == null)
- {
- if (log.isTraceEnabled()) log.warn("person1 is null");
- }
-
- // assert person1.equals(found.get(0));
}
public void testMultipleResults() throws ParseException
More information about the jbosscache-commits
mailing list