package org.hibernate.search.backend; import static org.junit.Assert.*; import java.util.Properties; import org.hibernate.search.Environment; import org.hibernate.search.impl.ImmutableSearchFactory; import org.hibernate.search.impl.MutableSearchFactoryState; import org.hibernate.search.indexes.impl.DirectoryBasedIndexManager; import org.hibernate.search.spi.WorkerBuildContext; import org.hibernate.search.spi.internals.SearchFactoryState; import org.junit.Test; public class TestBackendFactory { @Test public void test(){ BackendFactory bf = new BackendFactory(); MutableSearchFactoryState sfs = new MutableSearchFactoryState(); sfs.setConfigurationProperties(new Properties()); WorkerBuildContext wbc = new ImmutableSearchFactory(sfs); DirectoryBasedIndexManager dbim = new DirectoryBasedIndexManager(); Properties props = new Properties(); props.put(Environment.WORKER_BACKEND, "org.hibernate.search.backend.impl.blackhole.BlackHoleBackendQueueProcessor"); assertNotNull(BackendFactory.createBackend(dbim, wbc, props)); try{ props.put(Environment.WORKER_BACKEND, "lucene"); assertNotNull(BackendFactory.createBackend(dbim, wbc, props)); }catch(NullPointerException npe){} try{ props.put(Environment.WORKER_BACKEND, "jms"); assertNotNull(BackendFactory.createBackend(dbim, wbc, props)); }catch(NullPointerException npe){} try{ props.put(Environment.WORKER_BACKEND, "blackhole"); assertNotNull(BackendFactory.createBackend(dbim, wbc, props)); }catch(NullPointerException npe){} try{ props.put(Environment.WORKER_BACKEND, "jgroupsMaster"); assertNotNull(BackendFactory.createBackend(dbim, wbc, props)); }catch(NullPointerException npe){} try{ props.put(Environment.WORKER_BACKEND, "jgroupsSlave"); assertNotNull(BackendFactory.createBackend(dbim, wbc, props)); }catch(NullPointerException npe){} try{ props.put(Environment.WORKER_BACKEND, "jgroups"); assertNotNull(BackendFactory.createBackend(dbim, wbc, props)); }catch(NullPointerException npe){} props.put(Environment.WORKER_EXECUTION, "async"); assertFalse(BackendFactory.isConfiguredAsSync(props)); props.put(Environment.WORKER_EXECUTION, "test"); assertTrue(BackendFactory.isConfiguredAsSync(props)); assertNotNull(BackendFactory.buildWorkersExecutor(props, "test")); assertEquals(1, BackendFactory.getWorkerThreadPoolSize(props)); props.put(Environment.WORKER_THREADPOOL_SIZE, "5"); assertEquals(5, BackendFactory.getWorkerThreadPoolSize(props)); props.put(Environment.WORKER_WORKQUEUE_SIZE, "5"); assertEquals(5, BackendFactory.getWorkerQueueSize(props)); } }