[jbosscache-commits] JBoss Cache SVN: r6050 - in searchable/trunk/src: test/java/org/jboss/cache/search and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Jun 26 07:03:51 EDT 2008


Author: navssurtani
Date: 2008-06-26 07:03:51 -0400 (Thu, 26 Jun 2008)
New Revision: 6050

Added:
   searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
Modified:
   searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
   searchable/trunk/src/test/java/org/jboss/cache/search/BlackBoxTest.java
Log:
Created QueryResultIteratorImpl and fixed CacheQueryImpl

Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java	2008-06-26 11:02:27 UTC (rev 6049)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java	2008-06-26 11:03:51 UTC (rev 6050)
@@ -3,6 +3,7 @@
 import org.jboss.cache.Cache;
 
 import java.util.List;
+import java.util.NoSuchElementException;
 
 /**
  * This is the implementation class for the interface QueryResultIterator. It is what is returned when the iterate()
@@ -17,11 +18,13 @@
    //private final int size;
    private Object next;
    private int nextObjectIndex = -1;
-   private List<Object> list;
+   private List list;
+   private CacheEntityLoader entityLoader;
 
    public QueryResultIteratorImpl(List list, CacheEntityLoader entityLoader)
    {
       this.list = list;
+      this.entityLoader = entityLoader;
    }
 
    public void jumpToResult(int index) throws IndexOutOfBoundsException
@@ -71,12 +74,14 @@
 
    public boolean hasNext()
    {
-      return false;  //TODO: Implement
+      return false; //TODO: Implement
    }
 
    public Object next()
    {
-      return null;  //TODO: Implement
+      if ( !hasNext() ) throw new NoSuchElementException( "Out of boundaries" );
+      index++;
+      return next;
    }
 
    public boolean hasPrevious()
@@ -101,7 +106,6 @@
 
    public void remove()
    {
-      //TODO: Implement
    }
 
    public void set(Object o)
@@ -111,6 +115,6 @@
 
    public void add(Object o)
    {
-      //TODO: Implement
+      list.add(o);
    }
 }

Modified: searchable/trunk/src/test/java/org/jboss/cache/search/BlackBoxTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/BlackBoxTest.java	2008-06-26 11:02:27 UTC (rev 6049)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/BlackBoxTest.java	2008-06-26 11:03:51 UTC (rev 6050)
@@ -1,15 +1,14 @@
 package org.jboss.cache.search;
 
+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.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.search.test.Person;
 import org.testng.annotations.Test;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.search.Query;
-import org.hibernate.search.FullTextQuery;
 
 import java.util.List;
 
@@ -28,7 +27,7 @@
       sc.put(Fqn.fromString("/a/b/c"), "Navin", p1);
                 QueryParser qp = new QueryParser("field", new StandardAnalyzer());
        Query luceneQuery = qp.parse("playing");
-       FullTextQuery query = sc.createQuery(luceneQuery);
+       CacheQuery query = sc.createQuery(luceneQuery);
 
        List found = query.list();
 

Added: searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java	                        (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/QueryResultIteratorImplTest.java	2008-06-26 11:03:51 UTC (rev 6050)
@@ -0,0 +1,137 @@
+package org.jboss.cache.search;
+
+import org.jboss.cache.Fqn;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Navin Surtani  - navin at surtani.org
+ *         <p/>
+ *         Test class for the QueryResultIteratorImpl
+ */
+
+ at Test
+public class QueryResultIteratorImplTest
+{
+   CacheEntityLoader entityLoader;
+   List<CacheEntityId> list;
+
+   @BeforeMethod
+   public void SetUp()
+   {
+      list = new ArrayList();
+      list.add(new CacheEntityId(Fqn.fromString("/a"), "key1"));
+      list.add(new CacheEntityId(Fqn.fromString("/b"), "key2"));
+      list.add(new CacheEntityId(Fqn.fromString("/c"), "key3"));
+      list.add(new CacheEntityId(Fqn.fromString("/d"), "key4"));
+      list.add(new CacheEntityId(Fqn.fromString("/e"), "key5"));
+      list.add(new CacheEntityId(Fqn.fromString("/f"), "key6"));
+      list.add(new CacheEntityId(Fqn.fromString("/g"), "key7"));
+      list.add(new CacheEntityId(Fqn.fromString("/h"), "key8"));
+      list.add(new CacheEntityId(Fqn.fromString("/i"), "key9"));
+      list.add(new CacheEntityId(Fqn.fromString("/j"), "key10"));
+
+      QueryResultIteratorImpl iterator = new QueryResultIteratorImpl(list, entityLoader);
+
+   }
+
+   @AfterMethod
+   public void tearDown()
+   {
+      list = null;
+   }
+
+   public void jumpToResultTest(int index) throws IndexOutOfBoundsException
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public void firstTest()
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public void lastTest()
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public void afterFirstTest()
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public void beforeLastTest()
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean isFirstTest()
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean isLastTest()
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean isAfterFirstTest()
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean isBeforeLastTest()
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean hasNextTest()
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public Object nextTest()
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public boolean hasPreviousTest()
+   {
+      return false;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public Object previousTest()
+   {
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public int nextIndexTest()
+   {
+      return 0;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public int previousIndexTest()
+   {
+      return 0;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public void removeTest()
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public void setTest(Object o)
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public void addTest(Object o)
+   {
+      //To change body of implemented methods use File | Settings | File Templates.
+   }
+}




More information about the jbosscache-commits mailing list