Skip to content

Commit ed7b56f

Browse files
committed
Share tests across modules
1 parent 18165d7 commit ed7b56f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+33
-9
lines changed

buildSrc/src/main/groovy/shared-testing.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
// Sets up shared testing
3+
// to execute tests from hibernate-models in the context of other modules.
4+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
16
plugins {
27
id "testing"
38
}
@@ -24,7 +29,7 @@ configurations {
2429
}
2530

2631
dependencies {
27-
testImplementation project( path: ":hibernate-models", configuration: "exposedTestClasses" )
32+
testImplementation project( ":hibernate-models-testing" )
2833

2934
sharedTestClasses project(path: ':hibernate-models', configuration: 'exposedTestClasses')
3035
sharedTestResources project(path: ':hibernate-models', configuration: 'exposedTestResources')

buildSrc/src/main/groovy/testing.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
// Module that need testing
3+
// - automatically applied by published-java-module
4+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
16
plugins {
27
id "java-module"
38
id "jacoco"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.hibernate.models.spi.ClassLoading;
1414
import org.hibernate.models.spi.RegistryPrimer;
1515
import org.hibernate.models.spi.SourceModelBuildingContext;
16-
import org.hibernate.models.testing.intg.TestingModelContextFactory;
16+
import org.hibernate.models.testing.intg.ModelContextFactory;
1717
import org.hibernate.models.testing.orm.JpaAnnotations;
1818

1919
import org.jboss.jandex.Index;
@@ -24,7 +24,7 @@
2424
/**
2525
* @author Steve Ebersole
2626
*/
27-
public class JandexTestingModelContextFactoryImpl implements TestingModelContextFactory {
27+
public class JandexModelContextFactoryImpl implements ModelContextFactory {
2828
@Override
2929
public SourceModelBuildingContext createModelContext(
3030
RegistryPrimer registryPrimer,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.hibernate.models.testing.shared.intg.JandexModelContextFactoryImpl

hibernate-models-jandex/src/test/resources/META-INF/services/org.hibernate.models.testing.intg.TestingModelContextFactory

Lines changed: 0 additions & 1 deletion
This file was deleted.

hibernate-models-testing/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins {
2+
id 'java-module'
3+
}
4+
5+
description = "Test fixtures for modules performing tests"
6+
7+
dependencies {
8+
implementation project( ":hibernate-models" )
9+
implementation jakartaLibs.jpa
10+
}

hibernate-models/src/test/java/org/hibernate/models/testing/intg/TestingModelContextFactory.java renamed to hibernate-models-testing/src/main/java/org/hibernate/models/testing/intg/ModelContextFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
*
1414
* @author Steve Ebersole
1515
*/
16-
public interface TestingModelContextFactory {
16+
public interface ModelContextFactory {
1717
SourceModelBuildingContext createModelContext(RegistryPrimer registryPrimer, Class<?>... modelClasses);
1818
}

hibernate-models/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ plugins {
44

55
description = "A de-typed abstraction over reflection and annotations"
66

7+
dependencies {
8+
testImplementation project( ":hibernate-models-testing" )
9+
}
710

811
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
912
// Export testing

hibernate-models/src/test/java/org/hibernate/models/testing/TestHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.hibernate.models.internal.util.CollectionHelper;
1212
import org.hibernate.models.spi.RegistryPrimer;
1313
import org.hibernate.models.spi.SourceModelBuildingContext;
14-
import org.hibernate.models.testing.intg.TestingModelContextFactory;
14+
import org.hibernate.models.testing.intg.ModelContextFactory;
1515
import org.hibernate.models.testing.orm.OrmAnnotationHelper;
1616

1717
import static org.hibernate.models.internal.SimpleClassLoading.SIMPLE_CLASS_LOADING;
@@ -45,10 +45,10 @@ public static SourceModelBuildingContext createModelContext(
4545
private static SourceModelBuildingContext buildModelContext(
4646
RegistryPrimer additionalPrimer,
4747
Class<?>... modelClasses) {
48-
final ServiceLoader<TestingModelContextFactory> loader = ServiceLoader.load( TestingModelContextFactory.class );
49-
final Iterator<TestingModelContextFactory> serviceImpls = loader.iterator();
48+
final ServiceLoader<ModelContextFactory> loader = ServiceLoader.load( ModelContextFactory.class );
49+
final Iterator<ModelContextFactory> serviceImpls = loader.iterator();
5050
if ( serviceImpls.hasNext() ) {
51-
final TestingModelContextFactory contextFactory = serviceImpls.next();
51+
final ModelContextFactory contextFactory = serviceImpls.next();
5252
if ( serviceImpls.hasNext() ) {
5353
throw new IllegalStateException( "Found more than one TestingModelContextFactory" );
5454
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,5 @@ dependencyResolutionManagement {
129129

130130
include "hibernate-models"
131131
include "hibernate-models-jandex"
132+
include 'hibernate-models-testing'
132133

0 commit comments

Comments
 (0)