Author: adriancole
Date: 2009-03-04 19:22:03 -0500 (Wed, 04 Mar 2009)
New Revision: 7852
Added:
core/branches/flat/src/test/java/org/horizon/loader/AbstractCacheStoreConfigTest.java
core/branches/flat/src/test/java/org/horizon/loader/AbstractCacheStoreTest.java
Modified:
core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStoreConfig.java
Log:
added javadoc and tests for base classes
Modified:
core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStoreConfig.java
===================================================================
---
core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStoreConfig.java 2009-03-04
18:04:58 UTC (rev 7851)
+++
core/branches/flat/src/main/java/org/horizon/loader/AbstractCacheStoreConfig.java 2009-03-05
00:22:03 UTC (rev 7852)
@@ -1,9 +1,17 @@
package org.horizon.loader;
/**
- * Configuration for {@link AbstractCacheStore}.
+ * Configures {@link AbstractCacheStore}. This allows you to tune a number of
characteristics of the {@link
+ * AbstractCacheStore}.
+ * <p/>
+ * <ul> <li><tt>purgeSynchronously</tt> - whether {@link
org.horizon.loader.CacheStore#purgeExpired()} calls happen
+ * synchronously or not. By default, this is set to
<tt>false</tt>.</li>
+ * <p/>
+ * </ul>
*
* @author Mircea.Markus(a)jboss.com
+ * @version $Id$
+ * @since 1.0
*/
public class AbstractCacheStoreConfig extends AbstractCacheLoaderConfig {
Added:
core/branches/flat/src/test/java/org/horizon/loader/AbstractCacheStoreConfigTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/AbstractCacheStoreConfigTest.java
(rev 0)
+++
core/branches/flat/src/test/java/org/horizon/loader/AbstractCacheStoreConfigTest.java 2009-03-05
00:22:03 UTC (rev 7852)
@@ -0,0 +1,38 @@
+package org.horizon.loader;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Unit tests that cover {@link AbstractCacheStoreConfig }
+ *
+ * @author Adrian Cole
+ * @version $Id: $
+ * @since 1.0
+ */
+@Test(groups = "unit", enabled = true, testName =
"loader.bdbje.AbstractCacheStoreConfig")
+public class AbstractCacheStoreConfigTest {
+ private AbstractCacheStoreConfig config;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ config = new AbstractCacheStoreConfig();
+ }
+
+ @AfterMethod
+ public void tearDown() throws CacheLoaderException {
+ config = null;
+ }
+
+ @Test
+ public void testIsPurgeSynchronously() {
+ assert !config.isPurgeSynchronously();
+ }
+
+ @Test
+ public void testSetPurgeSynchronously() {
+ config.setPurgeSynchronously(true);
+ assert config.isPurgeSynchronously();
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/test/java/org/horizon/loader/AbstractCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/AbstractCacheStoreTest.java
(rev 0)
+++
core/branches/flat/src/test/java/org/horizon/loader/AbstractCacheStoreTest.java 2009-03-05
00:22:03 UTC (rev 7852)
@@ -0,0 +1,56 @@
+package org.horizon.loader;
+
+import static org.easymock.classextension.EasyMock.*;
+import org.horizon.util.ReflectionUtil;
+import org.horizon.util.concurrent.WithinThreadExecutor;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.ExecutorService;
+
+/**
+ * Unit tests that cover {@link AbstractCacheStoreTest }
+ *
+ * @author Adrian Cole
+ * @version $Id: $
+ * @since 1.0
+ */
+@Test(groups = "unit", enabled = true, testName =
"loader.bdbje.AbstractCacheStoreTest")
+public class AbstractCacheStoreTest {
+ private AbstractCacheStore cs;
+ private AbstractCacheStoreConfig cfg;
+
+ @BeforeTest
+ public void setUp() throws NoSuchMethodException {
+ cs = createMock(AbstractCacheStore.class,new Method[] {
AbstractCacheStore.class.getMethod("clear", null) });
+ cfg = new AbstractCacheStoreConfig();
+ cs.init(cfg,null,null);
+ }
+
+ @AfterTest
+ public void tearDown() throws CacheLoaderException {
+ cs.stop();
+ cs = null;
+ cfg = null;
+ }
+
+
+ @Test
+ void testSynchExecutorIsSetWhenCfgPurgeSynchIsTrueOnStart() throws Exception {
+ cfg.setPurgeSynchronously(true);
+ cs.start();
+ ExecutorService service = (ExecutorService) ReflectionUtil.getValue(cs,
"purgerService");
+ assert service instanceof WithinThreadExecutor;
+ }
+
+
+ @Test
+ void testASynchExecutorIsDefaultOnStart() throws Exception {
+ cs.start();
+ ExecutorService service = (ExecutorService) ReflectionUtil.getValue(cs,
"purgerService");
+ assert !(service instanceof WithinThreadExecutor);
+ }
+
+}