Permalink
Browse files

HSEARCH-1287 Include Infinispan Directory in published JBoss Module

  • Loading branch information...
Sanne committed Mar 22, 2013
1 parent 697d6dd commit b681224b01af3e31f9c03a28499997c901f92071
@@ -0,0 +1,127 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * JBoss, Home of Professional Open Source
+ * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
+ * as indicated by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+*/
+package org.hibernate.search.test.integration.jbossas7;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.hibernate.search.test.integration.jbossas7.controller.MemberRegistration;
+import org.hibernate.search.test.integration.jbossas7.model.Member;
+import org.hibernate.search.test.integration.jbossas7.util.Resources;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor;
+import org.jboss.shrinkwrap.descriptor.api.spec.se.manifest.ManifestDescriptor;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test the Hibernate Search module in JBoss AS
+ * combined with an Infinispan Directory usage.
+ *
+ * @author Sanne Grinovero
+ */
+@RunWith(Arquillian.class)
+public class InfinispanModuleMemberRegistrationIT {
+
+ @Deployment
+ public static Archive<?> createTestArchive() {
+ WebArchive archive = ShrinkWrap
+ .create( WebArchive.class, ModuleMemberRegistrationIT.class.getSimpleName() + ".war" )
+ .addClasses( Member.class, MemberRegistration.class, Resources.class )
+ .addAsResource( persistenceXml(), "META-INF/persistence.xml" )
+ .add( manifest(), "META-INF/MANIFEST.MF" )
+ .addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" );
+ return archive;
+ }
+
+ private static Asset manifest() {
+ String manifest = Descriptors.create( ManifestDescriptor.class )
+ .attribute( "Dependencies", "org.hibernate.search.orm services" )
+ .exportAsString();
+ return new StringAsset( manifest );
+ }
+
+ private static Asset persistenceXml() {
+ String persistenceXml = Descriptors.create( PersistenceDescriptor.class )
+ .version( "2.0" )
+ .createPersistenceUnit()
+ .name( "primary" )
+ .jtaDataSource( "java:jboss/datasources/ExampleDS" )
+ .getOrCreateProperties()
+ .createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up()
+ .createProperty().name( "hibernate.search.default.lucene_version" ).value( "LUCENE_CURRENT" ).up()
+ .createProperty().name( "hibernate.search.default.directory_provider" ).value( "infinispan" ).up()
+ .createProperty().name( "hibernate.search.autoregister_listeners" ).value( "true" ).up()
+ .up().up()
+ .exportAsString();
+ return new StringAsset( persistenceXml );
+ }
+
+ @Inject
+ MemberRegistration memberRegistration;
+
+ @Test
+ public void testRegister() throws Exception {
+ Member newMember = memberRegistration.getNewMember();
+ newMember.setName( "Davide D'Alto" );
+ newMember.setEmail( "davide@mailinator.com" );
+ newMember.setPhoneNumber( "2125551234" );
+ memberRegistration.register();
+
+ assertNotNull( newMember.getId() );
+ }
+
+ @Test
+ public void testNewMemberSearch() throws Exception {
+ Member newMember = memberRegistration.getNewMember();
+ newMember.setName( "Peter O'Tall" );
+ newMember.setEmail( "peter@mailinator.com" );
+ newMember.setPhoneNumber( "4643646643" );
+ memberRegistration.register();
+
+ List<Member> search = memberRegistration.search( "Peter" );
+
+ assertFalse( "Expected at least one result after the indexing", search.isEmpty() );
+ assertEquals( "Search hasn't found a new member", newMember.getName(), search.get( 0 ).getName() );
+ }
+
+ @Test
+ public void testUnexistingMember() throws Exception {
+ List<Member> search = memberRegistration.search( "TotallyInventedName" );
+
+ assertNotNull( "Search should never return null", search );
+ assertTrue( "Search results should be empty", search.isEmpty() );
+ }
+}
@@ -46,12 +46,6 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-infinispan</artifactId>
<version>${project.version}</version>
- <exclusions>
- <exclusion>
- <artifactId>infinispan-lucene-directory</artifactId>
- <groupId>org.infinispan</groupId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -50,6 +50,11 @@
<outputDirectory>/modules/org/hibernate/search/orm/${hibernate.search.module.slot}</outputDirectory>
<filtered>true</filtered>
</file>
+ <file>
+ <source>${module.xml.basedir}/infinispan/lucene-directory/module.xml</source>
+ <outputDirectory>/modules/org/infinispan/lucene-directory/${infinispanVersion}</outputDirectory>
+ <filtered>true</filtered>
+ </file>
</files>
<dependencySets>
@@ -81,6 +86,17 @@
<include>org.hibernate:hibernate-search-orm</include>
</includes>
</dependencySet>
+
+ <dependencySet>
+ <useProjectArtifact>false</useProjectArtifact>
+ <outputDirectory>/modules/org/infinispan/lucene-directory/${infinispanVersion}</outputDirectory>
+ <useTransitiveFiltering>false</useTransitiveFiltering>
+ <unpack>false</unpack>
+ <includes>
+ <include>org.infinispan:infinispan-lucene-directory</include>
+ </includes>
+ </dependencySet>
+
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>modules/org/apache/lucene/${luceneVersion}</outputDirectory>
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2013, 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
+ -->
+<module xmlns="urn:jboss:module:1.1" name="org.infinispan.lucene-directory" slot="${infinispanVersion}">
+ <resources>
+ <resource-root path="infinispan-lucene-directory-${infinispanVersion}.jar" />
+ </resources>
+ <dependencies>
+ <module name="org.apache.lucene" slot="${luceneVersion}" />
+ <module name="org.infinispan" />
+ <module name="org.jboss.logging" />
+ </dependencies>
+</module>
@@ -38,9 +38,10 @@
<module name="org.hibernate" />
<module name="org.apache.lucene" export="true" slot="${luceneVersion}" />
<module name="org.apache.solr" export="true" optional="true" slot="${luceneVersion}" />
+ <module name="org.infinispan.lucene-directory" slot="${infinispanVersion}" />
+ <module name="org.infinispan" />
<module name="org.jboss.logging" />
<module name="org.jgroups" />
- <module name="org.infinispan" />
<module name="javax.persistence.api" />
<!-- For naming (used by Hibernate Search Infinispan) -->

0 comments on commit b681224

Please sign in to comment.