[jbosscache-commits] JBoss Cache SVN: r7931 - in searchable/trunk: src/main/java/org/jboss/cache/search and 2 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Mar 20 10:02:50 EDT 2009


Author: manik.surtani at jboss.com
Date: 2009-03-20 10:02:50 -0400 (Fri, 20 Mar 2009)
New Revision: 7931

Added:
   searchable/trunk/src/main/java/org/jboss/cache/search/TransactionalEventTransactionContext.java
Removed:
   searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java
   searchable/trunk/src/main/java/org/jboss/cache/search/NodeRemovedTransactionContext.java
Modified:
   searchable/trunk/pom.xml
   searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
   searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
   searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java
   searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java
   searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java
   searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java
Log:
Added more tests

Modified: searchable/trunk/pom.xml
===================================================================
--- searchable/trunk/pom.xml	2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/pom.xml	2009-03-20 14:02:50 UTC (rev 7931)
@@ -63,16 +63,6 @@
             <version>1.2.0</version>
             <scope>test</scope>
         </dependency>
-
-        <!-- Optional deps -->
-        <dependency>
-            <groupId>jdbm</groupId>
-            <artifactId>jdbm</artifactId>
-            <version>1.0</version>
-            <optional>true</optional>
-        </dependency>
-
-
     </dependencies>
     <build>
         <plugins>

Deleted: searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java	2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java	2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,103 +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.jboss.cache.search;
-
-import org.hibernate.search.backend.TransactionContext;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
-
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
-
-/**
- * This class implements the {@link org.hibernate.search.backend.TransactionContext} interface.  It
- * retrieves transaction context information from the {@link org.jboss.cache.notifications.event.NodeModifiedEvent} that gets passed in.
- * <p />
- * It is used by the {@link SearchableCoreListener} to pass transaction information to a Hibernate Search {@link org.hibernate.search.backend.Work} object.
- * <p />
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- * @see SearchableCoreListener
- */
-public class NodeModifiedTransactionContext implements TransactionContext
-{
-
-   NodeModifiedEvent event;
-
-   /**
-    * Creates a new instance of NodeModifiedTransactionContext.
-    * <p />
-    * @param event a NodeModifiedEvent to wrap.  Should not be null.
-    * @throws NullPointerException if event is null.
-    */
-   public NodeModifiedTransactionContext(NodeModifiedEvent event)
-   {
-      if (event == null) throw new NullPointerException("event cannot be null");
-      this.event = event;
-   }
-
-   /**
-    * Returns a boolean value whether or not a transaction is in progress (JTA transaction and in this case *not*
-    * an org.hibernate transaction).
-    * @return true if a transaction is in progress, false otherwise.
-    */
-   public boolean isTransactionInProgress()
-   {
-      return (event.getTransaction() != null);
-   }
-
-   /**
-    * Returns a JTA transaction.
-    * @return a JTA transaction if one is available, or a null otherwise.
-    * @see org.jboss.cache.notifications.event.NodeModifiedEvent#getTransaction()
-    */
-
-   public Object getTransactionIdentifier()
-   {
-      return event.getTransaction();
-   }
-
-   /**
-    * Registers the synchronization passed in as a parameter with the ongoing transaction.
-    * <p />
-    * If there is no ongoing transaction, then this method will do nothing and simply return.
-    * <p />
-    * @param synchronization synchronization to register.  Must not be null.
-    * @throws NullPointerException if the synchronization is null.
-    */
-   public void registerSynchronization(Synchronization synchronization)
-   {
-      if (synchronization == null) throw new NullPointerException("Synchronization passed in is null!");
-
-      Transaction transaction = event.getTransaction();
-      if (transaction != null)
-      {
-         try
-         {
-            transaction.registerSynchronization(synchronization);
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-   }
-}

Deleted: searchable/trunk/src/main/java/org/jboss/cache/search/NodeRemovedTransactionContext.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/NodeRemovedTransactionContext.java	2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/NodeRemovedTransactionContext.java	2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,52 +0,0 @@
-package org.jboss.cache.search;
-
-import org.hibernate.search.backend.TransactionContext;
-import org.jboss.cache.notifications.event.NodeRemovedEvent;
-
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
- */
-public class NodeRemovedTransactionContext implements TransactionContext
-{
-
-   NodeRemovedEvent event;
-
-   public NodeRemovedTransactionContext(NodeRemovedEvent event)
-   {
-      if (event == null) throw new NullPointerException("event cannot be null");
-      this.event = event;
-   }
-
-   public boolean isTransactionInProgress()
-   {
-      return (event.getTransaction() != null);
-   }
-
-   public Object getTransactionIdentifier()
-   {
-      return event.getTransaction();
-   }
-
-   public void registerSynchronization(Synchronization synchronization)
-   {
-      if (synchronization == null) throw new NullPointerException("Synchronization passed in is null!");
-
-      Transaction transaction = event.getTransaction();
-      if (transaction != null)
-      {
-         try
-         {
-            transaction.registerSynchronization(synchronization);
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException(e);
-         }
-
-
-      }
-   }
-}

Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java	2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java	2009-03-20 14:02:50 UTC (rev 7931)
@@ -101,8 +101,8 @@
       c.addCacheListener(coreListener);
 
       //Create secondary listener
-      SearchableCoreRemover remover = new SearchableCoreRemover(searchFactory);
-      c.addCacheListener(remover);
+//      SearchableCoreRemover remover = new SearchableCoreRemover(searchFactory);
+//      c.addCacheListener(remover);
 
       //Create the searchableCache and pass it on.
       SearchableCache sc = new SearchableCacheImpl(c, searchFactory);

Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java	2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java	2009-03-20 14:02:50 UTC (rev 7931)
@@ -22,6 +22,8 @@
 
 package org.jboss.cache.search;
 
+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;
@@ -29,12 +31,12 @@
 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.NodeEvent;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.notifications.event.TransactionRegisteredEvent;
 
+import javax.transaction.Transaction;
 import java.util.Map;
 
 /**
@@ -93,7 +95,7 @@
          Map dataMap = event.getData();
          if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
 
-         TransactionContext ctx = new NodeRemovedTransactionContext(event);
+         TransactionContext ctx = new TransactionalEventTransactionContext(event);
 
          for (Object key : dataMap.keySet())
          {
@@ -115,6 +117,22 @@
    }
 
    /**
+    * 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
     *
@@ -130,7 +148,7 @@
       if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
 
 
-      TransactionContext ctx = new NodeModifiedTransactionContext(event);
+      TransactionContext ctx = new TransactionalEventTransactionContext(event);
 
       for (Object key : dataMap.keySet())
       {
@@ -168,7 +186,7 @@
    {
       Map dataMap = event.getData();
 
-      TransactionContext ctx = new NodeModifiedTransactionContext(event);
+      TransactionContext ctx = new TransactionalEventTransactionContext(event);
 
       for (Object key : dataMap.keySet())
       {

Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java	2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java	2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,16 +1,14 @@
 package org.jboss.cache.search;
 
-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.event.NodeEvent;
-import org.jboss.cache.notifications.event.NodeRemovedEvent;
 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.NodeRemoved;
+import org.jboss.cache.notifications.event.NodeRemovedEvent;
 
 import java.util.Map;
 
@@ -41,7 +39,7 @@
          Map dataMap = event.getData();
          if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
 
-         TransactionContext ctx = new NodeRemovedTransactionContext(event);
+         TransactionContext ctx = new TransactionalEventTransactionContext(event);
 
          for (Object key : dataMap.keySet())
          {

Copied: searchable/trunk/src/main/java/org/jboss/cache/search/TransactionalEventTransactionContext.java (from rev 7930, searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java)
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/TransactionalEventTransactionContext.java	                        (rev 0)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/TransactionalEventTransactionContext.java	2009-03-20 14:02:50 UTC (rev 7931)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+
+package org.jboss.cache.search;
+
+import org.hibernate.search.backend.TransactionContext;
+import org.jboss.cache.notifications.event.TransactionalEvent;
+
+import javax.transaction.Synchronization;
+import javax.transaction.Transaction;
+
+/**
+ * This class implements the {@link org.hibernate.search.backend.TransactionContext} interface.  It
+ * retrieves transaction context information from the {@link org.jboss.cache.notifications.event.NodeModifiedEvent} that gets passed in.
+ * <p />
+ * It is used by the {@link SearchableCoreListener} to pass transaction information to a Hibernate Search {@link org.hibernate.search.backend.Work} object.
+ * <p />
+ * @author Navin Surtani (<a href="mailto:nsurtani at redhat.com">nsurtani at redhat.com</a>)
+ * @see SearchableCoreListener
+ */
+public class TransactionalEventTransactionContext implements TransactionContext
+{
+
+   TransactionalEvent event;
+
+   /**
+    * Creates a new instance of NodeModifiedTransactionContext.
+    * <p />
+    * @param event a NodeModifiedEvent to wrap.  Should not be null.
+    * @throws NullPointerException if event is null.
+    */
+   public TransactionalEventTransactionContext(TransactionalEvent event)
+   {
+      if (event == null) throw new NullPointerException("event cannot be null");
+      this.event = event;
+   }
+
+   /**
+    * Returns a boolean value whether or not a transaction is in progress (JTA transaction and in this case *not*
+    * an org.hibernate transaction).
+    * @return true if a transaction is in progress, false otherwise.
+    */
+   public boolean isTransactionInProgress()
+   {
+      return (event.getTransaction() != null);
+   }
+
+   /**
+    * Returns a JTA transaction.
+    * @return a JTA transaction if one is available, or a null otherwise.
+    * @see org.jboss.cache.notifications.event.NodeModifiedEvent#getTransaction()
+    */
+
+   public Object getTransactionIdentifier()
+   {
+      return event.getTransaction();
+   }
+
+   /**
+    * Registers the synchronization passed in as a parameter with the ongoing transaction.
+    * <p />
+    * If there is no ongoing transaction, then this method will do nothing and simply return.
+    * <p />
+    * @param synchronization synchronization to register.  Must not be null.
+    * @throws NullPointerException if the synchronization is null.
+    */
+   public void registerSynchronization(Synchronization synchronization)
+   {
+      if (synchronization == null) throw new NullPointerException("Synchronization passed in is null!");
+
+      Transaction transaction = event.getTransaction();
+      if (transaction != null)
+      {
+         try
+         {
+            transaction.registerSynchronization(synchronization);
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+   }
+}

Modified: searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java	2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java	2009-03-20 14:02:50 UTC (rev 7931)
@@ -13,7 +13,7 @@
    @Test (expectedExceptions = NullPointerException.class)
    public void nullConstuctor()
    {
-      NodeModifiedTransactionContext nmtc = new NodeModifiedTransactionContext(null);
+      TransactionalEventTransactionContext nmtc = new TransactionalEventTransactionContext(null);
    }
 
 

Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java	2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java	2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,28 +1,33 @@
 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.Indexed;
 import org.hibernate.search.annotations.Store;
-import org.jboss.cache.*;
-import org.jboss.cache.loader.jdbm.JdbmCacheLoaderConfig;
+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.config.CacheLoaderConfig;
+import org.jboss.cache.loader.FileCacheLoaderConfig;
+import org.jboss.cache.search.SearchableCache;
 import org.jboss.cache.search.SearchableCacheFactory;
-import org.jboss.cache.search.SearchableCache;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.index.Term;
 
-import static org.testng.AssertJUnit.*;
-
+import java.io.Serializable;
+import java.util.List;
 import java.util.Properties;
-import java.util.List;
-import java.io.Serializable;
 
 @Test(groups = {"unit"}, sequential = true)
 public class IndexingInTransaction
@@ -50,14 +55,14 @@
 
       CacheLoaderConfig clc = new CacheLoaderConfig();
 
-      JdbmCacheLoaderConfig jclc = new JdbmCacheLoaderConfig();
-      jclc.setAsync(false);
-      jclc.setFetchPersistentState(false);
-      jclc.setIgnoreModifications(false);
-      jclc.setPurgeOnStartup(true);
-      jclc.setLocation("/tmp/c1");
+      FileCacheLoaderConfig fclc = new FileCacheLoaderConfig();
+      fclc.setAsync(false);
+      fclc.setFetchPersistentState(false);
+      fclc.setIgnoreModifications(false);
+      fclc.setPurgeOnStartup(true);
+      fclc.setLocation("/tmp/c1");
 
-      clc.addIndividualCacheLoaderConfig(jclc);
+      clc.addIndividualCacheLoaderConfig(fclc);
       c.setCacheLoaderConfig(clc);
 
       coreCache = factory.createCache(c, false);

Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java	2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java	2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,18 +1,21 @@
 package org.jboss.cache.search.blackbox;
 
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import org.jboss.cache.search.test.Person;
+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.SearchableCoreRemover;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-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.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;
 
 /**
@@ -24,6 +27,7 @@
 {
    Person p1 = new Person();
    SearchableCache searchableCache;
+   TransactionManager tm;
 
    @BeforeMethod
    public void setUp()
@@ -32,7 +36,10 @@
       p1.setBlurb("Smelly");
       p1.setAge(12);
 
-      Cache cache = new DefaultCacheFactory().createCache(true);
+      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);
 
    }
@@ -56,4 +63,26 @@
       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;
+   }
 }




More information about the jbosscache-commits mailing list