HHH-13952 Remove our ability to build the Wildfly feature pack and run integration tests on WildFly
This commit is contained in:
parent
95c9526dda
commit
2b279c6a83
|
@ -55,8 +55,8 @@ task release {
|
|||
"the fact that subprojects will appropriately define a release task " +
|
||||
"themselves if they have any release-related activities to perform"
|
||||
|
||||
// Force to release with JDK 8. Releasing with JDK 11 is not supported yet:
|
||||
// - the hibernate-orm-modules tests do not run due to an issue with the ASM version currently used by Gradle
|
||||
// Force to release with JDK 8. It used to not work on JDK11 because of the hibernate-orm-modules module,
|
||||
// but this limitation might be resolved now that this module has been deleted?
|
||||
doFirst {
|
||||
if ( !JavaVersion.current().isJava8() || !gradle.ext.testedJavaVersionAsEnum.isJava8() ) {
|
||||
throw new IllegalStateException( "Please use JDK 8 to perform the release." )
|
||||
|
|
|
@ -15,7 +15,6 @@ ext {
|
|||
'hibernate-infinispan',
|
||||
'hibernate-ehcache',
|
||||
'hibernate-java8',
|
||||
'hibernate-orm-modules',
|
||||
'hibernate-integrationtest-java-modules',
|
||||
'release'
|
||||
]
|
||||
|
|
|
@ -245,17 +245,11 @@ processTestResources {
|
|||
copy {
|
||||
from file( 'src/test/resources' )
|
||||
into file( "${buildDir}/resources/test" )
|
||||
include 'arquillian.xml'
|
||||
include 'org/hibernate/test/wf/ddl/manifest.mf'
|
||||
expand wildFlyInstallDir: project( ':hibernate-orm-modules' ).wildFlyInstallDir,
|
||||
hibernateMajorMinorVersion: "${project.ormVersion.family}",
|
||||
arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test.dependsOn ':hibernate-orm-modules:prepareWildFlyForTests'
|
||||
|
||||
test {
|
||||
systemProperty 'file.encoding', 'utf-8'
|
||||
beforeTest { descriptor ->
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<arquillian
|
||||
xmlns="http://jboss.org/schema/arquillian"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
|
||||
|
||||
<defaultProtocol type="Servlet 3.0" />
|
||||
|
||||
<!-- Uncomment in order to inspect deployments -->
|
||||
<!--
|
||||
<engine>
|
||||
<property name="deploymentExportPath">${arquillianDeploymentExportDir}</property>
|
||||
</engine>
|
||||
-->
|
||||
|
||||
<group qualifier="Grid" default="true">
|
||||
<container qualifier="container.active-1" mode="suite" default="true">
|
||||
<configuration>
|
||||
<property name="jbossHome">${wildFlyInstallDir}</property>
|
||||
<!-- For Remote debugging of Wildfly add the following line to the 'javaVmArguments' section below: -->
|
||||
<!-- -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y-->
|
||||
<!-- DO NOT add comments within the property section below as the Arquillian parser can't deal with it -->
|
||||
<property name="javaVmArguments">
|
||||
-Dee8.preview.mode=true
|
||||
-Djava.net.preferIPv4Stack=true
|
||||
-Djgroups.bind_addr=127.0.0.1
|
||||
</property>
|
||||
</configuration>
|
||||
</container>
|
||||
</group>
|
||||
</arquillian>
|
|
@ -1,159 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* 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>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id "org.wildfly.build.provision" version '0.0.11'
|
||||
id "org.wildfly.build.featurepack" version '0.0.11'
|
||||
}
|
||||
|
||||
|
||||
|
||||
apply from: rootProject.file( 'gradle/base-information.gradle' )
|
||||
apply plugin: 'java'
|
||||
apply from: rootProject.file( 'gradle/libraries.gradle' )
|
||||
|
||||
ext {
|
||||
// NOTE : `wildflyVersion` comes from libraries.gradle...
|
||||
|
||||
// "10" for WildFly 10.x, "11" for 11.x, etc
|
||||
wildFlyMajorVersion = project.wildflyVersion.split( '\\.' )[0]
|
||||
bytebuddyVersion = project.byteBuddyVersion
|
||||
artifactClassifier = "wildfly-${wildFlyMajorVersion}-dist"
|
||||
wildFlyInstallDir = "$rootProject.buildDir/wildfly"
|
||||
fpackStagingDir = file( "target/featurepack" ) //Target build directory for the Feature Pack
|
||||
}
|
||||
|
||||
description = "Feature Pack of Hibernate ORM modules for WildFly ${project.wildFlyMajorVersion}"
|
||||
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'org.hibernate.build.maven-repo-auth'
|
||||
apply from: rootProject.file( 'gradle/publishing-repos.gradle' )
|
||||
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
|
||||
|
||||
apply plugin: 'build-dashboard'
|
||||
apply plugin: 'project-report'
|
||||
|
||||
project.tasks.jar.enabled = false
|
||||
project.tasks.javadoc.enabled = false
|
||||
|
||||
evaluationDependsOn( ':hibernate-core' )
|
||||
evaluationDependsOn( ':hibernate-envers' )
|
||||
|
||||
configurations {
|
||||
featurePack {
|
||||
description = "Dependencies to be included in the published Feature Pack"
|
||||
}
|
||||
provisioning {
|
||||
description = "Dependencies which should be made available to the provisioning of WildFly"
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
name 'jboss-public'
|
||||
url 'https://repository.jboss.org/nexus/content/groups/public/'
|
||||
}
|
||||
}
|
||||
|
||||
//This builds the WildFly Feature Packs which define the Hibernate ORM modules
|
||||
// # Definitions of the modules are in /module-templates
|
||||
// # Versions of the included libraries are defined in the "featurePack" configuration (below)
|
||||
// # See the "variables" option to replace tokens in the module definitions
|
||||
// # This just creates the exploded feature pack: does NOT create a zip nor a publication, which are handled by other tasks below.
|
||||
featurepack {
|
||||
moduleTemplates = file( 'module-templates' ) //where to find the templates for module.xml files to generate
|
||||
destinationDir = project.fpackStagingDir
|
||||
configurationName 'featurePack'
|
||||
// Variables to be replaced in the template. N.B. not all variables need to be replaced!
|
||||
// Exact ORM version, e.g. "5.3.0.Final"
|
||||
variables['slot'] = rootProject.ormVersion.fullName
|
||||
// Just the minor ORM version, e.g. "5.3"; Is used as an alias for the exact version
|
||||
variables['minorSlot'] = rootProject.ormVersion.family
|
||||
variables['bytebuddySlot'] = bytebuddyVersion
|
||||
variables['infinispan2lcSlot'] = 'for-orm-' + rootProject.ormVersion.family
|
||||
//Dependency on another Feature Pack:
|
||||
dependency "org.wildfly:wildfly-feature-pack:${project.wildflyVersion}" // It will assume it is "zip" by default
|
||||
//Ensure we declare all source repositories explicitly
|
||||
autoAddRepositories = false
|
||||
}
|
||||
|
||||
task createCoreFeaturePackZip( type: Zip, dependsOn: [featurepack] ) {
|
||||
baseName 'hibernate-orm-jbossmodules'
|
||||
from project.fpackStagingDir
|
||||
}
|
||||
|
||||
provision {
|
||||
dependsOn( createCoreFeaturePackZip )
|
||||
dependsOn( ":hibernate-envers:jar")
|
||||
dependsOn( ":hibernate-core:jar")
|
||||
configuration = file( 'wildfly-server-provisioning.xml' )
|
||||
destinationDir = file( "$project.wildFlyInstallDir" )
|
||||
//Override HCANN:
|
||||
override( 'org.hibernate.common:hibernate-commons-annotations' ) {
|
||||
version = project.hibernateCommonsVersion
|
||||
}
|
||||
variables['wildfly.version'] = project.wildflyVersion
|
||||
variables['hibernate-orm.version'] = rootProject.ormVersion.fullName
|
||||
//Ensure we declare all source repositories explicitly
|
||||
autoAddRepositories = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile project( ":hibernate-core" )
|
||||
testCompile project( ":hibernate-envers" )
|
||||
testCompile libraries.junit
|
||||
testCompile libraries.arquillian_junit_container
|
||||
testCompile libraries.arquillian_protocol_servlet
|
||||
testCompile libraries.shrinkwrap_descriptors_api_javaee
|
||||
testCompile libraries.shrinkwrap_descriptors_impl_javaee
|
||||
testCompile libraries.wildfly_arquillian_container_managed
|
||||
|
||||
featurePack libraries.byteBuddy
|
||||
featurePack project( ":hibernate-core" )
|
||||
featurePack project( ":hibernate-envers" )
|
||||
featurePack "org.wildfly:jipijapa-hibernate5:${wildflyVersion}"
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publishedArtifacts {
|
||||
artifact( createCoreFeaturePackZip ) {
|
||||
artifactId 'hibernate-orm-jbossmodules'
|
||||
description 'Main feature pack of Hibernate ORM: hibernate-core and hibernate-envers, including essential dependencies such as Byte Buddy'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task ciBuild( dependsOn: [clean, test, publish] )
|
||||
task release( dependsOn: [clean, test, bintrayUpload] )
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// tasks related to in-container (Arquillian + WF) testing
|
||||
|
||||
task prepareWildFlyForTests( dependsOn: [provision] ) {
|
||||
description = 'Downloads the WildFly distribution, installs it into a local directory, includes present version of Hibernate ORM, JPA 2.2 : ready for integration tests'
|
||||
}
|
||||
|
||||
test {
|
||||
exclude 'org/hibernate/wildfly/model/**'
|
||||
}
|
||||
|
||||
|
||||
test.dependsOn prepareWildFlyForTests
|
||||
|
||||
processTestResources {
|
||||
expand(
|
||||
[
|
||||
wildFlyInstallDir : project.wildFlyInstallDir,
|
||||
arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments"
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="net.bytebuddy" slot="${bytebuddySlot}">
|
||||
<properties>
|
||||
<property name="jboss.api" value="private"/>
|
||||
</properties>
|
||||
|
||||
<resources>
|
||||
<artifact name="${net.bytebuddy:byte-buddy}"/>
|
||||
</resources>
|
||||
<dependencies>
|
||||
<!-- ByteBuddy currently uses sun.misc.Unsafe -->
|
||||
<module name="sun.jdk"/>
|
||||
</dependencies>
|
||||
</module>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<module-alias xmlns="urn:jboss:module:1.3"
|
||||
name="org.hibernate.orm" slot="${minorSlot}"
|
||||
target-name="org.hibernate.orm" target-slot="${slot}"
|
||||
/>
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="org.hibernate" slot="${minorSlot}">
|
||||
|
||||
<properties>
|
||||
<property name="jboss.api" value="deprecated"/>
|
||||
<!-- This module is using the old name. Please use "org.hibernate.orm" in the future,
|
||||
and declare the dependency on "org.hibernate.envers" explicitly as well if it's used -->
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<module name="org.hibernate.orm" services="import" export="true" slot="${minorSlot}"/>
|
||||
<module name="org.hibernate.envers" services="import" export="true" slot="${minorSlot}"/>
|
||||
</dependencies>
|
||||
|
||||
</module>
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="org.hibernate.orm" slot="${slot}">
|
||||
<resources>
|
||||
<artifact name="${org.hibernate:hibernate-core}"/>
|
||||
</resources>
|
||||
|
||||
<dependencies>
|
||||
<module name="org.hibernate.envers" slot="${slot}" services="import" optional="true"/>
|
||||
<module name="com.fasterxml.classmate"/>
|
||||
<module name="javax.api"/>
|
||||
<module name="javax.annotation.api"/>
|
||||
<module name="javax.enterprise.api"/>
|
||||
<module name="javax.persistence.api"/>
|
||||
<module name="javax.transaction.api"/>
|
||||
<module name="javax.validation.api"/>
|
||||
<module name="javax.xml.bind.api"/>
|
||||
<module name="org.antlr"/>
|
||||
<module name="org.dom4j"/>
|
||||
<module name="org.jboss.as.jpa.spi"/>
|
||||
<module name="org.jboss.jandex"/>
|
||||
<module name="org.jboss.logging"/>
|
||||
<module name="org.jboss.vfs"/>
|
||||
<module name="org.javassist" export="true" optional="true"/>
|
||||
<module name="org.hibernate.commons-annotations"/>
|
||||
<module name="org.hibernate.orm.jipijapa-hibernate5" services="import" slot="${slot}"/>
|
||||
<module name="net.bytebuddy" slot="${bytebuddySlot}" />
|
||||
<module name="org.infinispan.hibernate-cache" services="import" optional="true" slot="${infinispan2lcSlot}"/>
|
||||
</dependencies>
|
||||
</module>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<module-alias xmlns="urn:jboss:module:1.3"
|
||||
name="org.hibernate.envers" slot="${minorSlot}"
|
||||
target-name="org.hibernate.envers" target-slot="${slot}"
|
||||
/>
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="org.hibernate.envers" slot="${slot}">
|
||||
<resources>
|
||||
<artifact name="${org.hibernate:hibernate-envers}"/>
|
||||
</resources>
|
||||
|
||||
<dependencies>
|
||||
<module name="org.hibernate.orm" slot="${slot}"/>
|
||||
<module name="com.fasterxml.classmate"/>
|
||||
<module name="javax.api"/>
|
||||
<module name="javax.annotation.api"/>
|
||||
<module name="javax.enterprise.api"/>
|
||||
<module name="javax.persistence.api"/>
|
||||
<module name="javax.transaction.api"/>
|
||||
<module name="javax.xml.bind.api"/>
|
||||
<module name="org.antlr"/>
|
||||
<module name="org.dom4j"/>
|
||||
<module name="org.jboss.jandex"/>
|
||||
<module name="org.jboss.logging"/>
|
||||
<module name="org.hibernate.commons-annotations"/>
|
||||
<module name="net.bytebuddy" slot="${bytebuddySlot}" />
|
||||
</dependencies>
|
||||
</module>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<module-alias xmlns="urn:jboss:module:1.3"
|
||||
name="org.hibernate.orm.jipijapa-hibernate5" slot="${minorSlot}"
|
||||
target-name="org.hibernate.orm.jipijapa-hibernate5" target-slot="${slot}"
|
||||
/>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="org.hibernate.orm.jipijapa-hibernate5" slot="${slot}">
|
||||
<properties>
|
||||
<property name="jboss.api" value="private"/>
|
||||
</properties>
|
||||
|
||||
<resources>
|
||||
<artifact name="${org.wildfly:jipijapa-hibernate5}"/>
|
||||
</resources>
|
||||
|
||||
<dependencies>
|
||||
<module name="org.hibernate.orm" slot="${slot}"/>
|
||||
<module name="javax.api"/>
|
||||
<module name="javax.annotation.api"/>
|
||||
<module name="javax.enterprise.api"/>
|
||||
<module name="javax.persistence.api"/>
|
||||
<module name="javax.transaction.api"/>
|
||||
<module name="javax.validation.api"/>
|
||||
<module name="javax.xml.bind.api"/>
|
||||
<module name="org.jboss.as.jpa.spi"/>
|
||||
<module name="org.jboss.jandex"/>
|
||||
<module name="org.jboss.logging"/>
|
||||
<module name="org.jboss.vfs"/>
|
||||
<module name="org.hibernate.commons-annotations"/>
|
||||
<module name="org.infinispan" services="import"/>
|
||||
<module name="org.infinispan.hibernate-cache" services="import" optional="true" slot="${infinispan2lcSlot}"/>
|
||||
</dependencies>
|
||||
</module>
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* 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.wildfly.integrationtest;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.envers.AuditReader;
|
||||
import org.hibernate.envers.AuditReaderFactory;
|
||||
import org.hibernate.wildfly.model.AuditedEntity;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
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.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Chris Cranford
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class HibernateEnversOnWildflyTest {
|
||||
|
||||
private static final String ORM_VERSION = Session.class.getPackage().getImplementationVersion();
|
||||
private static final String ORM_MINOR_VERSION = ORM_VERSION.substring( 0, ORM_VERSION.indexOf( ".", ORM_VERSION.indexOf( "." ) + 1 ) );
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create( WebArchive.class )
|
||||
.addClass( AuditedEntity.class )
|
||||
.addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), "META-INF/persistence.xml" );
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
return Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit()
|
||||
.name( "primary" )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties()
|
||||
// We want to use the ORM from this build instead of the one coming with WildFly
|
||||
.createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:" + ORM_MINOR_VERSION ).up()
|
||||
.createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up()
|
||||
.createProperty().name( "hibernate.allow_update_outside_transaction" ).value( "true" ).up()
|
||||
.up().up();
|
||||
}
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Inject
|
||||
private UserTransaction userTransaction;
|
||||
|
||||
@Test
|
||||
public void testEnversCompatibility() throws Exception {
|
||||
// revision 1
|
||||
userTransaction.begin();
|
||||
entityManager.joinTransaction();
|
||||
AuditedEntity entity = new AuditedEntity( 1, "Marco Polo" );
|
||||
entityManager.persist( entity );
|
||||
userTransaction.commit();
|
||||
|
||||
// revision 2
|
||||
userTransaction.begin();
|
||||
entityManager.joinTransaction();
|
||||
entity.setName( "George Washington" );
|
||||
entityManager.merge( entity );
|
||||
userTransaction.commit();
|
||||
|
||||
entityManager.clear();
|
||||
|
||||
// verify audit history revision counts
|
||||
userTransaction.begin();
|
||||
final AuditReader auditReader = AuditReaderFactory.get( entityManager );
|
||||
assertEquals( Arrays.asList( 1, 2 ), auditReader.getRevisions( AuditedEntity.class, 1 ) );
|
||||
userTransaction.commit();
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* 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.wildfly.integrationtest;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.wildfly.model.Kryptonite;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
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.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Integration test for using the current Hibernate ORM version on WildFly.
|
||||
* <p>
|
||||
* Gradle will unzip the targeted WildFly version and unpack the module ZIP created by this build into the server's
|
||||
* module directory. Arquillian is used to start this WildFly instance, run this test on the server and stop the server
|
||||
* again.
|
||||
*
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class HibernateModulesOnWildflyTest {
|
||||
|
||||
private static final String ORM_VERSION = Session.class.getPackage().getImplementationVersion();
|
||||
private static final String ORM_MINOR_VERSION = ORM_VERSION.substring( 0, ORM_VERSION.indexOf( ".", ORM_VERSION.indexOf( "." ) + 1) );
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create( WebArchive.class )
|
||||
.addClass( Kryptonite.class )
|
||||
.addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), "META-INF/persistence.xml" );
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
return Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit()
|
||||
.name( "primary" )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties()
|
||||
// We want to use the ORM from this build instead of the one coming with WildFly
|
||||
.createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:" + ORM_MINOR_VERSION ).up()
|
||||
.createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up()
|
||||
.createProperty().name( "hibernate.allow_update_outside_transaction" ).value( "true" ).up()
|
||||
.up().up();
|
||||
}
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Test
|
||||
public void shouldUseHibernateOrm52() {
|
||||
Session session = entityManager.unwrap( Session.class );
|
||||
|
||||
Kryptonite kryptonite1 = new Kryptonite();
|
||||
kryptonite1.id = 1L;
|
||||
kryptonite1.description = "Some Kryptonite";
|
||||
session.persist( kryptonite1 );
|
||||
|
||||
// EntityManager methods exposed through Session only as of 5.2
|
||||
Kryptonite loaded = session.find( Kryptonite.class, 1L );
|
||||
|
||||
assertThat( loaded.description, equalTo( "Some Kryptonite" ) );
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* 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.wildfly.integrationtest;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl;
|
||||
import org.hibernate.bytecode.spi.BasicProxyFactory;
|
||||
import org.hibernate.bytecode.spi.BytecodeProvider;
|
||||
import org.hibernate.bytecode.spi.ProxyFactoryFactory;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.wildfly.model.Kryptonite;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
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.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.hamcrest.core.IsNull.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* The purpose of this test is to check that it's still possible to use Javassist as byte code provider with WildFly.
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class JavassistHibernateModulesOnWildflyTest {
|
||||
|
||||
private static final String ORM_VERSION = Session.class.getPackage().getImplementationVersion();
|
||||
private static final String ORM_MINOR_VERSION = ORM_VERSION.substring( 0, ORM_VERSION.indexOf( ".", ORM_VERSION.indexOf( "." ) + 1) );
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create( WebArchive.class )
|
||||
.addClass( Kryptonite.class )
|
||||
.addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsResource( persistenceXml(), "META-INF/persistence.xml" );
|
||||
}
|
||||
|
||||
private static Asset persistenceXml() {
|
||||
PersistenceDescriptor persistenceXml = Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit()
|
||||
.name( "primary" )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties()
|
||||
// We want to use the ORM from this build instead of the one coming with WildFly
|
||||
.createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:" + ORM_MINOR_VERSION ).up()
|
||||
.createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up()
|
||||
.createProperty().name( "hibernate.allow_update_outside_transaction" ).value( "true" ).up()
|
||||
.up().up();
|
||||
return new StringAsset( persistenceXml.exportAsString() );
|
||||
}
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Test
|
||||
public void shouldUseHibernateOrm52() {
|
||||
Session session = entityManager.unwrap( Session.class );
|
||||
|
||||
Kryptonite kryptonite1 = new Kryptonite();
|
||||
kryptonite1.id = 1L;
|
||||
kryptonite1.description = "Some Kryptonite";
|
||||
session.persist( kryptonite1 );
|
||||
|
||||
// EntityManager methods exposed through Session only as of 5.2
|
||||
Kryptonite loaded = session.find( Kryptonite.class, 1L );
|
||||
|
||||
assertThat( loaded.description, equalTo( "Some Kryptonite" ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToCreateProxyWithJavassist() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty( AvailableSettings.BYTECODE_PROVIDER, Environment.BYTECODE_PROVIDER_NAME_JAVASSIST );
|
||||
|
||||
// hibernate.bytecode.provider is a system property. I don't want to apply it
|
||||
// to the arquillian.xml because it will change the other tests as well.
|
||||
// I guess this is a more explicit way anyway to test that Javassist is available.
|
||||
BytecodeProvider provider = Environment.buildBytecodeProvider( properties );
|
||||
assertThat( provider.getClass(), equalTo( BytecodeProviderImpl.class ) );
|
||||
|
||||
ProxyFactoryFactory factory = provider.getProxyFactoryFactory();
|
||||
BasicProxyFactory basicProxyFactory = factory.buildBasicProxyFactory( Kryptonite.class, null );
|
||||
Object proxy = basicProxyFactory.getProxy();
|
||||
assertThat( proxy, notNullValue() );
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* 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.wildfly.integrationtest;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityTransaction;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||
import org.hibernate.wildfly.model.Kryptonite;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
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.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class TransactionRollbackTest {
|
||||
|
||||
private static final String ORM_VERSION = Session.class.getPackage().getImplementationVersion();
|
||||
private static final String ORM_MINOR_VERSION = ORM_VERSION.substring( 0,
|
||||
ORM_VERSION.indexOf(
|
||||
".",
|
||||
ORM_VERSION.indexOf( "." ) + 1
|
||||
)
|
||||
);
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create( WebArchive.class )
|
||||
.addClass( Kryptonite.class )
|
||||
.addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), "META-INF/persistence.xml" );
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
return Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit()
|
||||
.name( "primary" )
|
||||
.transactionType( PersistenceUnitTransactionType._RESOURCE_LOCAL )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties()
|
||||
// We want to use the ORM from this build instead of the one coming with WildFly
|
||||
.createProperty()
|
||||
.name( "jboss.as.jpa.providerModule" )
|
||||
.value( "org.hibernate:" + ORM_MINOR_VERSION )
|
||||
.up()
|
||||
.createProperty()
|
||||
.name( "hibernate.hbm2ddl.auto" )
|
||||
.value( "create-drop" )
|
||||
.up()
|
||||
.createProperty()
|
||||
.name( "hibernate.allow_update_outside_transaction" )
|
||||
.value( "true" )
|
||||
.up()
|
||||
.up()
|
||||
.up();
|
||||
}
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Test
|
||||
public void testMarkRollbackOnlyAnUnactiveTransaction() {
|
||||
EntityTransaction transaction = entityManager.getTransaction();
|
||||
final TransactionImplementor hibernateTransaction = (TransactionImplementor) transaction;
|
||||
hibernateTransaction.markRollbackOnly();
|
||||
transaction.rollback();
|
||||
assertFalse( transaction.isActive() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkRollbackOnlyAnActiveTransaction() {
|
||||
EntityTransaction transaction = entityManager.getTransaction();
|
||||
final TransactionImplementor hibernateTransaction = (TransactionImplementor) transaction;
|
||||
transaction.begin();
|
||||
hibernateTransaction.markRollbackOnly();
|
||||
transaction.rollback();
|
||||
assertFalse( transaction.isActive() );
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* 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.wildfly.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
/**
|
||||
* @author Chris Cranford
|
||||
*/
|
||||
@Audited
|
||||
@Entity
|
||||
public class AuditedEntity {
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
AuditedEntity() {
|
||||
|
||||
}
|
||||
|
||||
public AuditedEntity(Integer id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if ( this == object ) {
|
||||
return true;
|
||||
}
|
||||
if ( object == null || !( object instanceof AuditedEntity ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AuditedEntity that = (AuditedEntity) object;
|
||||
return !( name != null ? !name.equals( that.name ) : that.name != null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ( name != null ? name.hashCode() : 0 );
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* 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.wildfly.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
@Entity
|
||||
public class Kryptonite {
|
||||
|
||||
@Id
|
||||
public long id;
|
||||
|
||||
public String description;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ 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>.
|
||||
-->
|
||||
<arquillian
|
||||
xmlns="http://jboss.org/schema/arquillian"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
|
||||
|
||||
<defaultProtocol type="Servlet 3.0" />
|
||||
|
||||
<!-- Uncomment in order to inspect deployments -->
|
||||
<!--
|
||||
<engine>
|
||||
<property name="deploymentExportPath">${arquillianDeploymentExportDir}</property>
|
||||
</engine>
|
||||
-->
|
||||
|
||||
<group qualifier="Grid" default="true">
|
||||
<container qualifier="container.active-1" mode="suite" default="true">
|
||||
<configuration>
|
||||
<property name="jbossHome">${wildFlyInstallDir}</property>
|
||||
<!-- For Remote debugging of Wildfly add the following line to the 'javaVmArguments' section below: -->
|
||||
<!-- -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y-->
|
||||
<!-- DO NOT add comments within the property section below as the Arquillian parser can't deal with it -->
|
||||
<property name="javaVmArguments">
|
||||
-Dee8.preview.mode=true
|
||||
-Djava.net.preferIPv4Stack=true
|
||||
-Djgroups.bind_addr=127.0.0.1
|
||||
</property>
|
||||
</configuration>
|
||||
</container>
|
||||
</group>
|
||||
</arquillian>
|
|
@ -1,15 +0,0 @@
|
|||
<!-- Use of copy-module-artifacts is essential to make sure we use the current
|
||||
builds rather than whatever stale snapshot one might have in local Maven
|
||||
repositories: JBoss Modules would otherwise load jars from the local Maven -->
|
||||
<server-provisioning xmlns="urn:wildfly:server-provisioning:1.1" copy-module-artifacts="true">
|
||||
<feature-packs>
|
||||
<feature-pack
|
||||
groupId="org.hibernate"
|
||||
artifactId="hibernate-orm-jbossmodules"
|
||||
version="${hibernate-orm.version}" />
|
||||
<feature-pack
|
||||
groupId="org.wildfly"
|
||||
artifactId="wildfly-feature-pack"
|
||||
version="${wildfly.version}" />
|
||||
</feature-packs>
|
||||
</server-provisioning>
|
|
@ -63,7 +63,6 @@ include 'hibernate-ehcache'
|
|||
include 'hibernate-infinispan'
|
||||
include 'hibernate-jipijapa'
|
||||
|
||||
include 'hibernate-orm-modules'
|
||||
include 'hibernate-graalvm'
|
||||
|
||||
if ( JavaVersion.current().isJava11Compatible() ) {
|
||||
|
|
Loading…
Reference in New Issue