[hibernate-commits] Hibernate SVN: r20208 - search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Fri Aug 20 09:31:48 EDT 2010
Author: hardy.ferentschik
Date: 2010-08-20 09:31:48 -0400 (Fri, 20 Aug 2010)
New Revision: 20208
Added:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/MutableSearchFactoryAndJMXTest.java
Log:
HSEARCH-278 This the SearchFactory is mutable we have to be a more devensive when registring an MBean and check first whether a bean is registered.
Added: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/MutableSearchFactoryAndJMXTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/MutableSearchFactoryAndJMXTest.java (rev 0)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/MutableSearchFactoryAndJMXTest.java 2010-08-20 13:31:48 UTC (rev 20208)
@@ -0,0 +1,60 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program 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 distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.search.test.jmx;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.hibernate.search.Environment;
+import org.hibernate.search.impl.SearchFactoryBuilder;
+import org.hibernate.search.store.RAMDirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.test.util.ManualConfiguration;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class MutableSearchFactoryAndJMXTest extends TestCase {
+ public void testRebuildFactory() throws Exception {
+ File targetDir = SearchTestCase.getTargetDir();
+ File simpleJndiDir = new File( targetDir, "simpleJndi" );
+ simpleJndiDir.mkdir();
+
+ ManualConfiguration configuration = new ManualConfiguration()
+ .addProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() )
+ .addProperty( "hibernate.session_factory_name", "java:comp/SessionFactory" )
+ .addProperty( "hibernate.jndi.class", "org.osjava.sj.SimpleContextFactory" )
+ .addProperty( "hibernate.jndi.org.osjava.sj.root", simpleJndiDir.getAbsolutePath() )
+ .addProperty( "hibernate.jndi.org.osjava.sj.jndi.shared", "true" )
+ .addProperty( Environment.JMX_ENABLED, "true" );
+
+ new SearchFactoryBuilder().configuration( configuration ).buildSearchFactory();
+
+ // if there are problems with the JMX registration there will be an exception when the new factory is build
+ new SearchFactoryBuilder().configuration( configuration ).buildSearchFactory();
+ }
+}
+
+
More information about the hibernate-commits
mailing list