/
MongoDBWildFlyNoSQLMemberRegistrationIT.java
54 lines (48 loc) · 2.44 KB
/
MongoDBWildFlyNoSQLMemberRegistrationIT.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Hibernate OGM, Domain model persistence for NoSQL datastores
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.ogm.test.integration.mongodb.wildflynosql;
import org.hibernate.ogm.cfg.OgmProperties;
import org.hibernate.ogm.datastore.mongodb.MongoDB;
import org.hibernate.ogm.test.integration.mongodb.MongoDBModuleMemberRegistrationScenario;
import org.hibernate.ogm.test.integration.mongodb.errorhandler.TestErrorHandler;
import org.junit.runner.RunWith;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor;
import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceUnit;
import org.jboss.shrinkwrap.descriptor.api.persistence20.Properties;
/**
* Test for the Hibernate OGM module in WildFly using MongoDB
* and WildFly NoSql subsystem
*
* @author Fabio Massimo Ercoli
*/
@RunWith(Arquillian.class)
public class MongoDBWildFlyNoSQLMemberRegistrationIT extends MongoDBModuleMemberRegistrationScenario {
@Deployment
public static Archive<?> createTestArchive() {
return createTestArchiveFromPersistenceXml( persistenceXml() );
}
private static PersistenceDescriptor persistenceXml() {
Properties<PersistenceUnit<PersistenceDescriptor>> propertiesContext = Descriptors.create( PersistenceDescriptor.class )
.version( "2.0" )
.createPersistenceUnit()
.name( "primary" )
.provider( "org.hibernate.ogm.jpa.HibernateOgmPersistence" )
.getOrCreateProperties();
return propertiesContext
.createProperty().name( OgmProperties.DATASTORE_PROVIDER ).value( MongoDB.DATASTORE_PROVIDER_NAME ).up()
.createProperty().name( OgmProperties.NATIVE_CLIENT_RESOURCE ).value( "java:jboss/mongodb/client" ).up()
.createProperty().name( OgmProperties.CREATE_DATABASE ).value( "true" ).up()
.createProperty().name( OgmProperties.ERROR_HANDLER ).value( TestErrorHandler.class.getName() ).up()
.createProperty().name( "hibernate.search.default.directory_provider" ).value( "ram" ).up()
.createProperty().name( "wildfly.jpa.hibernate.search.module" ).value( "org.hibernate.search.orm:${module-slot.org.hibernate.search.short-id}" ).up()
.up().up();
}
}