[infinispan-commits] Infinispan SVN: r632 - in branches/ISPN-32: query and 5 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Aug 5 07:27:50 EDT 2009


Author: navssurtani
Date: 2009-08-05 07:27:49 -0400 (Wed, 05 Aug 2009)
New Revision: 632

Added:
   branches/ISPN-32/query/src/test/java/org/infinispan/query/TransactionalEventTransactionContextTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/
   branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/BrokenAnnotationTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheProfilerTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/helper/
   branches/ISPN-32/query/src/test/java/org/infinispan/query/helper/IndexCleanUp.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/test/
   branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenDocumentId.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenProvided.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/test/Person.java
Removed:
   branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCoreListener.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenAnnotationTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenDocumentId.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenProvided.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/CacheEntityIdTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/ClusteredCacheTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/IndexCleanUp.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/IndexingInTransaction.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheProfilerTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalPOJOCacheTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/NodeModifiedTransactionContextTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/NodeRemovedTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/Person.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/TransformerTest.java
Modified:
   branches/ISPN-32/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java
   branches/ISPN-32/core/src/main/java/org/infinispan/commands/write/ReplaceCommand.java
   branches/ISPN-32/query/pom.xml
   branches/ISPN-32/query/src/main/java/org/infinispan/query/CacheEntityLoader.java
   branches/ISPN-32/query/src/main/java/org/infinispan/query/CacheQueryImpl.java
   branches/ISPN-32/query/src/main/java/org/infinispan/query/LazyQueryResultIterator.java
   branches/ISPN-32/query/src/main/java/org/infinispan/query/QueryResultIterator.java
   branches/ISPN-32/query/src/main/java/org/infinispan/query/QueryResultIteratorImpl.java
   branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCacheFactory.java
   branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCoreInterceptor.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/LazyQueryResultIteratorTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/QueryResultIteratorImplTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/SearchableCacheFactoryTest.java
   branches/ISPN-32/query/src/test/java/org/infinispan/query/SearchableCacheImplTest.java
Log:
[ISPN-32] Still fixing up query module

Modified: branches/ISPN-32/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java
===================================================================
--- branches/ISPN-32/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -130,4 +130,8 @@
    public boolean isConditional() {
       return value != null;
    }
+
+   public Object getValue(){
+      return value;
+   }
 }

Modified: branches/ISPN-32/core/src/main/java/org/infinispan/commands/write/ReplaceCommand.java
===================================================================
--- branches/ISPN-32/core/src/main/java/org/infinispan/commands/write/ReplaceCommand.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/core/src/main/java/org/infinispan/commands/write/ReplaceCommand.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -156,4 +156,16 @@
             ", successful=" + successful +
             '}';
    }
+
+   public Object getOldValue(){
+      return oldValue;
+   }
+
+   public Object getNewValue(){
+      return newValue;
+   }
+
+   public Object getKey(){
+      return key;
+   }
 }

Modified: branches/ISPN-32/query/pom.xml
===================================================================
--- branches/ISPN-32/query/pom.xml	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/pom.xml	2009-08-05 11:27:49 UTC (rev 632)
@@ -19,19 +19,19 @@
          <groupId>${project-package}</groupId>
          <artifactId>infinispan-core</artifactId>
          <version>${project-version}</version>
-   	  </dependency>
+      </dependency>
 
-	  <dependency> 
-		<groupId>org.hibernate</groupId> 
-		<artifactId> hibernate-search</artifactId> 
-		<version>3.1.1.GA</version> 
-	  </dependency>
-	
       <dependency>
+         <groupId>org.hibernate</groupId>
+         <artifactId>hibernate-search</artifactId>
+         <version>3.1.1.GA</version>
+      </dependency>
+
+      <dependency>
          <groupId>${project-package}</groupId>
          <artifactId>infinispan-tree</artifactId>
          <version>${project-version}</version>
-   	  </dependency>
+      </dependency>
 
       <dependency>
          <groupId>${project-package}</groupId>
@@ -49,6 +49,19 @@
          <scope>test</scope>
       </dependency>
 
+      <dependency>
+         <groupId>org.slf4j</groupId>
+         <artifactId>slf4j-api</artifactId>
+         <version>1.4.2</version>
+         <scope>test</scope>
+      </dependency>
 
+      <dependency>
+         <groupId>org.slf4j</groupId>
+         <artifactId>slf4j-log4j12</artifactId>
+         <version>1.4.2</version>
+         <scope>test</scope>
+      </dependency>
+
    </dependencies>
 </project>

Modified: branches/ISPN-32/query/src/main/java/org/infinispan/query/CacheEntityLoader.java
===================================================================
--- branches/ISPN-32/query/src/main/java/org/infinispan/query/CacheEntityLoader.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/main/java/org/infinispan/query/CacheEntityLoader.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -52,7 +52,7 @@
     * @throws NullPointerException if ids is null.
     */
    public List<Object> load(List<EntityId> ids) {
-      if (ids == null) throw new NullPointerException("ids are null");
+      if (ids == null) throw new NullPointerException("keys are null");
       List<Object> objectsToReturn = new ArrayList<Object>(ids.size());
 
       for (EntityId id : ids) {

Modified: branches/ISPN-32/query/src/main/java/org/infinispan/query/CacheQueryImpl.java
===================================================================
--- branches/ISPN-32/query/src/main/java/org/infinispan/query/CacheQueryImpl.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/main/java/org/infinispan/query/CacheQueryImpl.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -23,7 +23,6 @@
 package org.infinispan.query;
 
 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.*;
@@ -47,8 +46,6 @@
 import static org.hibernate.search.util.FilterCacheModeTypeHelper.cacheResults;
 import org.hibernate.transform.ResultTransformer;
 import org.infinispan.Cache;
-import org.jboss.cache.Cache;
-import org.jboss.cache.pojo.PojoCache;
 
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
@@ -68,38 +65,33 @@
  */
 public class CacheQueryImpl implements CacheQuery
 {
-   //   private Cache cache; - Removed on 11/07/2008, cache is assigned but never used. Hence removed.
    private Sort sort;
    private Filter filter;
    private Map<String, FullTextFilterImpl> filterDefinitions;
    private Integer firstResult;
    private Integer resultSize;
    private Integer maxResults;
-   private static final Log log = LogFactory.getLog(CacheQueryImpl.class);
+   private Log log;
    private boolean needClassFilterClause;
    private String[] indexProjection;
    private ResultTransformer resultTransformer;
-   CacheEntityLoader entityLoader;
    private Set<Class<?>> classesAndSubclasses;
    private Set<String> idFieldNames;
    private boolean allowFieldSelectionInProjection = true;
+   private Query luceneQuery;
+   private SearchFactoryImplementor searchFactory;
+   private Set<Class<?>> targetedEntities;
+   private Cache cache;
+   private Class[] classes;
 
-   // Protected fields for CacheQueryPojoImpl to see.
-   protected Query luceneQuery;
-   protected SearchFactoryImplementor searchFactory;
-   protected Set<Class<?>> targetedEntities;
-   protected Cache cache;
-   protected Class[] classes;
 
 
 
 
-
    public CacheQueryImpl(Query luceneQuery, SearchFactoryImplementor searchFactory, Cache cache, Class... classes)
    {
       this.luceneQuery = luceneQuery;
       this.cache = cache;
-      entityLoader = new CacheEntityLoader(cache);
       this.searchFactory = searchFactory;
       this.targetedEntities = this.searchFactory.getIndexedTypesPolymorphic(classes);
       this.classes = classes;
@@ -237,7 +229,7 @@
 
    public QueryResultIterator iterator(int fetchSize) throws HibernateException
    {
-      List<EntityId> ids = null;
+      List<Object> keyList = null;
       IndexSearcher searcher = buildSearcher(searchFactory);
       if (searcher == null)
       {
@@ -250,14 +242,19 @@
          int first = first();
          int max = max(first, queryHits.totalHits);
          int size = max - first + 1 < 0 ? 0 : max - first + 1;
-         ids = new ArrayList<EntityId>(size);
+         keyList = new ArrayList<Object>(size);
 
          DocumentExtractor extractor = new DocumentExtractor(queryHits, searchFactory, indexProjection, idFieldNames, allowFieldSelectionInProjection);
          for (int index = first; index <= max; index++)
          {
-            String documentId = (String) extractor.extract(index).id;
-            EntityId id = createCacheEntityId(documentId);
-            ids.add(id);
+            // Since the documentId is same thing as the key in each key, value pairing. We can just get the documentId
+            // from Lucene and then get it from the cache.
+
+            // The extractor.extract.id gives me the documentId that we need.
+
+
+            Object key = extractor.extract(index).id;
+            keyList.add(key);
          }
 
       }
@@ -274,7 +271,7 @@
 
       }
 
-      return new QueryResultIteratorImpl(ids, entityLoader, fetchSize);
+      return new QueryResultIteratorImpl(keyList, cache, fetchSize);
    }
 
    public QueryResultIterator lazyIterator()
@@ -294,7 +291,7 @@
 
          DocumentExtractor extractor = new DocumentExtractor(queryHits, searchFactory, indexProjection, idFieldNames, allowFieldSelectionInProjection);
 
-         return new LazyQueryResultIterator(extractor, entityLoader, searcher, searchFactory, first, max, fetchSize);
+         return new LazyQueryResultIterator(extractor, cache, searcher, searchFactory, first, max, fetchSize);
       }
       catch (IOException e)
       {
@@ -321,8 +318,9 @@
 
       try
       {
+
          QueryHits queryHits = getQueryHits(searcher, calculateTopDocsRetrievalSize());
-         if (log.isTraceEnabled()) log.trace("Number of hits are " + queryHits.totalHits);
+         log.debug("Number of hits are " + queryHits.totalHits);
          int first = first();
          int max = max(first, queryHits.totalHits);
 
@@ -330,25 +328,34 @@
 
          DocumentExtractor extractor = new DocumentExtractor(queryHits, searchFactory, indexProjection, idFieldNames, allowFieldSelectionInProjection);
 
-         List<EntityId> ids = new ArrayList<EntityId>(size);
+         List<Object> keysForCache = new ArrayList<Object>(size);
          for (int index = first; index <= max; index++)
          {
-            String documentId = (String) extractor.extract(index).id;
-            EntityId id = createCacheEntityId(documentId);
-            ids.add(id);
+            // Since the documentId is same thing as the key in each key, value pairing. We can just get the documentId
+            // from Lucene and then get it from the cache.
+
+            // The extractor.extract.id gives me the documentId that we need.
+
+            Object cacheKey = extractor.extract(index).id;
+            keysForCache.add(cacheKey);
          }
-         if (entityLoader instanceof PojoEntityLoader)
-         {
-            System.out.println("entityLoader is a PEL");
+
+         // Loop through my list of keys and get it from the cache. Put each object that I get into a separate list.
+         List<Object> listToReturn = new ArrayList<Object>(size);
+         for (Object key : keysForCache){
+            listToReturn.add(cache.get(key));
          }
-         List<Object> list = entityLoader.load(ids);
+
+
+         // TODO: navssurtani --> Speak with EB or HF about what a resultTransformer is and what it does etc etc.
+
          if (resultTransformer == null)
          {
-            return list;
+            return listToReturn;
          }
          else
          {
-            return resultTransformer.transformList(list);
+            return resultTransformer.transformList(listToReturn);
 
          }
 
@@ -366,12 +373,6 @@
 
    }
 
-   protected EntityId createCacheEntityId(String docId)
-   {
-      return new CacheEntityId(docId);
-   }
-
-
    private int max(int first, int totalHits)
    {
       if (maxResults == null)

Modified: branches/ISPN-32/query/src/main/java/org/infinispan/query/LazyQueryResultIterator.java
===================================================================
--- branches/ISPN-32/query/src/main/java/org/infinispan/query/LazyQueryResultIterator.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/main/java/org/infinispan/query/LazyQueryResultIterator.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -25,41 +25,39 @@
 import org.apache.lucene.search.IndexSearcher;
 import org.hibernate.search.engine.DocumentExtractor;
 import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.infinispan.Cache;
 
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.NoSuchElementException;
 
 /**
- * Implementation for {@link org.infinispan.query.QueryResultIterator}. This is what is returned when
- * the {@link CacheQuery#lazyIterator()} method is called. This loads the results only when required and hence differs from
- * {@link org.infinispan.query.QueryResultIteratorImpl} which is the other implementation of QueryResultIterator.
+ * Implementation for {@link org.infinispan.query.QueryResultIterator}. This is what is returned when the {@link
+ * CacheQuery#lazyIterator()} method is called. This loads the results only when required and hence differs from {@link
+ * org.infinispan.query.QueryResultIteratorImpl} which is the other implementation of QueryResultIterator.
  *
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ * @author Navin Surtani
  */
-public class LazyQueryResultIterator implements QueryResultIterator
-{
+public class LazyQueryResultIterator implements QueryResultIterator {
    private int index = 0;
    private int bufferIndex = -1; // this is the index at which the buffer was populated.  Hence, the first element of the buffer is at this index in the overall result set.
    private int max = 0;
    private int first = 0;
    private int fetchSize = 0;     // difference between fetchsize and index must always be the value for first. fetchSize has to be at least 1.
-   private CacheEntityLoader entityLoader;
    private DocumentExtractor extractor;
+   private Cache cache;
    private IndexSearcher searcher;
    private SearchFactoryImplementor searchFactory;
    Object[] buffer;
 
-   public LazyQueryResultIterator(DocumentExtractor extractor, CacheEntityLoader entityLoader,
-                                  IndexSearcher searcher, SearchFactoryImplementor searchFactory, int first, int max, int fetchSize)
-   {
-      if (fetchSize < 1)
-      {
+   public LazyQueryResultIterator(DocumentExtractor extractor, Cache cache,
+                                  IndexSearcher searcher, SearchFactoryImplementor searchFactory, int first, int max, int fetchSize) {
+      if (fetchSize < 1) {
          throw new IllegalArgumentException("Incorrect value for fetchsize passed. Your fetchSize is less than 1");
       }
 
       this.extractor = extractor;
-      this.entityLoader = entityLoader;
+      this.cache = cache;
       index = first;
       this.first = first;
       this.max = max;
@@ -71,69 +69,56 @@
       buffer = new Object[this.fetchSize];
    }
 
-   public void jumpToResult(int index) throws IndexOutOfBoundsException
-   {
-      if (index < first || index > max)
-      {
+   public void jumpToResult(int index) throws IndexOutOfBoundsException {
+      if (index < first || index > max) {
          throw new IndexOutOfBoundsException("The given index is incorrect. Please check and try again.");
       }
-      
+
       this.index = first + index;
 
    }
 
-   public void first()
-   {
+   public void first() {
       index = first;
    }
 
-   public void last()
-   {
+   public void last() {
       index = max;
    }
 
-   public void afterFirst()
-   {
+   public void afterFirst() {
       index = first + 1;
    }
 
-   public void beforeLast()
-   {
+   public void beforeLast() {
       index = max - 1;
    }
 
-   public boolean isFirst()
-   {
+   public boolean isFirst() {
       return index == first;
    }
 
-   public boolean isLast()
-   {
+   public boolean isLast() {
       return index == max;
    }
 
-   public boolean isAfterFirst()
-   {
+   public boolean isAfterFirst() {
       return index == first + 1;
    }
 
-   public boolean isBeforeLast()
-   {
+   public boolean isBeforeLast() {
       return index == max - 1;
    }
 
-   public void close()
-   {
+   public void close() {
       IndexSearcherCloser.closeSearcher(searcher, searchFactory.getReaderProvider());
    }
 
-   public boolean hasNext()
-   {
+   public boolean hasNext() {
       return index <= max;
    }
 
-   public Object next()
-   {
+   public Object next() {
       if (!hasNext()) throw new IndexOutOfBoundsException("Index is out of bounds. There is no next");
 
       Object toReturn = null;
@@ -141,22 +126,19 @@
 
       // make sure the index we are after is in the buffer.  If it is, then index >= bufferIndex and index <= (bufferIndex + bufferSize).
       if (bufferIndex >= 0                                       // buffer init check
-              && index >= bufferIndex                           // lower boundary
-              && index < (bufferIndex + bufferSize))          // upper boundary
+            && index >= bufferIndex                           // lower boundary
+            && index < (bufferIndex + bufferSize))          // upper boundary
       {
          // now we can get this from the buffer.  Sweet!
          int indexToReturn = index - bufferIndex;
          toReturn = buffer[indexToReturn];
-      }
-      else
-      {
+      } else {
          // else we need to populate the buffer and get what we need.
 
-         try
-         {
+         try {
             String documentId = (String) extractor.extract(index).id;
             CacheEntityId id = new CacheEntityId(documentId);
-            toReturn = entityLoader.load(id);
+            toReturn = cache.get(id);
 
             //Wiping bufferObjects and the bufferIndex so that there is no stale data.
             Arrays.fill(buffer, null);
@@ -166,17 +148,15 @@
             // ignore loop below, in needs fixing
             //now loop through bufferSize times to add the rest of the objects into the list.
 
-            for (int i = 1; i < bufferSize; i++)
-            {
+            for (int i = 1; i < bufferSize; i++) {
                String bufferDocumentId = (String) extractor.extract(index + i).id;
                CacheEntityId bufferId = new CacheEntityId(bufferDocumentId);
-               Object toBuffer = entityLoader.load(bufferId);
+               Object toBuffer = cache.get(bufferId);
                buffer[i] = toBuffer;
             }
             bufferIndex = index;
          }
-         catch (IOException e)
-         {
+         catch (IOException e) {
             e.printStackTrace();
          }
       }
@@ -185,13 +165,11 @@
       return toReturn;
    }
 
-   public boolean hasPrevious()
-   {
+   public boolean hasPrevious() {
       return index >= first;
    }
 
-   public Object previous()
-   {
+   public Object previous() {
       if (!hasPrevious()) throw new IndexOutOfBoundsException("Index is out of bounds. There is no previous");
 
       Object toReturn = null;
@@ -200,52 +178,47 @@
       // make sure the index we are after is in the buffer.  If it is, then index >= bufferIndex and index <= (bufferIndex + bufferSize).
 
       if (bufferIndex >= 0 // buffer init check
-              && index <= bufferIndex // lower boundary
-              && index >= (bufferIndex + bufferSize)) // upper boundary
+            && index <= bufferIndex // lower boundary
+            && index >= (bufferIndex + bufferSize)) // upper boundary
       {
          // now we can get this from the buffer.  Sweet!
          int indexToReturn = bufferIndex - index;        // Unlike next() we have to make sure that we are subtracting index from bufferIndex
          toReturn = buffer[indexToReturn];
       }
 
-      try
-      {
+      try {
          //Wiping the buffer
          Arrays.fill(buffer, null);
 
          String documentId = (String) extractor.extract(index).id;
          CacheEntityId id = new CacheEntityId(documentId);
-         toReturn = entityLoader.load(id);
+         toReturn = cache.get(id);
 
          buffer[0] = toReturn;
 
          //now loop through bufferSize times to add the rest of the objects into the list.
-         for (int i = 1; i < bufferSize; i++)
-         {
+         for (int i = 1; i < bufferSize; i++) {
             String bufferDocumentId = (String) extractor.extract(index - i).id;    //In this case it has to be index - i because previous() is called.
             CacheEntityId bufferId = new CacheEntityId(bufferDocumentId);
-            Object toBuffer = entityLoader.load(bufferId);
+            Object toBuffer = cache.get(bufferId);
             buffer[i] = toBuffer;
          }
 
          bufferIndex = index;
       }
-      catch (IOException e)
-      {
+      catch (IOException e) {
          e.printStackTrace();
       }
       index--;
       return toReturn;
    }
 
-   public int nextIndex()
-   {
+   public int nextIndex() {
       if (!hasNext()) throw new NoSuchElementException("Out of boundaries");
       return index + 1;
    }
 
-   public int previousIndex()
-   {
+   public int previousIndex() {
       if (!hasPrevious()) throw new NoSuchElementException("Out of boundaries.");
       return index - 1;
    }
@@ -253,8 +226,7 @@
    /**
     * This method is not supported and should not be used. Use cache.remove() instead.
     */
-   public void remove()
-   {
+   public void remove() {
       throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache");
    }
 
@@ -264,8 +236,7 @@
     * @param o
     * @throws UnsupportedOperationException
     */
-   public void set(Object o) throws UnsupportedOperationException
-   {
+   public void set(Object o) throws UnsupportedOperationException {
       throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache");
    }
 
@@ -276,8 +247,7 @@
     * @throws UnsupportedOperationException
     */
 
-   public void add(Object o)
-   {
+   public void add(Object o) {
       throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache");
    }
 

Modified: branches/ISPN-32/query/src/main/java/org/infinispan/query/QueryResultIterator.java
===================================================================
--- branches/ISPN-32/query/src/main/java/org/infinispan/query/QueryResultIterator.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/main/java/org/infinispan/query/QueryResultIterator.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -27,8 +27,8 @@
 /**
  * Iterates over query results
  * <p/>
- * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">manik at jboss.org</a>)
+ * @author Manik Surtani
+ * @author Navin Surtani 
  */
 public interface QueryResultIterator extends ListIterator
 {

Modified: branches/ISPN-32/query/src/main/java/org/infinispan/query/QueryResultIteratorImpl.java
===================================================================
--- branches/ISPN-32/query/src/main/java/org/infinispan/query/QueryResultIteratorImpl.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/main/java/org/infinispan/query/QueryResultIteratorImpl.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -25,25 +25,28 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.infinispan.Cache;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.NoSuchElementException;
-import java.util.Arrays;
 
 /**
  * This is the implementation class for the interface QueryResultIterator which extends ListIterator. It is what is
- * returned when the iterator() method is run on a CacheQuery instance.
+ * returned when the {@link org.infinispan.query.CacheQuery#iterator()}.
  * <p/>
  * <p/>
  *
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ * //TODO: navssurtani --> Document this.
+ *
+ * @author Navin Surtani
  */
 public class QueryResultIteratorImpl implements QueryResultIterator
 {
    private int index = 0;
    //private final int size;
-   private List<EntityId> idList;
-   private CacheEntityLoader entityLoader;
+   private List<Object> idList;
+   private Cache cache;
    private int lowerLimit = 0;
    private int upperLimit = 0;
    private int fetchSize = 0;
@@ -52,7 +55,7 @@
    private static final Log log = LogFactory.getLog(QueryResultIteratorImpl.class);
 
 
-   public QueryResultIteratorImpl(List<EntityId> idList, CacheEntityLoader entityLoader, int fetchSize)
+   public QueryResultIteratorImpl(List<Object> idList, Cache cache, int fetchSize)
    {
       if (fetchSize < 1)
       {
@@ -60,9 +63,7 @@
       }
 
       this.idList = idList;
-      System.out.println("idList size is " + idList.size());
-      System.out.println("idList object 1 is " + idList.get(0));
-      this.entityLoader = entityLoader;
+      this.cache = cache;
       upperLimit = idList.size() - 1;
       this.fetchSize = fetchSize;
 
@@ -127,7 +128,7 @@
 
    public boolean isFirst()
    {
-      return idList.get(index) == idList.get(0);
+      return index == 0;
    }
 
    /**
@@ -146,7 +147,8 @@
 
    public boolean isAfterFirst()
    {
-      return idList.get(index) == idList.get(1);
+      return index == 1;
+//      return idList.get(index).equals(idList.get(1));
    }
 
    /**
@@ -155,7 +157,8 @@
 
    public boolean isBeforeLast()
    {
-      return idList.get(index) == idList.get(idList.size() - 2);
+      return index == idList.size() - 2;
+//      return idList.get(index) == idList.get(idList.size() - 2);
    }
 
    public void close()
@@ -201,7 +204,7 @@
       {
          // We need to populate the buffer.
 
-         toReturn = entityLoader.load(idList.get(index));
+         toReturn = cache.get(idList.get(index));
 
          //Wiping bufferObjects and the bufferIndex so that there is no stale data.
 
@@ -222,7 +225,7 @@
                break;
             }
 
-            Object toBuffer = entityLoader.load(idList.get(index + i));
+            Object toBuffer = cache.get(idList.get(index + i));
             buffer[i] = toBuffer;
          }
          bufferIndex = index;
@@ -268,15 +271,15 @@
       }
       else
       {
-         toReturn = entityLoader.load(idList.get(index));
-         //Wiping bufferObjects and the bufferIndex so that there is no stale data.
+         toReturn = cache.get(idList.get(index));
+         // Wiping bufferObjects and the bufferIndex so that there is no stale data.
 
          Arrays.fill(buffer, null);
          buffer[0] = toReturn;
 
-         // we now need to buffer item at index "index", as well as the next "fetchsize - 1" elements.  I.e., a total of fetchsize elements will be buffered.
-         // ignore loop below, in needs fixing
-         //now loop through bufferSize times to add the rest of the objects into the list.
+         // we now need to buffer objects at index "index", as well as the next "fetchsize - 1" elements.
+         // I.e., a total of fetchsize elements will be buffered.
+         // now loop through bufferSize times to add the rest of the objects into the list.
 
          for (int i = 1; i < bufferSize; i++)
          {
@@ -288,13 +291,10 @@
                }
                break;
             }
-
-            Object toBuffer = entityLoader.load(idList.get(index - i));
+            Object toBuffer = cache.get(idList.get(index - i));
             buffer[i] = toBuffer;
          }
          bufferIndex = index;
-
-
       }
       index--;
       return toReturn;
@@ -330,7 +330,7 @@
     */
    public void remove()
    {
-      throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache");
+      throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache.  Please use searchableCache.put()");
    }
 
    /**
@@ -341,7 +341,7 @@
     */
    public void set(Object o) throws UnsupportedOperationException
    {
-      throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache");
+      throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache.  Please use searchableCache.put()");
    }
 
    /**
@@ -353,7 +353,11 @@
 
    public void add(Object o)
    {
-      throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache");
+      throw new UnsupportedOperationException("Not supported as you are trying to change something in the cache. Please use searchableCache.put()");
    }
 
+   public void setFetchSize(int newFetchSize){
+      fetchSize = newFetchSize;
+   }
+
 }

Modified: branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCacheFactory.java
===================================================================
--- branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCacheFactory.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCacheFactory.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -29,6 +29,7 @@
 import org.infinispan.factories.ComponentRegistry;
 import org.infinispan.factories.InterceptorChainFactory;
 import org.infinispan.interceptors.LockingInterceptor;
+import org.infinispan.interceptors.base.CommandInterceptor;
 
 import java.lang.reflect.Field;
 import java.util.Properties;
@@ -53,7 +54,7 @@
     * @param classes - Class array to be added
     * @return a SearchableCache
     */
-   public SearchableCache createSearchableCache(Cache<?, ?> c, Class[] classes) throws IllegalAccessException, InstantiationException {
+   public SearchableCache createSearchableCache(Cache<?, ?> c, Class... classes) throws IllegalAccessException, InstantiationException {
       return createSearchableCache(c, null, classes);
    }
 
@@ -65,7 +66,7 @@
     * @param classes    - a class array
     * @return a SearchableCache
     */
-   public SearchableCache createSearchableCache(Cache<?, ?> c, Properties properties, Class[] classes) throws IllegalAccessException, InstantiationException {
+   public SearchableCache createSearchableCache(Cache<?, ?> c, Properties properties, Class... classes) throws IllegalAccessException, InstantiationException {
 
       //validate the classes first. make sure the correct annotations are put in.
 
@@ -84,21 +85,18 @@
 
       // step 1: create hibernate search searchFactory
       SearchConfiguration cfg = new SearchableCacheConfiguration(classes, properties);
-      // set classes in the cfg
-
       SearchFactoryImplementor searchFactory = new SearchFactoryImpl(cfg);
 
 
-      // Okay, create the core listener
-//      SearchableCoreListener coreListener = new SearchableCoreListener(searchFactory);
-//      c.addCacheListener(coreListener);
-
+      // get the component registry and then register the searchFactory.
       ComponentRegistry cr = c.getAdvancedCache().getComponentRegistry();
       cr.registerComponent(searchFactory, SearchFactoryImplementor.class);
+
+      // Get the interceptor chain factory so I can create my interceptor.
       InterceptorChainFactory icf = cr.getComponent(InterceptorChainFactory.class);
 
-      // Don't like this cast :-(.
-      SearchableCoreInterceptor inter = (SearchableCoreInterceptor) icf.createInterceptor(SearchableCoreInterceptor.class);
+      // Create my interceptor.
+      CommandInterceptor inter =  icf.createInterceptor(SearchableCoreInterceptor.class);
 
       c.getAdvancedCache().addInterceptorAfter(inter, LockingInterceptor.class);
 

Modified: branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCoreInterceptor.java
===================================================================
--- branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCoreInterceptor.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCoreInterceptor.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -4,7 +4,6 @@
 import org.hibernate.search.backend.Work;
 import org.hibernate.search.backend.WorkType;
 import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.infinispan.commands.write.EvictCommand;
 import org.infinispan.commands.write.PutKeyValueCommand;
 import org.infinispan.commands.write.PutMapCommand;
 import org.infinispan.commands.write.RemoveCommand;
@@ -18,7 +17,6 @@
 
 /**
  * // TODO: navssurtani --> Document this
- * // TODO: Do I need a method for visitClearCommand()? How can I deal with it?
  *
  * @author Navin Surtani
  * @since 4.0
@@ -59,8 +57,8 @@
       // remove the object out of the cache first.
       Object valueRemoved = invokeNextInterceptor(ctx, command);
 
-      if (valueRemoved != null) {
-         removeFromIndexes(valueRemoved, command.getKey().toString());
+      if (command.isSuccessful()) {
+         removeFromIndexes(command.getValue(), command.getKey().toString());
       }
 
       return valueRemoved;
@@ -75,12 +73,8 @@
       Object valueReplaced = invokeNextInterceptor(ctx, command);
       if (valueReplaced != null) {
 
-         //TODO: navssurtani --> find out from someone if this method is actually coded correctly in terms of dealing with the array.         
-
-         // This is an array of parameters and we know that the array is of the form key, oldValue, newValue,
-         //  lifeSpanMillis, maxIdleTimeMillis
          Object[] parameters = command.getParameters();
-         String keyString = parameters[0].toString();
+         String keyString = command.getKey().toString();
 
          removeFromIndexes(parameters[1], keyString);
          addToIndexes(parameters[2], keyString);
@@ -91,9 +85,8 @@
 
    @Override
    public Object visitPutMapCommand(InvocationContext ctx, PutMapCommand command) throws Throwable{
+      
 
-      //TODO: navssurtani --> Find out if that when a map gets put into the cache, if each key, value pairing in the map gets its own pairing in the cahe, or if the map is stored as a value in a key, value pair in the cache.
-
       log.debug("Entered searchable core interceptor visitPutMapCommand()");
 
       Object mapPut = invokeNextInterceptor(ctx, command);
@@ -102,29 +95,14 @@
 
       // Loop through all the keys and put those key, value pairings into lucene.
 
-      for(Object key : dataMap.keySet()){
-         addToIndexes(dataMap.get(key), key.toString());
+      for(Map.Entry entry : dataMap.entrySet()){
+         addToIndexes(entry.getValue(), entry.getKey().toString());
       }
       return mapPut;
    }
 
 
-   @Override
-   public Object visitEvictCommand(InvocationContext ctx, EvictCommand command) throws Throwable{
 
-      //TODO: navssurtani --> Should I be getting rid of stuff from lucene just because an object has been removed from the local cache?
-            
-      log.debug("Entered searchable core interceptor visitPutMapCommand()");
-
-      Object objectEvicted = invokeNextInterceptor(ctx, command);
-
-      if (objectEvicted != null){
-         removeFromIndexes(objectEvicted, command.getKey().toString());
-      }
-      return objectEvicted;
-   }
-
-
    // Method that will be called when data needs to be added into Lucene.
    private void addToIndexes(Object value, String key) {
 

Deleted: branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCoreListener.java
===================================================================
--- branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCoreListener.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/main/java/org/infinispan/query/SearchableCoreListener.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,211 +0,0 @@
-/*
- * 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.infinispan.query;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-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.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.NodeModified;
-import org.jboss.cache.notifications.annotation.NodeRemoved;
-import org.jboss.cache.notifications.annotation.TransactionRegistered;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.notifications.event.NodeRemovedEvent;
-import org.jboss.cache.notifications.event.TransactionRegisteredEvent;
-
-import javax.transaction.Transaction;
-import java.util.Map;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- *         <p/>
- *         Listener class for changes made to the cache. This listener makes changes if it is a {@link org.jboss.cache.Cache} being used.
- */
- at CacheListener
-public class SearchableCoreListener
-{
-   private SearchFactoryImplementor searchFactory;
-   private static final Log log = LogFactory.getLog(SearchableCoreListener.class);
-
-   public SearchableCoreListener(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 passed in.
-    */
-
-   @NodeModified
-   public void updateLuceneIndexes(NodeModifiedEvent event) throws InvalidKeyException
-   {
-     if (log.isDebugEnabled()) log.debug("You have entered the SearchableListener");
-      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;
-         }
-      }
-   }
-
-
-   @NodeRemoved
-   public void handleNodeRemoved(NodeRemovedEvent event) throws InvalidKeyException
-   {
-
-      log.debug("Entered the SCL. @NodeRemoved annotation found");
-      if (event.isPre())
-      {
-         // Directly going to handle the deletion of data.
-         Map dataMap = event.getData();
-         if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
-
-         TransactionContext ctx = new org.jboss.cache.search.TransactionalEventTransactionContext(event);
-
-         for (Object key : dataMap.keySet())
-         {
-            // todo: the key may be any object ... casting may produce CCE and is breaking the cache iface contract
-            CacheEntityId cacheEntityId = new CacheEntityId(event.getFqn(), (String) key);
-            if (log.isTraceEnabled()) log.trace("Created new CacheEntityId");
-
-            String fqnString = cacheEntityId.getFqn().toString();  // Vars for logging
-            String keyString = (String) key;
-
-
-            searchFactory.getWorker().performWork(new Work(dataMap.get(key), cacheEntityId.getDocumentId(), WorkType.DELETE), ctx);
-
-            if (log.isTraceEnabled())
-            {
-               log.debug("Added your object into Lucene with Fqn " + fqnString + " and key " + keyString);
-            }
-         }
-     }
-   }
-
-   /**
-    * Transaction commencement needs to be handled explicitly
-    */
-   @TransactionRegistered
-   public void handleTransactionBoundary(TransactionRegisteredEvent event)
-   {
-      Transaction transactionId = event.getTransaction();
-
-      // TODO find some way to notify Hibernate Search that a transaction has commenced.
-
-      // According to http://www.hibernate.org/hib_docs/search/reference/en/html/search-batchindex.html#search-batchindex-indexing
-      // work is flushed automatically by HS when the transaction commits so there is nothing else to do there.  We just need an
-      // internal equivalent of fullTextSession.beginTransaction() and force it to use the transactionId provided.
-   }
-
-
-   /**
-    * If the modification type is PUT_MAP or PUT_DATA then this method will be called.
-    * Takes in the event as a parameter
-    *
-    * @param event         that has occured - or a node that has been changed. {@link org.jboss.cache.notifications.event.NodeModifiedEvent}
-    * @param searchFactory - a SearchFactoryImpl instance.
-    * @throws InvalidKeyException
-    */
-
-
-   public void handlePutData(NodeModifiedEvent event, SearchFactoryImplementor searchFactory) throws InvalidKeyException
-   {
-      Map dataMap = event.getData();
-      if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
-
-
-      TransactionContext ctx = new TransactionalEventTransactionContext(event);
-
-      for (Object key : dataMap.keySet())
-      {
-          // todo: the key may be any object ... casting may produce CCE and is breaking the cache iface contract
-         CacheEntityId cacheEntityId = new CacheEntityId(event.getFqn(), (String) key);
-         if (log.isTraceEnabled()) log.trace("Created new CacheEntityId");
-
-         String fqnString = cacheEntityId.getFqn().toString();  // Vars for logging
-         String keyString = (String) key;
-
-
-         searchFactory.getWorker().performWork(new Work(dataMap.get(key), cacheEntityId.getDocumentId(), WorkType.DELETE), ctx);
-         searchFactory.getWorker().performWork(new Work(dataMap.get(key), cacheEntityId.getDocumentId(), WorkType.ADD), ctx);
-
-
-         if (log.isTraceEnabled())
-         {
-            log.debug("Added your object into Lucene with Fqn " + fqnString + " and key " + keyString);
-         }
-
-
-      }
-
-   }
-
-
-   /**
-    * If the modification type is DELETE_DATA then this method will be called.
-    * Takes in the event as a parameter
-    *
-    * @param event         that has occured - or a node that has been changed. {@link org.jboss.cache.notifications.event.NodeModifiedEvent}
-    * @param searchFactory - a SearchFactoryImpl instance.
-    * @throws InvalidKeyException
-    */
-   protected void handleDeleteData(NodeModifiedEvent event, SearchFactoryImplementor searchFactory) throws InvalidKeyException
-   {
-      Map dataMap = event.getData();
-
-      TransactionContext ctx = new TransactionalEventTransactionContext(event);
-
-      for (Object key : dataMap.keySet())
-      {
-         // todo: the key may be any object ... casting may produce CCE and is breaking the cache iface contract
-         CacheEntityId cacheEntityId = new CacheEntityId(event.getFqn(), (String) key);
-
-         String fqnString = cacheEntityId.getFqn().toString();
-         String keyString = (String) key;
-
-
-         searchFactory.getWorker().performWork(new Work(dataMap.get(key), cacheEntityId.getDocumentId(), WorkType.DELETE), ctx);
-         if (log.isTraceEnabled())
-            log.trace("Deleted your object from Lucene with Fqn " + fqnString + " and key " + keyString);
-
-
-      }
-
-   }
-
-}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenAnnotationTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenAnnotationTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenAnnotationTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,46 +0,0 @@
-package org.jboss.cache.search.blackbox;
-
-import org.testng.annotations.Test;
-import org.jboss.cache.search.test.BrokenProvided;
-import org.jboss.cache.search.test.BrokenDocumentId;
-import org.jboss.cache.search.SearchableCache;
-import org.jboss.cache.search.SearchableCacheFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-
-/**
- * This test is to try and create a searchable cache without the proper annotations used.
- *
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
- at Test (groups = "functional")
-public class BrokenAnnotationTest
-{
-   @Test (expectedExceptions = IllegalArgumentException.class)
-   public void testProvided()
-   {
-      BrokenProvided provided = new BrokenProvided();
-      provided.setBoth("Cat", 5);
-
-      Cache cache = new DefaultCacheFactory().createCache();
-
-      SearchableCache searchable = new SearchableCacheFactory().createSearchableCache(cache, BrokenProvided.class);
-
-
-   }
-
-   @Test (expectedExceptions = IllegalArgumentException.class)
-   public void testDocumentId()
-   {
-      BrokenDocumentId provided = new BrokenDocumentId();
-      provided.setBoth("Cat", 5);
-
-      Cache cache = new DefaultCacheFactory().createCache();
-
-      SearchableCache searchable = new SearchableCacheFactory().createSearchableCache(cache, BrokenProvided.class);
-
-
-
-   }
-
-}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenDocumentId.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenDocumentId.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenDocumentId.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,27 +0,0 @@
-package org.jboss.cache.search.test;
-
-import org.hibernate.search.annotations.ProvidedId;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
- at ProvidedId
- at Indexed
-public class BrokenDocumentId
-{
-   @DocumentId
-   @Field
-   String name;
-
-   @Field
-   int age;
-
-   public void setBoth(String name, int age)
-   {
-      this.name = name;
-      this.age = age;
-   }
-}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenProvided.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenProvided.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenProvided.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,26 +0,0 @@
-package org.jboss.cache.search.test;
-
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
- at Indexed
-public class BrokenProvided
-{
-   @Field   
-   public String name;
-
-   @Field
-   public int age;
-
-   public void setBoth(String name, int age)
-   {
-      this.name = name;
-      this.age = age;
-
-   }
-
-}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/CacheEntityIdTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/CacheEntityIdTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/CacheEntityIdTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,36 +0,0 @@
-package org.jboss.cache.search;
-
-import org.testng.annotations.Test;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.search.CacheEntityId;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
-
- at Test
-public class CacheEntityIdTest
-{
-
-   @Test (expectedExceptions = NullPointerException.class)
-   public void testNullFqn() throws InvalidKeyException
-   {
-      CacheEntityId nullFqn = new CacheEntityId(null, "key");
-   }
-
-
-   @Test (expectedExceptions = NullPointerException.class)
-   public void testNullKey() throws InvalidKeyException
-   {
-      CacheEntityId nullKey = new CacheEntityId(Fqn.fromString("/a/b/c"), null);
-   }
-
-   @Test (expectedExceptions = NullPointerException.class)
-   public void testNullDocId()
-   {
-      CacheEntityId nulldoc = new CacheEntityId(null);
-   }
-
-
-
-}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/ClusteredCacheTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/ClusteredCacheTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/ClusteredCacheTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,230 +0,0 @@
-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.search.Query;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.search.CacheQuery;
-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.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.List;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
- at Test(groups = "functional")
-public class ClusteredCacheTest
-{
-   Cache cache1, cache2;
-   SearchableCache searchableCache1, searchableCache2;
-   Person person1;
-   Person person2;
-   Person person3;
-   Person person4;
-   QueryParser queryParser;
-   Query luceneQuery;
-   CacheQuery cacheQuery;
-   List found;
-   String key1 = "Navin";
-   String key2 = "BigGoat";
-   String key3 = "MiniGoat";
-   private static final Log log = LogFactory.getLog(Person.class);
-
-
-
-   @BeforeMethod
-   public void setUp() throws CloneNotSupportedException
-   {
-      Configuration cacheCfg = new Configuration();
-      cacheCfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
-      cacheCfg.setFetchInMemoryState(false);
-      cache1 = new DefaultCacheFactory().createCache(cacheCfg.clone());
-      searchableCache1 = new SearchableCacheFactory().createSearchableCache(cache1, Person.class);
-
-      cache2 = new DefaultCacheFactory().createCache(cacheCfg.clone());
-      searchableCache2 = new SearchableCacheFactory().createSearchableCache(cache2, Person.class);
-
-      // wait until both caches are started and can see each other on the network.
-      long giveUpTime = System.currentTimeMillis() + (60 * 1000); // give up after 1 minute of waiting
-      boolean wait = true;
-      while (wait && System.currentTimeMillis() < giveUpTime)
-      {
-         wait = !((cache1.getMembers().size() == 2) && (cache2.getMembers().size() == 2));
-         // spin-lock
-         try
-         {
-            Thread.sleep(100);
-         }
-         catch (InterruptedException e)
-         {
-            // do nothing
-         }
-      }
-
-      if (wait)
-      {
-         // we still haven't got the cache views we want!!
-         throw new RuntimeException("Unable to initialise cluster!");
-      }
-
-
-      person1 = new Person();
-      person1.setName("Navin Surtani");
-      person1.setBlurb("Likes playing WoW");
-
-      person2 = new Person();
-      person2.setName("BigGoat");
-      person2.setBlurb("Eats grass");
-
-      person3 = new Person();
-      person3.setName("MiniGoat");
-      person3.setBlurb("Eats cheese");
-
-      //Put the 3 created objects in the searchableCache1.
-
-      searchableCache1.put(Fqn.fromString("/a/b/c"), key1, person1);
-      searchableCache1.put(Fqn.fromString("/a/b/d"), key2, person2);
-      searchableCache1.put(Fqn.fromString("/a/b/c"), key3, person3);
-
-
-   }
-
-   @AfterMethod
-   public void tearDown()
-   {
-      if (searchableCache1 != null) searchableCache1.stop();
-      if (searchableCache2 != null) searchableCache2.stop();
-
-      IndexCleanUp.cleanUpIndexes();
-
-   }
-
-   public void testSimple() throws ParseException
-   {
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("playing");
-      cacheQuery = searchableCache2.createQuery(luceneQuery);
-
-      found = cacheQuery.list();
-
-      assert found.size() == 1;
-
-      if(found.get(0) == null)
-      {
-         if(log.isTraceEnabled()) log.warn("found.get(0) is null");
-         Person p1 = (Person) searchableCache2.get("/a/b/c", key1);
-                         http://wiki.jboss.org/wiki/JBossCacheSearchable
-         if(p1 == null)
-         {
-            if(log.isTraceEnabled()) log.warn("Person p1 is null in sc2 and cannot actually see the data of person1 in sc1");
-         }
-
-         else
-         {
-            if(log.isTraceEnabled()) log.trace("p1 name is  " + p1.getName());
-
-         }
-      }
-
-
-      assert found.get(0).equals(person1);
-
-   }
-
-   public void testModified() throws ParseException
-   {
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("playing");
-      cacheQuery = searchableCache2.createQuery(luceneQuery);
-
-      found = cacheQuery.list();
-
-      assert found.size() == 1;
-      assert found.get(0).equals(person1);
-
-      person1.setBlurb("Likes pizza");
-      searchableCache1.put(Fqn.fromString("/a/b/c/"), "Navin", person1);
-
-
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("pizza");
-      cacheQuery = searchableCache2.createQuery(luceneQuery);
-
-      found = cacheQuery.list();
-
-      assert found.size() == 1;
-      assert found.get(0).equals(person1);
-   }
-
-   public void testAdded() throws ParseException
-   {
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-
-      luceneQuery = queryParser.parse("eats");
-      cacheQuery = searchableCache2.createQuery(luceneQuery);
-      found = cacheQuery.list();
-
-      System.out.println("found.size() is " + found.size());
-
-      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");
-
-      searchableCache1.put(Fqn.fromString("/r/a/m/"), "Ram", person4);
-
-      luceneQuery = queryParser.parse("eats");
-      cacheQuery = searchableCache2.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";
-   }
-
-   public void testRemoved() throws ParseException
-   {
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("eats");
-      cacheQuery = searchableCache2.createQuery(luceneQuery);
-      found = cacheQuery.list();
-
-      assert found.size() == 2;
-      assert found.contains(person2);
-      assert found.contains(person3) : "This should still contain object person3";
-
-      searchableCache1.remove(Fqn.fromString("/a/b/c/"), key3);
-
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("eats");
-      cacheQuery = searchableCache2.createQuery(luceneQuery);
-      found = cacheQuery.list();
-
-      assert found.size() == 1;
-      assert found.contains(person2);
-      assert !found.contains(person3) : "The search should not return person3";
-
-
-   }
-
-
-}
-
-

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/IndexCleanUp.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/IndexCleanUp.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/IndexCleanUp.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,41 +0,0 @@
-package org.jboss.cache.search.helper;
-
-import org.jboss.cache.search.test.Person;
-
-import java.io.File;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
-public class IndexCleanUp
-{
-
-   public static void cleanUpIndexes()
-   {
-      Class[] knownClasses = {Person.class};
-      for (Class c : knownClasses)
-      {
-         String dirName = c.getName();
-         File file = new File(dirName);
-         if (file.exists())
-         {
-            recursiveDelete(file);
-         }
-      }
-   }
-
-   private static void recursiveDelete(File f)
-   {
-      if (f.isDirectory())
-      {
-         File[] files = f.listFiles();
-         for (File file : files) recursiveDelete(file);
-      }
-      else
-      {
-         f.delete();
-      }
-   }
-
-}
-

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/IndexingInTransaction.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/IndexingInTransaction.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/IndexingInTransaction.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,202 +0,0 @@
-package org.jboss.cache.search.blackbox;
-
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.ProvidedId;
-import org.hibernate.search.annotations.Store;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.loader.FileCacheLoaderConfig;
-import org.jboss.cache.search.SearchableCache;
-import org.jboss.cache.search.SearchableCacheFactory;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Properties;
-
- at Test(groups = {"unit"}, sequential = true)
-public class IndexingInTransaction
-{
-
-   private static final Fqn fname = Fqn.fromString("blah");
-
-   private Cache coreCache;
-
-   private SearchableCache searchableCache;
-
-   Node node;
-
-   public IndexingInTransaction()
-   {
-      init();
-   }
-
-   @BeforeMethod
-   public void init()
-   {
-      CacheFactory factory = new DefaultCacheFactory();
-      Configuration c = new Configuration();
-      c.setInvocationBatchingEnabled(true);
-
-      CacheLoaderConfig clc = new CacheLoaderConfig();
-
-      FileCacheLoaderConfig fclc = new FileCacheLoaderConfig();
-      fclc.setAsync(false);
-      fclc.setFetchPersistentState(false);
-      fclc.setIgnoreModifications(false);
-      fclc.setPurgeOnStartup(true);
-      fclc.setLocation("/tmp/c1");
-
-      clc.addIndividualCacheLoaderConfig(fclc);
-      c.setCacheLoaderConfig(clc);
-
-      coreCache = factory.createCache(c, false);
-
-      SearchableCacheFactory f = new SearchableCacheFactory();
-      Properties p = new Properties();
-      p.put("hibernate.search.default.indexBase", "/tmp/c1idx");
-      p.put("hibernate.search.worker.batch_size", "1");
-      searchableCache = f.createSearchableCache(coreCache, p, Entity.class);
-      searchableCache.create();
-      searchableCache.start();
-      node = searchableCache.getRoot().addChild(fname);
-   }
-
-   @Test
-   public void testPutEntitiesWithoutTransaction()
-   {
-      for (int i = 1; i <= 10; i++)
-      {
-         Entity e = getEntity(i);
-         System.out.println("caching: " + e);
-         Node c = node.addChild(Fqn.fromString(e.getName()));
-         c.put("" + e.getId(), e);
-      }
-      assertFalse(searchableCache.createQuery(
-              Entity.searchByName("Name5")).list().isEmpty());
-   }
-
-   @Test
-   public void testPutEntitiesWithTransaction() throws Exception
-   {
-      ((CacheSPI) (coreCache)).getTransactionManager().begin();
-      for (int i = 15; i <= 15; i++)
-      {
-         Entity e = getEntity(i);
-         System.out.println("caching: " + e);
-         Node c = node.addChild(Fqn.fromString(e.getName()));
-         c.put("" + e.getId(), e);
-      }
-      ((CacheSPI) (coreCache)).getTransactionManager().commit();
-
-      assertFalse("there should be record for the name15",
-              searchableCache.createQuery(
-                      Entity.searchByName("Name15")).list().isEmpty());
-
-
-      searchableCache.removeNode(Fqn.fromString("Name15"));
-
-      List l = searchableCache.createQuery(Entity.searchByName("Name15")).list();
-      System.out.println(l.size());
-
-      System.out.println("Cache listeners are " + coreCache.getCacheListeners());
-      // bug: collection is not empty - there is null as there are inconsistencies in the indexes
-      assertTrue("there should be no record found", l.isEmpty());
-
-   }
-
-   Entity getEntity(long id)
-   {
-      return new Entity(id, "Name" + id, "Surname" + id, true);
-   }
-
-//    public static void main(String[] args) {
-//        IndexingInTransaction stb = new IndexingInTransaction();
-//        stb.init();
-//    }
-
-}
-
- at ProvidedId
- at Indexed
-class Entity implements Serializable
-{
-
-   public static final String IDX_NAME = "name";
-   public static final String IDX_SURNAME = "surname";
-
-   private long id;
-
-   @Field(store = Store.YES)
-   private String name;
-
-   @Field(store = Store.YES)
-   private String surname;
-
-   private boolean dead;
-
-   Entity(long id, String name, String surname, boolean dead)
-   {
-      this.id = id;
-      this.name = name;
-      this.surname = surname;
-      this.dead = dead;
-   }
-
-   public long getId()
-   {
-      return id;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public String getSurname()
-   {
-      return surname;
-   }
-
-   public boolean isDead()
-   {
-      return dead;
-   }
-
-   public static Query searchByName(String name)
-   {
-      BooleanQuery query = new BooleanQuery();
-      query.add(new TermQuery(
-              new Term(Entity.IDX_NAME,
-                      name.toLowerCase())),
-              BooleanClause.Occur.MUST);
-      return query;
-   }
-
-   @Override
-   public String toString()
-   {
-      return "Entity{" +
-              "id=" + id +
-              ", name='" + name + '\'' +
-              ", surname='" + surname + '\'' +
-              ", dead=" + dead +
-              '}';
-   }
-
-}
\ No newline at end of file

Modified: branches/ISPN-32/query/src/test/java/org/infinispan/query/LazyQueryResultIteratorTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/LazyQueryResultIteratorTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/LazyQueryResultIteratorTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,22 +1,27 @@
-package org.jboss.cache.search;
+package org.infinispan.query;
 
-import org.testng.annotations.*;
-import org.apache.lucene.search.Query;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.search.test.Person;
-import org.jboss.cache.search.helper.IndexCleanUp;
+import org.apache.lucene.search.Query;
+import org.infinispan.Cache;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.query.helper.IndexCleanUp;
+import org.infinispan.query.test.Person;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
 
 
 /**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ * @author Navin Surtani
  */
 @Test(groups = "functional")
-public class LazyQueryResultIteratorTest
+public class LazyQueryResultIteratorTest extends SingleCacheManagerTest
 {
    SearchableCache searchableCache;
    QueryParser parser = null;
@@ -27,11 +32,15 @@
    Person person1, person2, person3, person4, person5, person6, person7, person8, person9, person10;
    StringBuilder builder;
 
+   protected CacheManager createCacheManager() throws Exception {
+      return TestCacheManagerFactory.createLocalCacheManager();
+   }
 
+
    @BeforeTest
-   public void setUpBeforeTest() throws ParseException
+   public void setUpBeforeTest() throws Exception
    {
-      Cache coreCache = new DefaultCacheFactory().createCache();
+      Cache coreCache = createCacheManager().getCache();
       searchableCache = new SearchableCacheFactory().createSearchableCache(coreCache, Person.class);
 
       person1 = new Person();
@@ -56,16 +65,16 @@
       person9.setBlurb("cat");
       person10.setBlurb("cat");
 
-      searchableCache.put(Fqn.fromString("/a"), "key1", person1);
-      searchableCache.put(Fqn.fromString("/a"), "key2", person2);
-      searchableCache.put(Fqn.fromString("/a"), "key3", person3);
-      searchableCache.put(Fqn.fromString("/a"), "key4", person4);
-      searchableCache.put(Fqn.fromString("/a"), "key5", person5);
-      searchableCache.put(Fqn.fromString("/a"), "key6", person6);
-      searchableCache.put(Fqn.fromString("/a"), "key7", person7);
-      searchableCache.put(Fqn.fromString("/a"), "key8", person8);
-      searchableCache.put(Fqn.fromString("/a"), "key9", person9);
-      searchableCache.put(Fqn.fromString("/a"), "key10", person10);
+      searchableCache.put("key1", person1);
+      searchableCache.put("key2", person2);
+      searchableCache.put("key3", person3);
+      searchableCache.put("key4", person4);
+      searchableCache.put("key5", person5);
+      searchableCache.put("key6", person6);
+      searchableCache.put("key7", person7);
+      searchableCache.put("key8", person8);
+      searchableCache.put("key9", person9);
+      searchableCache.put("key10", person10);
 
 
    }
@@ -224,7 +233,7 @@
          builder.append("key");
          builder.append(i);
          String keyString = builder.toString();
-         Object expectedValue = searchableCache.get("/a", keyString);
+         Object expectedValue = searchableCache.get(keyString);
          assert iterator.hasNext(); // should have next as long as we are less than the number of elements.
 
          Object next = iterator.next();
@@ -249,7 +258,7 @@
          String keyString = builder.toString();
 
 
-         Object expectedValue = searchableCache.get("/a", keyString);
+         Object expectedValue = searchableCache.get(keyString);
 
          assert iterator.hasPrevious(); // should have previous as long as we are less than the number of elements.
 

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheProfilerTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheProfilerTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheProfilerTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,250 +0,0 @@
-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;
-
-   }
-
-}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,256 +0,0 @@
-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")
-public class LocalCacheTest
-{
-   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";
-
-   @BeforeMethod
-   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);
-
-   }
-
-   @AfterMethod
-   public void tearDown()
-   {
-      if (searchableCache != null) searchableCache.stop();
-      IndexCleanUp.cleanUpIndexes();
-   }
-
-   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);
-   }
-
-   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();
-   }
-
-   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;
-
-   }
-
-   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);
-   }
-
-   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";
-   }
-
-   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";
-
-
-   }
-
-   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);
-   }
-
-   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;
-
-   }
-
-   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();
-
-   }
-
-}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalPOJOCacheTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalPOJOCacheTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalPOJOCacheTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,213 +0,0 @@
-package org.jboss.cache.search.blackbox;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.pojo.PojoCache;
-import org.jboss.cache.pojo.PojoCacheFactory;
-import org.jboss.cache.search.CacheQuery;
-import org.jboss.cache.search.SearchableCache;
-import org.jboss.cache.search.SearchableCacheFactory;
-import org.jboss.cache.search.QueryResultIterator;
-import org.jboss.cache.search.helper.IndexCleanUp;
-import org.jboss.cache.search.test.Person;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.*;
-
-/**
- * Same as LocalCacheTest except that you will use a POJO Cache instead and use pojoCache.attach() ad pojoCache.detach()
- * instead of cache.put() and cache.remove().
- * <p/>
- *
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
-
- at Test(groups = "functional", enabled = false)
-public class LocalPOJOCacheTest
-{
-   SearchableCache searchableCache;
-   PojoCache pojo;
-   Person person1;
-   Person person2;
-   Person person3;
-   Person person4;
-   QueryParser queryParser;
-   Query luceneQuery;
-   CacheQuery cacheQuery;
-   List found;
-   private static final Log log = LogFactory.getLog(LocalPOJOCacheTest.class);
-
-
-   @BeforeMethod
-   public void setUp()
-   {
-      boolean toStart = false;
-      pojo = PojoCacheFactory.createCache(new Configuration(), toStart);
-      pojo.start(); // if toStart above is true, it will starts the cache automatically.
-      searchableCache = new SearchableCacheFactory().createSearchableCache(pojo, Person.class);
-
-      person1 = new Person();
-      person1.setName("Navin Surtani");
-      person1.setBlurb("Likes playing WoW");
-
-      person2 = new Person();
-      person2.setName("BigGoat");
-      person2.setBlurb("Eats grass");
-
-      person3 = new Person();
-      person3.setName("MiniGoat");
-      person3.setBlurb("Eats cheese");
-
-//      pojo.attach("/a", person1);
-//      pojo.attach("/b", person2);
-//      pojo.attach("/c", person3);
-
-
-   }
-
-   @AfterMethod
-   public void tearDown()
-   {
-      if (pojo != null) pojo.stop();
-      if (searchableCache != null) searchableCache.stop();
-      IndexCleanUp.cleanUpIndexes();
-   }
-
-   public void testSimple() throws ParseException
-   {
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("eats");
-      cacheQuery = searchableCache.createQuery(luceneQuery);
-
-      found = cacheQuery.list();
-
-      assert found.size() == 2;
-   }
-
-   public void testMultipleResults() throws ParseException
-   {
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("Eats");
-      cacheQuery = searchableCache.createQuery(luceneQuery);
-      found = cacheQuery.list();
-
-      System.out.println("size is " + found.size());
-      assert found.size() == 2;
-
-      System.out.println("object 0 is " + found.get(0));
-      System.out.println("object 1 is " + found.get(1));
-      assert !found.get(1).equals(person2);
-      assert !found.get(0).equals(person3);
-
-   }
-
-   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");
-
-      pojo.attach(Fqn.fromString("/a/b/c/"), 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);
-   }
-
-   public void testAdded() throws ParseException
-   {
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("eats");
-      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("MightyGoat");
-      person4.setBlurb("Also eats grass");
-
-      pojo.attach(Fqn.fromString("/d/"), person4);
-
-      luceneQuery = queryParser.parse("eats");
-      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";
-   }
-
-   public void testRemoved() throws ParseException
-   {
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("eats");
-      cacheQuery = searchableCache.createQuery(luceneQuery);
-      found = cacheQuery.list();
-
-      assert found.size() == 2;
-      assert found.contains(person3);
-      assert found.contains(person2) : "This should still contain object person2";
-
-      pojo.detach("/b");
-
-      luceneQuery = queryParser.parse("eats");
-      cacheQuery = searchableCache.createQuery(luceneQuery);
-      found = cacheQuery.list();
-
-      assert found.size() == 1;
-      assert found.contains(person3);
-      assert !found.contains(person2) : "The search should not return person2";
-
-
-   }
-
-   public void testListAdded() throws ParseException
-   {
-      List<Person> objectsToAdd = new ArrayList<Person>();
-
-      objectsToAdd.add(person1);
-      objectsToAdd.add(person2);
-      objectsToAdd.add(person3);
-
-      pojo.attach(Fqn.fromString("/d"), objectsToAdd);
-
-      queryParser = new QueryParser("blurb", new StandardAnalyzer());
-      luceneQuery = queryParser.parse("eats");
-      cacheQuery = searchableCache.createQuery(luceneQuery);
-
-      found = cacheQuery.list();
-
-      System.out.println("Size of found is " + found.size());
-
-      System.out.println(pojo.find(Fqn.fromString("/d")));
-   }
-
-}
-
-
-

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/NodeModifiedTransactionContextTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/NodeModifiedTransactionContextTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/NodeModifiedTransactionContextTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,21 +0,0 @@
-package org.jboss.cache.search;
-
-import org.testng.annotations.Test;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
-
- at Test
-public class NodeModifiedTransactionContextTest
-{
-
-   @Test (expectedExceptions = NullPointerException.class)
-   public void nullConstuctor()
-   {
-      TransactionalEventTransactionContext nmtc = new TransactionalEventTransactionContext(null);
-   }
-
-
-
-}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/NodeRemovedTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/NodeRemovedTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/NodeRemovedTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,88 +0,0 @@
-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.search.Query;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.search.SearchableCache;
-import org.jboss.cache.search.SearchableCacheFactory;
-import org.jboss.cache.search.test.Person;
-import org.jboss.cache.transaction.DummyTransactionManagerLookup;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.TransactionManager;
-import java.util.List;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
-
- at Test
-public class NodeRemovedTest
-{
-   Person p1 = new Person();
-   SearchableCache searchableCache;
-   TransactionManager tm;
-
-   @BeforeMethod
-   public void setUp()
-   {
-      p1.setName("Cat");
-      p1.setBlurb("Smelly");
-      p1.setAge(12);
-
-      Configuration cfg = new Configuration();
-      cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-      Cache cache = new DefaultCacheFactory().createCache(cfg, true);
-      tm = ((CacheSPI) cache).getTransactionManager();
-      searchableCache = new SearchableCacheFactory().createSearchableCache(cache, Person.class);
-
-   }
-
-   public void testRemoveNode() throws ParseException
-   {
-      searchableCache.put("/a", "key", p1);
-
-      QueryParser parser = new QueryParser("name", new StandardAnalyzer());
-      Query luceneQuery = parser.parse("cat");
-      List found = searchableCache.createQuery(luceneQuery, Person.class).list();
-
-      assert found.size() == 1;
-
-      searchableCache.removeNode("/a");
-
-      parser = new QueryParser("name", new StandardAnalyzer());
-      luceneQuery = parser.parse("cat");
-      found = searchableCache.createQuery(luceneQuery, Person.class).list();
-
-      assert found.size() == 0;
-   }
-
-   public void testRemoveNodeWithTx() throws Exception
-   {
-      tm.begin();
-      searchableCache.put("/a", "key", p1);
-      tm.commit();
-
-      QueryParser parser = new QueryParser("name", new StandardAnalyzer());
-      Query luceneQuery = parser.parse("cat");
-      List found = searchableCache.createQuery(luceneQuery, Person.class).list();
-
-      assert found.size() == 1;
-
-      tm.begin();
-      searchableCache.removeNode("/a");
-      tm.commit();
-
-      parser = new QueryParser("name", new StandardAnalyzer());
-      luceneQuery = parser.parse("cat");
-      found = searchableCache.createQuery(luceneQuery, Person.class).list();
-
-      assert found.size() == 0;
-   }
-}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/Person.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/Person.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/Person.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,86 +0,0 @@
-package org.jboss.cache.search.test;
-
-
-import org.hibernate.search.annotations.*;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.Serializable;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
- at ProvidedId
- at Indexed
-public class Person implements Serializable
-{
-   private static final Log log = LogFactory.getLog(Person.class);
-
-
-   @Field (store = Store.YES)
-   private String name;
-   @Field (store = Store.YES)
-   private String blurb;
-   @Field (store = Store.YES, index = Index.UN_TOKENIZED )
-   private int age;
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   public String getBlurb()
-   {
-      return blurb;
-   }
-
-   public void setBlurb(String blurb)
-   {
-      this.blurb = blurb;
-   }
-
-   public int getAge()
-   {
-      return age;
-   }
-
-   public void setAge(int age)
-   {
-      this.age = age;
-   }
-
-   public boolean equals(Object o)
-   {
-      if (this == o) return true;
-      if (o == null || getClass() != o.getClass()) return false;
-
-      Person person = (Person) o;
-
-      if (blurb != null ? !blurb.equals(person.blurb) : person.blurb != null) return false;
-      if (name != null ? !name.equals(person.name) : person.name != null) return false;
-
-      return true;
-   }
-
-   public int hashCode()
-   {
-      int result;
-      result = (name != null ? name.hashCode() : 0);
-      result = 31 * result + (blurb != null ? blurb.hashCode() : 0);
-      return result;
-   }
-
-
-   public String toString()
-   {
-      return "Person{" +
-              "name='" + name + '\'' +
-              ", blurb='" + blurb + '\'' +
-              '}';
-   }
-}

Modified: branches/ISPN-32/query/src/test/java/org/infinispan/query/QueryResultIteratorImplTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/QueryResultIteratorImplTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/QueryResultIteratorImplTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,6 +1,9 @@
-package org.jboss.cache.search;
+package org.infinispan.query;
 
-import org.jboss.cache.Fqn;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.*;
+import org.easymock.IAnswer;
+import org.infinispan.Cache;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -11,92 +14,89 @@
 import java.util.Map;
 
 /**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ * @author Navin Surtani
  *         <p/>
  *         Test class for the QueryResultIteratorImpl
  */
 
 @Test(groups = "functional")
-public class QueryResultIteratorImplTest
-{
-   List<EntityId> ids;
-   Map<EntityId, Object> dummyResults;
+public class QueryResultIteratorImplTest {
+   List<Object> keys;
+   Map<String, String> dummyResults;
    QueryResultIterator iterator;
    int fetchSize = 1;
+   Cache<String, String> cache;
 
    @BeforeMethod
-   public void setUp() throws InvalidKeyException
-   {
-      // create a set of dummy cache entity IDs
-      ids = new ArrayList();
-      ids.add(new CacheEntityId(Fqn.fromString("/a"), "key1"));
-      ids.add(new CacheEntityId(Fqn.fromString("/b"), "key2"));
-      ids.add(new CacheEntityId(Fqn.fromString("/c"), "key3"));
-      ids.add(new CacheEntityId(Fqn.fromString("/d"), "key4"));
-      ids.add(new CacheEntityId(Fqn.fromString("/e"), "key5"));
-      ids.add(new CacheEntityId(Fqn.fromString("/f"), "key6"));
-      ids.add(new CacheEntityId(Fqn.fromString("/g"), "key7"));
-      ids.add(new CacheEntityId(Fqn.fromString("/h"), "key8"));
-      ids.add(new CacheEntityId(Fqn.fromString("/i"), "key9"));
-      ids.add(new CacheEntityId(Fqn.fromString("/j"), "key10"));
+   public void setUp() throws Exception {
+      // set up the cache first.
+      // cache = createCacheManager().getCache();
 
+      // create a set of dummy keys
+      keys = new ArrayList<Object>();
       // create some dummy data
-      dummyResults = new HashMap<EntityId, Object>();
-      int counter = 0;
+      dummyResults = new HashMap<String, String>();
 
-      for (EntityId id : ids)
-      {
-         // for each cache entity ID, create a dummy result that will be returned when loading it.
-         dummyResults.put(id, "Result number " + counter++);
+      for (int i=1; i<=10; i++) {
+         String key = "key" + i;
+         keys.add(key);
+         dummyResults.put(key, "Result number " + i);
       }
 
-      // now create a dummy entity loader
-      CacheEntityLoader dummyLoader = new DummyEntityLoader(ids, dummyResults);
+      // create the instance of the iterator.
+      cache = createMock(Cache.class);
 
-      iterator = new QueryResultIteratorImpl(ids, dummyLoader, fetchSize);
+      expect(cache.get(anyObject())).andAnswer(new IAnswer<String>(){
+         public String answer() throws Throwable {
+            String k = getCurrentArguments()[0].toString();
+            return dummyResults.get(k);
+         }
+      }).anyTimes();
+
+      iterator = new QueryResultIteratorImpl(keys, cache, fetchSize);
+      EasyMock.replay(cache);
    }
 
    @AfterMethod
-   public void tearDown()
-   {
-      ids = null;
+   public void tearDown() {
+      keys = null;
       dummyResults = null;
       iterator = null;
    }
 
-   public void testJumpToResult() throws IndexOutOfBoundsException
-   {
+   public void testJumpToResult() throws IndexOutOfBoundsException {
       iterator.jumpToResult(0);
       assert iterator.isFirst();
 
       iterator.jumpToResult(1);
       assert iterator.isAfterFirst();
 
-      iterator.jumpToResult((ids.size() - 1));
+      iterator.jumpToResult((keys.size() - 1));
       assert iterator.isLast();
 
-      iterator.jumpToResult(ids.size() - 2);
+      iterator.jumpToResult(keys.size() - 2);
       assert iterator.isBeforeLast();
    }
 
-   public void testFirst()
-   {
+   public void testFirst() {
       assert iterator.isFirst() : "We should be pointing at the first element";
       Object next = iterator.next();
-      assert next == dummyResults.get(ids.get(0));
+      System.out.println(next);
+
+      assert next == dummyResults.get(keys.get(0));
+
       assert !iterator.isFirst();
 
       iterator.first();
 
       assert iterator.isFirst() : "We should be pointing at the first element";
       next = iterator.next();
-      assert next == dummyResults.get(ids.get(0));
+      assert next == dummyResults.get(keys.get(0));
       assert !iterator.isFirst();
 
    }
 
-   public void testLast()
-   {
+   public void testLast() {
       //Jumps to the last element
       iterator.last();
 
@@ -105,18 +105,17 @@
 
       Object next = iterator.next();
 
-      //Returns the size of the list of ids.
-      int size = ids.size();
+      //Returns the size of the list of keys.
+      int size = keys.size();
 
       //Makes sure that previous is the last element.
-      assert next == dummyResults.get(ids.get(size - 1));
+      assert next == dummyResults.get(keys.get(size - 1));
 
       //Check that the iterator is NOT pointing at the last element.
       assert !iterator.isLast();
    }
 
-   public void testAfterFirst()
-   {
+   public void testAfterFirst() {
       //Jump to the second element.
       iterator.afterFirst();
 
@@ -127,15 +126,14 @@
       Object previous = iterator.previous();
 
       //Check that previous is the first element.
-      assert previous == dummyResults.get(ids.get(1));
+      assert previous == dummyResults.get(keys.get(1));
 
       //Make sure that the iterator isn't pointing at the second element.
       assert !iterator.isAfterFirst();
 
    }
 
-   public void testBeforeLast()
-   {
+   public void testBeforeLast() {
       //Jump to the penultimate element.
       iterator.beforeLast();
 
@@ -146,15 +144,14 @@
       Object next = iterator.next();
 
       //Check that next is the penultimate element.
-      int size = ids.size();
-      assert next == dummyResults.get(ids.get(size - 2));
+      int size = keys.size();
+      assert next == dummyResults.get(keys.get(size - 2));
 
       //Make sure that the iterator is not pointing at the penultimate element.
       assert !iterator.isBeforeLast();
    }
 
-   public void testIsFirst()
-   {
+   public void testIsFirst() {
       iterator.first();
       assert iterator.isFirst();
 
@@ -162,8 +159,7 @@
       assert !iterator.isFirst();
    }
 
-   public void testIsLast()
-   {
+   public void testIsLast() {
       iterator.last();
       assert iterator.isLast();
 
@@ -171,8 +167,7 @@
       assert !iterator.isLast();
    }
 
-   public void testIsAfterFirst()
-   {
+   public void testIsAfterFirst() {
       iterator.afterFirst();
       assert iterator.isAfterFirst();
 
@@ -180,31 +175,26 @@
       assert !iterator.isAfterFirst();
    }
 
-   public void testIsBeforeLast()
-   {
+   public void testIsBeforeLast() {
       iterator.beforeLast();
       assert iterator.isBeforeLast();
    }
 
-   public void testNextAndHasNext()
-   {
+   public void testNextAndHasNext() {
       iterator.first();
-      for (int i = 0; i < ids.size(); i++)
-      {
+      for (int i = 0; i < keys.size(); i++) {
          System.out.println("Loop number count: - " + (i + 1));
-         Object expectedValue = dummyResults.get(ids.get(i));
+         Object expectedValue = dummyResults.get(keys.get(i));
          assert iterator.hasNext(); // should have next as long as we are less than the number of elements.
          assert expectedValue == iterator.next(); // tests next()
       }
       assert !iterator.hasNext(); // this should now NOT be true.
    }
 
-   public void testPreviousAndHasPrevious()
-   {
+   public void testPreviousAndHasPrevious() {
       iterator.last();
-      for (int i = ids.size() - 1; i >= 0; i--)
-      {
-         Object expectedValue = dummyResults.get(ids.get(i));
+      for (int i = keys.size() - 1; i >= 0; i--) {
+         Object expectedValue = dummyResults.get(keys.get(i));
          assert iterator.hasPrevious(); // should have previous as long as we are more than the number of elements.
          assert expectedValue == iterator.previous(); // tests previous()
       }
@@ -212,56 +202,21 @@
 
    }
 
-   public void testNextIndex()
-   {
+   public void testNextIndex() {
       iterator.first();
       assert iterator.nextIndex() == 1;
 
       iterator.last();
-      assert iterator.nextIndex() == ids.size();
+      assert iterator.nextIndex() == keys.size();
 
    }
 
-   public void testPreviousIndex()
-   {
+   public void testPreviousIndex() {
       iterator.first();
       assert iterator.previousIndex() == -1;
 
       iterator.last();
-      assert iterator.previousIndex() == (ids.size() - 2);
+      assert iterator.previousIndex() == (keys.size() - 2);
    }
 
-   public static class DummyEntityLoader extends CacheEntityLoader
-   {
-      private List<EntityId> allKnownIds;
-      private Map<EntityId, Object> dummyValues;
-
-      public DummyEntityLoader(List<EntityId> allKnownIds, Map<EntityId, Object> dummyValues)
-      {
-         // use a null as a cache since we won't ever need to refer to the cache
-         super(null);
-
-         this.allKnownIds = allKnownIds;
-         this.dummyValues = dummyValues;
-      }
-
-      @Override
-      public List<Object> load(List <EntityId> ids)
-      {
-         List<Object> resultsToReturn = new ArrayList<Object>(ids.size());
-         // iterate through the list of ids we are looking for
-         for (EntityId id : ids)
-         {
-            resultsToReturn.add(dummyValues.get(id));
-         }
-
-         return resultsToReturn;
-      }
-
-      @Override
-      public Object load(EntityId id)
-      {
-         return dummyValues.get(id);
-      }
-   }
 }

Modified: branches/ISPN-32/query/src/test/java/org/infinispan/query/SearchableCacheFactoryTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/SearchableCacheFactoryTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/SearchableCacheFactoryTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,11 +1,10 @@
-package org.jboss.cache.search;
+package org.infinispan.query;
 
+import org.infinispan.Cache;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.Test;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.pojo.PojoCacheFactory;
-import org.jboss.cache.pojo.PojoCache;
 
 /**
  * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
@@ -14,31 +13,19 @@
  */
 
 @Test (groups = "functional")
-public class SearchableCacheFactoryTest
+public class SearchableCacheFactoryTest extends SingleCacheManagerTest
 {
+   protected CacheManager createCacheManager() throws Exception {
+      return TestCacheManagerFactory.createLocalCacheManager();
+   }
 
    @Test (expectedExceptions = IllegalArgumentException.class)
-   public void testCreateSearchableCacheWithZeroArray()
-   {
+   public void testCreateSearchableCacheWithZeroArray() throws Exception {
       Class[] fakeClasses = new Class[0];
-      
-      Cache coreCache = new DefaultCacheFactory().createCache();
+      Cache coreCache = createCacheManager().getCache();
       SearchableCache searchableCache = new SearchableCacheFactory().createSearchableCache(coreCache, null, fakeClasses);
       
    }
 
-   @Test (expectedExceptions = IllegalArgumentException.class)
-   public void testCreateSearchableCacheWithZeroArrayPojo()
-   {
-      Class[] fakeClasses = new Class[0];
-      boolean toStart = false;
-      PojoCache pojo = PojoCacheFactory.createCache(new Configuration(), toStart);
-      pojo.start(); // if toStart above is true, it will starts the cache automatically.
 
-      SearchableCache searchableCache = new SearchableCacheFactory().createSearchableCache(pojo, null, fakeClasses);
-
-   }
-
-
-
 }

Modified: branches/ISPN-32/query/src/test/java/org/infinispan/query/SearchableCacheImplTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/SearchableCacheImplTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/SearchableCacheImplTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,28 +1,35 @@
-package org.jboss.cache.search;
+package org.infinispan.query;
 
+import org.infinispan.Cache;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
 import org.testng.annotations.Test;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
 
 /**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ * @author Navin Surtani
  */
 
 @Test (groups = "functional")
-public class SearchableCacheImplTest
+public class SearchableCacheImplTest extends SingleCacheManagerTest
 {
 
+   protected CacheManager createCacheManager() throws Exception {
+      return TestCacheManagerFactory.createLocalCacheManager();
+   }
+
+
    @Test (expectedExceptions = NullPointerException.class)
-   public void testConstructorWithNullCache()
+   public void testConstructorWithNullCache() throws Exception
    {
       SearchableCacheImpl nullCache = new SearchableCacheImpl(null, null);
       
    }
 
    @Test (expectedExceptions = NullPointerException.class)
-   public void testConstructorWithNullSearchFactory()
+   public void testConstructorWithNullSearchFactory() throws Exception
    {
-      Cache cache = new DefaultCacheFactory().createCache();
+      Cache cache = createCacheManager().getCache();
       SearchableCacheImpl nullSearchFactory = new SearchableCacheImpl(cache, null);
    }
 }

Copied: branches/ISPN-32/query/src/test/java/org/infinispan/query/TransactionalEventTransactionContextTest.java (from rev 503, branches/ISPN-32/query/src/test/java/org/infinispan/query/NodeModifiedTransactionContextTest.java)
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/TransactionalEventTransactionContextTest.java	                        (rev 0)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/TransactionalEventTransactionContextTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -0,0 +1,21 @@
+package org.infinispan.query;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Navin Surtani
+ */
+
+ at Test
+public class TransactionalEventTransactionContextTest
+{
+
+   @Test (expectedExceptions = NullPointerException.class)
+   public void testNullConstuctor()
+   {
+      TransactionalEventTransactionContext tetc = new TransactionalEventTransactionContext(null);
+   }
+
+
+
+}

Deleted: branches/ISPN-32/query/src/test/java/org/infinispan/query/TransformerTest.java
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/TransformerTest.java	2009-08-04 18:59:29 UTC (rev 631)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/TransformerTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -1,110 +0,0 @@
-package org.jboss.cache.search;
-
-import org.jboss.cache.Fqn;
-import org.testng.annotations.Test;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- *         <p/>
- *         Unit-test class for the Transformer class.
- */
-
- at Test(groups = "functional")
-public class TransformerTest
-
-{
-   /**
-    * Tests the generateId method.
-    */
-
-   public void testGenerateId() throws InvalidKeyException
-   {
-
-      Fqn fqn = Fqn.fromString("/a/b/c");
-      String key = "key";
-
-      String generatedId = Transformer.generateId(fqn, key);
-
-      assert generatedId.contentEquals("Fqn=[/a/b/c]Key=[key]");
-
-      assert !generatedId.contentEquals("/ab/c/d");
-   }
-
-   /**
-    * Tests the getFqn method.
-    */
-   public void testGetFqn()
-   {
-      Fqn fqn = Transformer.getFqn("Fqn=[/cat/dog/person]Key=[key]");
-
-      Fqn expectedFqn = Fqn.fromString("/cat/dog/person");
-
-      assert fqn.equals(expectedFqn);
-
-      expectedFqn = Fqn.fromString("/dog/cat/person");
-
-      assert !fqn.equals(expectedFqn);
-
-   }
-
-   /**
-    * Tests the getKey method.
-    */
-   public void testGetKey()
-   {
-      String key = Transformer.getKey("Fqn=[/a/b/c]Key=[thisIsMyKey]");
-
-      assert key.contentEquals("thisIsMyKey");
-
-      assert !key.contentEquals("thisIsNotMyKey");
-
-   }
-
-   @Test(expectedExceptions = NullPointerException.class)
-   public void testGetKeyWithNull()
-   {
-      Transformer.getKey(null);
-   }
-
-   @Test(expectedExceptions = InvalidFqnException.class)
-   public void testGenerateIdWithHackedString() throws InvalidKeyException
-   {
-      Transformer.generateId(Fqn.fromString("/Fqn=[/a/b/c"), "x");
-   }
-
-   @Test(expectedExceptions = InvalidFqnException.class)
-   public void testGenerateIdWithHackedFqn() throws InvalidKeyException
-   {
-      Transformer.generateId(Fqn.fromString("/Fqn=[/a/b/c"), "x");
-   }
-
-   @Test(expectedExceptions = InvalidFqnException.class)
-   public void testGenerateIdWithHackedFqn2() throws InvalidKeyException
-   {
-      Transformer.generateId(Fqn.fromString("/]Key=[/a/b/c"), "x");
-   }
-
-   @Test(expectedExceptions = InvalidKeyException.class)
-   public void testGenerateIdWithHackedKey() throws InvalidKeyException
-   {
-      Transformer.generateId(Fqn.fromString("/a/b/c"), "]Key=[");
-   }
-
-   @Test(expectedExceptions = InvalidKeyException.class)
-   public void testGenerateIdWithHackedKey2() throws InvalidKeyException
-   {
-      Transformer.generateId(Fqn.fromString("/a/b/c"), "Fqn=[");
-   }
-
-   @Test(expectedExceptions = NullPointerException.class)
-   public void testGenerateIdWithNullKey() throws InvalidKeyException
-   {
-      Transformer.generateId(Fqn.fromString("/a/b/c"), null);
-   }
-
-   @Test(expectedExceptions = NullPointerException.class)
-   public void testGenerateIdWithNullFqn() throws InvalidKeyException
-   {
-      Transformer.generateId(null, "x");
-   }
-}

Copied: branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/BrokenAnnotationTest.java (from rev 503, branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenAnnotationTest.java)
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/BrokenAnnotationTest.java	                        (rev 0)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/BrokenAnnotationTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -0,0 +1,50 @@
+package org.infinispan.query.blackbox;
+
+import org.infinispan.Cache;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.query.SearchableCache;
+import org.infinispan.query.SearchableCacheFactory;
+import org.infinispan.query.test.BrokenProvided;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.testng.annotations.Test;
+
+/**
+ * This test is to try and create a searchable cache without the proper annotations used.
+ *
+ * @author Navin Surtani
+ */
+ at Test (groups = "functional")
+public class BrokenAnnotationTest extends SingleCacheManagerTest
+{
+   @Test (expectedExceptions = IllegalArgumentException.class)
+   public void testProvided() throws Exception
+   {
+      org.infinispan.query.test.BrokenProvided provided = new org.infinispan.query.test.BrokenProvided();
+      provided.setBoth("Cat", 5);
+      
+      Cache cache = createCacheManager().getCache();
+
+      SearchableCache searchable = new SearchableCacheFactory().createSearchableCache(cache, BrokenProvided.class);
+
+
+   }
+
+   @Test (expectedExceptions = IllegalArgumentException.class)
+   public void testDocumentId() throws Exception
+   {
+      org.infinispan.query.test.BrokenDocumentId provided = new org.infinispan.query.test.BrokenDocumentId();
+      provided.setBoth("Cat", 5);
+
+      Cache cache = createCacheManager().getCache();
+
+      SearchableCache searchable = new SearchableCacheFactory().createSearchableCache(cache, BrokenProvided.class);
+
+
+
+   }
+
+   protected CacheManager createCacheManager() throws Exception {
+      return new DefaultCacheManager();  // TODO: Is there a better way to do this?
+   }
+}


Property changes on: branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/BrokenAnnotationTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java (from rev 503, branches/ISPN-32/query/src/test/java/org/infinispan/query/ClusteredCacheTest.java)
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java	                        (rev 0)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -0,0 +1,201 @@
+package org.infinispan.query.blackbox;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.query.CacheQuery;
+import org.infinispan.query.SearchableCache;
+import org.infinispan.query.SearchableCacheFactory;
+import org.infinispan.query.helper.IndexCleanUp;
+import org.infinispan.query.test.Person;
+import org.infinispan.test.MultipleCacheManagersTest;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.tree.Fqn;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ */
+ at Test(groups = "functional")
+public class ClusteredCacheTest extends MultipleCacheManagersTest
+{
+   Cache cache1, cache2;
+   SearchableCache searchableCache1, searchableCache2;
+   Person person1;
+   Person person2;
+   Person person3;
+   Person person4;
+   QueryParser queryParser;
+   Query luceneQuery;
+   CacheQuery cacheQuery;
+   List found;
+   String key1 = "Navin";
+   String key2 = "BigGoat";
+   String key3 = "MiniGoat";
+   private static final Log log = LogFactory.getLog(Person.class);
+
+   public ClusteredCacheTest() {
+      cleanup = CleanupPhase.AFTER_METHOD;
+   }
+
+   protected void createCacheManagers() throws Throwable {
+      Configuration cacheCfg = new Configuration();
+      cacheCfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+      cacheCfg.setFetchInMemoryState(false);
+
+      List<Cache<String, Person>> caches = createClusteredCaches(2, "searchable", cacheCfg);
+
+      cache1 = caches.get(0);
+      searchableCache1 = new SearchableCacheFactory().createSearchableCache(cache1, Person.class);
+
+      cache2 = caches.get(1);
+      searchableCache2 = new SearchableCacheFactory().createSearchableCache(cache2, Person.class);
+
+      TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
+
+      person1 = new Person();
+      person1.setName("Navin Surtani");
+      person1.setBlurb("Likes playing WoW");
+
+      person2 = new Person();
+      person2.setName("BigGoat");
+      person2.setBlurb("Eats grass");
+
+      person3 = new Person();
+      person3.setName("MiniGoat");
+      person3.setBlurb("Eats cheese");
+
+      //Put the 3 created objects in the searchableCache1.
+
+      searchableCache1.put(key1, person1);
+      searchableCache1.put(key2, person2);
+      searchableCache1.put(key3, person3);
+   }
+
+   @AfterMethod
+   public void tearDown() {
+      IndexCleanUp.cleanUpIndexes();
+   }
+
+   public void testSimple() throws ParseException
+   {
+      queryParser = new QueryParser("blurb", new StandardAnalyzer());
+      luceneQuery = queryParser.parse("playing");
+      cacheQuery = searchableCache2.createQuery(luceneQuery);
+
+      found = cacheQuery.list();
+
+      assert found.size() == 1;
+
+      if(found.get(0) == null)
+      {
+         if(log.isTraceEnabled()) log.warn("found.get(0) is null");
+         Person p1 = (Person) searchableCache2.get(key1);
+         if(p1 == null)
+         {
+            log.warn("Person p1 is null in sc2 and cannot actually see the data of person1 in sc1");
+         }
+
+         else
+         {
+            log.trace("p1 name is  " + p1.getName());
+
+         }
+      }
+
+
+      assert found.get(0).equals(person1);
+
+   }
+
+   public void testModified() throws ParseException
+   {
+      queryParser = new QueryParser("blurb", new StandardAnalyzer());
+      luceneQuery = queryParser.parse("playing");
+      cacheQuery = searchableCache2.createQuery(luceneQuery);
+
+      found = cacheQuery.list();
+
+      assert found.size() == 1;
+      assert found.get(0).equals(person1);
+
+      person1.setBlurb("Likes pizza");
+      searchableCache1.put("Navin", person1);
+
+
+      queryParser = new QueryParser("blurb", new StandardAnalyzer());
+      luceneQuery = queryParser.parse("pizza");
+      cacheQuery = searchableCache2.createQuery(luceneQuery);
+
+      found = cacheQuery.list();
+
+      assert found.size() == 1;
+      assert found.get(0).equals(person1);
+   }
+
+   public void testAdded() throws ParseException
+   {
+      queryParser = new QueryParser("blurb", new StandardAnalyzer());
+
+      luceneQuery = queryParser.parse("eats");
+      cacheQuery = searchableCache2.createQuery(luceneQuery);
+      found = cacheQuery.list();
+
+      System.out.println("found.size() is " + found.size());
+
+      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");
+
+      searchableCache1.put("mighty", person4);
+
+      luceneQuery = queryParser.parse("eats");
+      cacheQuery = searchableCache2.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";
+   }
+
+   public void testRemoved() throws ParseException
+   {
+      queryParser = new QueryParser("blurb", new StandardAnalyzer());
+      luceneQuery = queryParser.parse("eats");
+      cacheQuery = searchableCache2.createQuery(luceneQuery);
+      found = cacheQuery.list();
+
+      assert found.size() == 2;
+      assert found.contains(person2);
+      assert found.contains(person3) : "This should still contain object person3";
+
+      searchableCache1.remove(Fqn.fromString("/a/b/c/"), key3);
+
+      queryParser = new QueryParser("blurb", new StandardAnalyzer());
+      luceneQuery = queryParser.parse("eats");
+      cacheQuery = searchableCache2.createQuery(luceneQuery);
+      found = cacheQuery.list();
+
+      assert found.size() == 1;
+      assert found.contains(person2);
+      assert !found.contains(person3) : "The search should not return person3";
+
+
+   }
+}
+
+


Property changes on: branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/ClusteredCacheTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheProfilerTest.java (from rev 503, branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheProfilerTest.java)
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheProfilerTest.java	                        (rev 0)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheProfilerTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -0,0 +1,253 @@
+package org.infinispan.query.blackbox;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.PrefixFilter;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
+import org.infinispan.Cache;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.query.CacheQuery;
+import org.infinispan.query.QueryResultIterator;
+import org.infinispan.query.SearchableCache;
+import org.infinispan.query.SearchableCacheFactory;
+import org.infinispan.query.helper.IndexCleanUp;
+import org.infinispan.query.test.Person;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+/**
+ * @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() throws IllegalAccessException, InstantiationException {
+      CacheManager manager = new DefaultCacheManager();
+      Cache coreCache = manager.getCache();
+
+      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(key1, person1);
+      searchableCache.put(key2, person2);
+      searchableCache.put(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(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("mighty", 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(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;
+
+   }
+
+}


Property changes on: branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheProfilerTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java (from rev 503, branches/ISPN-32/query/src/test/java/org/infinispan/query/LocalCacheTest.java)
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java	                        (rev 0)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -0,0 +1,266 @@
+package org.infinispan.query.blackbox;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.PrefixFilter;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
+import org.infinispan.Cache;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.query.CacheQuery;
+import org.infinispan.query.QueryResultIterator;
+import org.infinispan.query.SearchableCache;
+import org.infinispan.query.SearchableCacheFactory;
+import org.infinispan.query.helper.IndexCleanUp;
+import org.infinispan.query.test.Person;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ */
+
+ at Test(groups = "functional")
+public class LocalCacheTest extends SingleCacheManagerTest
+{
+   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";
+
+   protected CacheManager createCacheManager() throws Exception {
+      return TestCacheManagerFactory.createLocalCacheManager();
+   }
+   
+
+
+   @BeforeMethod
+   public void setUp() throws Exception
+   {
+      Cache coreCache = createCacheManager().getCache();
+
+      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(key1, person1);
+      searchableCache.put(key2, person2);
+      searchableCache.put(key3, person3);
+
+   }
+
+   @AfterMethod
+   public void tearDown()
+   {
+      if (searchableCache != null) searchableCache.stop();
+      IndexCleanUp.cleanUpIndexes();
+   }
+
+   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);
+   }
+
+   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();
+   }
+
+   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;
+
+   }
+
+   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(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);
+   }
+
+   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("mighty", 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";
+   }
+
+   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(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";
+
+
+   }
+
+   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);
+   }
+
+   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;
+
+   }
+
+   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();
+
+   }
+
+}


Property changes on: branches/ISPN-32/query/src/test/java/org/infinispan/query/blackbox/LocalCacheTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: branches/ISPN-32/query/src/test/java/org/infinispan/query/helper/IndexCleanUp.java (from rev 503, branches/ISPN-32/query/src/test/java/org/infinispan/query/IndexCleanUp.java)
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/helper/IndexCleanUp.java	                        (rev 0)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/helper/IndexCleanUp.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -0,0 +1,41 @@
+package org.infinispan.query.helper;
+
+import org.infinispan.query.test.Person;
+
+import java.io.File;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ */
+public class IndexCleanUp
+{
+
+   public static void cleanUpIndexes()
+   {
+      Class[] knownClasses = {Person.class};
+      for (Class c : knownClasses)
+      {
+         String dirName = c.getName();
+         File file = new File(dirName);
+         if (file.exists())
+         {
+            recursiveDelete(file);
+         }
+      }
+   }
+
+   private static void recursiveDelete(File f)
+   {
+      if (f.isDirectory())
+      {
+         File[] files = f.listFiles();
+         for (File file : files) recursiveDelete(file);
+      }
+      else
+      {
+         f.delete();
+      }
+   }
+
+}
+


Property changes on: branches/ISPN-32/query/src/test/java/org/infinispan/query/helper/IndexCleanUp.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenDocumentId.java (from rev 503, branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenDocumentId.java)
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenDocumentId.java	                        (rev 0)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenDocumentId.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -0,0 +1,27 @@
+package org.infinispan.query.test;
+
+import org.hibernate.search.annotations.ProvidedId;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+
+/**
+ * @author Navin Surtani
+ */
+ at ProvidedId
+ at Indexed
+public class BrokenDocumentId
+{
+   @DocumentId
+   @Field
+   String name;
+
+   @Field
+   int age;
+
+   public void setBoth(String name, int age)
+   {
+      this.name = name;
+      this.age = age;
+   }
+}


Property changes on: branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenDocumentId.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenProvided.java (from rev 503, branches/ISPN-32/query/src/test/java/org/infinispan/query/BrokenProvided.java)
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenProvided.java	                        (rev 0)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenProvided.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -0,0 +1,26 @@
+package org.infinispan.query.test;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ */
+ at Indexed
+public class BrokenProvided
+{
+   @Field   
+   public String name;
+
+   @Field
+   public int age;
+
+   public void setBoth(String name, int age)
+   {
+      this.name = name;
+      this.age = age;
+
+   }
+
+}


Property changes on: branches/ISPN-32/query/src/test/java/org/infinispan/query/test/BrokenProvided.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: branches/ISPN-32/query/src/test/java/org/infinispan/query/test/Person.java (from rev 503, branches/ISPN-32/query/src/test/java/org/infinispan/query/Person.java)
===================================================================
--- branches/ISPN-32/query/src/test/java/org/infinispan/query/test/Person.java	                        (rev 0)
+++ branches/ISPN-32/query/src/test/java/org/infinispan/query/test/Person.java	2009-08-05 11:27:49 UTC (rev 632)
@@ -0,0 +1,86 @@
+package org.infinispan.query.test;
+
+
+import org.hibernate.search.annotations.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.Serializable;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ */
+ at ProvidedId
+ at Indexed
+public class Person implements Serializable
+{
+   private static final Log log = LogFactory.getLog(Person.class);
+
+
+   @Field (store = Store.YES)
+   private String name;
+   @Field (store = Store.YES)
+   private String blurb;
+   @Field (store = Store.YES, index = Index.UN_TOKENIZED )
+   private int age;
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   public String getBlurb()
+   {
+      return blurb;
+   }
+
+   public void setBlurb(String blurb)
+   {
+      this.blurb = blurb;
+   }
+
+   public int getAge()
+   {
+      return age;
+   }
+
+   public void setAge(int age)
+   {
+      this.age = age;
+   }
+
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      Person person = (Person) o;
+
+      if (blurb != null ? !blurb.equals(person.blurb) : person.blurb != null) return false;
+      if (name != null ? !name.equals(person.name) : person.name != null) return false;
+
+      return true;
+   }
+
+   public int hashCode()
+   {
+      int result;
+      result = (name != null ? name.hashCode() : 0);
+      result = 31 * result + (blurb != null ? blurb.hashCode() : 0);
+      return result;
+   }
+
+
+   public String toString()
+   {
+      return "Person{" +
+              "name='" + name + '\'' +
+              ", blurb='" + blurb + '\'' +
+              '}';
+   }
+}


Property changes on: branches/ISPN-32/query/src/test/java/org/infinispan/query/test/Person.java
___________________________________________________________________
Name: svn:mergeinfo
   + 



More information about the infinispan-commits mailing list