Remove separate java 17 test source folder
This commit is contained in:
parent
2890b178aa
commit
abf0e945b0
|
@ -251,61 +251,6 @@ tasks.withType( Test.class ).each { test ->
|
|||
}
|
||||
}
|
||||
|
||||
// Tests with records
|
||||
if ( jdkVersions.test.release.asInt() >= 17 && jdkVersions.explicit ) {
|
||||
|
||||
// Add a new source set, which contains tests that can run on JDK17+
|
||||
sourceSets {
|
||||
testJava17 {
|
||||
java {
|
||||
srcDirs = ['src/test/java17']
|
||||
}
|
||||
// Refer to the main test resources to avoid processing variables twice
|
||||
resources {
|
||||
srcDirs tasks.processTestResources
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For the new source set, we need to configure the source and target version to 17
|
||||
compileTestJava17Java {
|
||||
javaCompiler = javaToolchains.compilerFor {
|
||||
languageVersion = jdkVersions.test.compiler
|
||||
}
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
// We also depend on the main test resources
|
||||
dependsOn( tasks.processTestResources )
|
||||
}
|
||||
|
||||
// The source set gets a custom configuration which extends the normal test implementation config
|
||||
configurations {
|
||||
testJava17Implementation.extendsFrom(testImplementation, testRuntimeOnly)
|
||||
testJava17CompileOnly.extendsFrom(testCompileOnly)
|
||||
}
|
||||
|
||||
// Add the output from src/main/java as dependency
|
||||
dependencies {
|
||||
testJava17Implementation files(sourceSets.main.output.classesDirs) {
|
||||
builtBy compileJava
|
||||
}
|
||||
}
|
||||
|
||||
// We execute the Java 17 tests in a custom test task
|
||||
task testJava17(type: Test) {
|
||||
javaLauncher = javaToolchains.launcherFor {
|
||||
languageVersion = jdkVersions.test.launcher
|
||||
}
|
||||
useJUnitPlatform()
|
||||
testClassesDirs = sourceSets.testJava17.output.classesDirs
|
||||
classpath = sourceSets.testJava17.runtimeClasspath
|
||||
}
|
||||
|
||||
testClasses.dependsOn compileTestJava17Java
|
||||
// And run this as part of the check task by default
|
||||
check.dependsOn testJava17
|
||||
}
|
||||
|
||||
tasks.named( "javadoc", Javadoc ) {
|
||||
configure(options) {
|
||||
overview = rootProject.file( "shared/javadoc/overview.html" )
|
||||
|
|
|
@ -10,9 +10,11 @@ package org.hibernate.orm.test.records;
|
|||
import org.hibernate.engine.spi.ManagedComposite;
|
||||
import org.hibernate.engine.spi.ManagedEntity;
|
||||
|
||||
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
|
||||
import org.hibernate.testing.bytecode.enhancement.EnhancementOptions;
|
||||
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
|
@ -1,102 +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.orm.test.records;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.IdClass;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MapsId;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.PrimaryKeyJoinColumn;
|
||||
|
||||
import static jakarta.persistence.CascadeType.MERGE;
|
||||
import static jakarta.persistence.CascadeType.PERSIST;
|
||||
import static jakarta.persistence.CascadeType.REMOVE;
|
||||
|
||||
/**
|
||||
* @author Marco Belladelli
|
||||
*/
|
||||
@DomainModel( annotatedClasses = {
|
||||
RecordIdClassAndMapsIdTest.UserAuthorityEntity.class,
|
||||
RecordIdClassAndMapsIdTest.UserAuthorityId.class,
|
||||
RecordIdClassAndMapsIdTest.UserEntity.class,
|
||||
} )
|
||||
@SessionFactory
|
||||
@Jira( "https://hibernate.atlassian.net/browse/HHH-18062" )
|
||||
public class RecordIdClassAndMapsIdTest {
|
||||
@Test
|
||||
public void testMapping(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
final UserEntity ue = new UserEntity();
|
||||
ue.setName( "user_1" );
|
||||
final UserAuthorityEntity uae = new UserAuthorityEntity();
|
||||
ue.addUserAuthority( uae );
|
||||
uae.setUser( ue );
|
||||
uae.setAuthority( "auth_1" );
|
||||
session.persist( ue );
|
||||
} );
|
||||
}
|
||||
|
||||
@Entity( name = "UserAuthorityEntity" )
|
||||
@IdClass( UserAuthorityId.class )
|
||||
static class UserAuthorityEntity {
|
||||
@Id
|
||||
private Long userId;
|
||||
|
||||
@Id
|
||||
private String authority;
|
||||
|
||||
@ManyToOne
|
||||
@MapsId( "userId" )
|
||||
@PrimaryKeyJoinColumn( name = "user_id" )
|
||||
private UserEntity user;
|
||||
|
||||
public void setUser(UserEntity user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public void setAuthority(String authority) {
|
||||
this.authority = authority;
|
||||
}
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
record UserAuthorityId(Long userId, String authority) {
|
||||
}
|
||||
|
||||
@Entity( name = "UserEntity" )
|
||||
static class UserEntity {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
@OneToMany( cascade = { PERSIST, MERGE, REMOVE }, mappedBy = "user", orphanRemoval = true )
|
||||
private Set<UserAuthorityEntity> userAuthorities = new HashSet<>();
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void addUserAuthority(UserAuthorityEntity userAuthority) {
|
||||
this.userAuthorities.add( userAuthority );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,94 +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.orm.test.records;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.IdClass;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MapsId;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static jakarta.persistence.CascadeType.MERGE;
|
||||
import static jakarta.persistence.CascadeType.PERSIST;
|
||||
import static jakarta.persistence.CascadeType.REMOVE;
|
||||
|
||||
@DomainModel( annotatedClasses = {
|
||||
RecordIdClassTest2.MyParentEntity.class,
|
||||
RecordIdClassTest2.MyChildEntity.class} )
|
||||
@SessionFactory
|
||||
public class RecordIdClassTest2 {
|
||||
|
||||
@Test
|
||||
public void testPersist(SessionFactoryScope scope) {
|
||||
scope.inTransaction( s-> {
|
||||
MyParentEntity ue = new MyParentEntity("hello");
|
||||
MyChildEntity uae = new MyChildEntity(ue, "world");
|
||||
ue.children.add(uae);
|
||||
s.persist(ue);
|
||||
});
|
||||
}
|
||||
|
||||
public record MyRecord(Long code, String qualifier) {}
|
||||
|
||||
@Entity
|
||||
@IdClass(MyRecord.class)
|
||||
public static class MyChildEntity {
|
||||
|
||||
@Id
|
||||
Long code;
|
||||
|
||||
@Id
|
||||
String qualifier;
|
||||
|
||||
String text;
|
||||
|
||||
@ManyToOne
|
||||
@MapsId("code")
|
||||
private MyParentEntity parent;
|
||||
|
||||
public MyChildEntity(MyParentEntity parent, String qualifier) {
|
||||
this.parent = parent;
|
||||
this.qualifier = qualifier;
|
||||
}
|
||||
|
||||
MyChildEntity() {
|
||||
}
|
||||
}
|
||||
|
||||
@Entity
|
||||
public static class MyParentEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
Long code;
|
||||
|
||||
String description;
|
||||
|
||||
@OneToMany(
|
||||
cascade = {PERSIST, MERGE, REMOVE},
|
||||
mappedBy = "parent",
|
||||
orphanRemoval = true)
|
||||
private Set<MyChildEntity> children = new HashSet<>();
|
||||
|
||||
public MyParentEntity(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
MyParentEntity() {
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue