[jbosscache-commits] JBoss Cache SVN: r7612 - 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 Jan 29 10:37:00 EST 2009


Author: navssurtani
Date: 2009-01-29 10:36:59 -0500 (Thu, 29 Jan 2009)
New Revision: 7612

Added:
   searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheFactoryTest.java
Modified:
   searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
Log:
More validation

Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java	2009-01-29 12:44:21 UTC (rev 7611)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java	2009-01-29 15:36:59 UTC (rev 7612)
@@ -86,7 +86,7 @@
 
       if (classes.length == 0)
       {
-         if (log.isWarnEnabled()) log.warn("You haven't passed in any classes to index.  Is this an error?");
+         throw new IllegalArgumentException("You haven't passed in any classes to index.");
       }
 
       // step 1: create hibernate search searchFactory
@@ -132,7 +132,7 @@
 
       if (classes.length == 0)
       {
-         if (log.isWarnEnabled()) log.warn("You haven't passed in any classes to index.  Is this an error?");
+         throw new IllegalArgumentException("You haven't passed in any classes to index.");
       }
 
       // step 1: create hibernate search searchFactory

Added: searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheFactoryTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheFactoryTest.java	                        (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/SearchableCacheFactoryTest.java	2009-01-29 15:36:59 UTC (rev 7612)
@@ -0,0 +1,44 @@
+package org.jboss.cache.search;
+
+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>)
+ *
+ * Test class for the SearchableCacheFactory.
+ */
+
+ at Test (groups = "functional")
+public class SearchableCacheFactoryTest
+{
+
+   @Test (expectedExceptions = IllegalArgumentException.class)
+   public void testCreateSearchableCacheWithZeroArray()
+   {
+      Class[] fakeClasses = new Class[0];
+      
+      Cache coreCache = new DefaultCacheFactory().createCache();
+      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);
+
+   }
+
+
+
+}




More information about the jbosscache-commits mailing list