Skip to content

Commit b050edd

Browse files
committed
HHH-19916 - Drop JUnit 4 usage
Not converted... * org.hibernate.orm.test.idgen.enhanced.HiloOptimizerConcurrencyTest - recreation of SF during tests * org.hibernate.orm.test.type.AbstractJavaTimeTypeTest subtypes - crazy parameterization (see org.hibernate.orm.test.tm.InterceptorTransactionTest) * org.hibernate.orm.test.cdi.general.hibernatesearch.extended.HibernateSearchExtendedCdiSupportTest - not sure yet, all the other tests here pass with conversion - shelved for now
1 parent ecf402a commit b050edd

File tree

6 files changed

+246
-324
lines changed

6 files changed

+246
-324
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
db=h2
1+
db=pgsql_ci
22

33
# Keep all these properties in sync unless you know what you are doing!
44
# We set '-Dlog4j2.disableJmx=true' to prevent classloader leaks triggered by the logger.

hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/PostgreSQLMultipleTypesOtherContributorTest.java

Lines changed: 0 additions & 159 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.orm.test.id.usertype.inet;
6+
7+
import org.hibernate.boot.model.TypeContributions;
8+
import org.hibernate.boot.model.TypeContributor;
9+
import org.hibernate.query.NativeQuery;
10+
import org.hibernate.service.ServiceRegistry;
11+
import org.hibernate.testing.orm.junit.BootstrapServiceRegistry;
12+
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
13+
import org.hibernate.testing.orm.junit.DomainModel;
14+
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
15+
import org.hibernate.testing.orm.junit.SessionFactory;
16+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
17+
import org.junit.jupiter.api.AfterEach;
18+
import org.junit.jupiter.api.Assertions;
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
21+
22+
import java.util.List;
23+
24+
/**
25+
* @author Vlad Mihalcea
26+
*/
27+
@SuppressWarnings("JUnitMalformedDeclaration")
28+
@RequiresDialectFeature(feature = DialectFeatureChecks.IsPgJdbc.class)
29+
@BootstrapServiceRegistry( javaServices = @BootstrapServiceRegistry.JavaService(
30+
role = TypeContributor.class,
31+
impl = PostgreSQLInetTypeTests.TypeContributorImpl.class
32+
) )
33+
@DomainModel(annotatedClasses = Event.class)
34+
@SessionFactory
35+
public class PostgreSQLInetTypeTests {
36+
@BeforeEach
37+
void setUp(SessionFactoryScope factoryScope) {
38+
factoryScope.inTransaction( (session) -> {
39+
var event = new Event();
40+
event.setId( 1L );
41+
event.setIp( "192.168.0.123/24" );
42+
43+
session.persist( event );
44+
} );
45+
}
46+
47+
@AfterEach
48+
void tearDown(SessionFactoryScope factoryScope) {
49+
factoryScope.dropData();
50+
}
51+
52+
@Test
53+
public void testJPQL(SessionFactoryScope factoryScope) {
54+
factoryScope.inTransaction( entityManager -> {
55+
var inets = entityManager.createQuery(
56+
"select e.ip " +
57+
"from Event e " +
58+
"where e.id = :id", Inet.class )
59+
.setParameter( "id", 1L )
60+
.getResultList();
61+
62+
Assertions.assertEquals( 1, inets.size() );
63+
Assertions.assertEquals( "192.168.0.123/24", inets.get( 0 ).getAddress() );
64+
} );
65+
}
66+
67+
@Test
68+
public void testNativeSQLAddScalar(SessionFactoryScope factoryScope) {
69+
factoryScope.inTransaction( entityManager -> {
70+
List<Inet> inets = entityManager.createNativeQuery(
71+
"select e.ip as ip " +
72+
"from Event e " +
73+
"where e.id = :id" )
74+
.setParameter( "id", 1L )
75+
.unwrap( NativeQuery.class )
76+
.addScalar( "ip", InetType.INSTANCE )
77+
.getResultList();
78+
79+
Assertions.assertEquals( 1, inets.size() );
80+
Assertions.assertEquals( "192.168.0.123/24", inets.get( 0 ).getAddress() );
81+
} );
82+
}
83+
84+
85+
public static class TypeContributorImpl implements TypeContributor {
86+
@Override
87+
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
88+
typeContributions.contributeJavaType( InetJavaType.INSTANCE );
89+
typeContributions.contributeJdbcType( InetJdbcType.INSTANCE );
90+
91+
var typeConfiguration = typeContributions.getTypeConfiguration();
92+
typeConfiguration.getBasicTypeRegistry().register( InetType.INSTANCE );
93+
}
94+
}
95+
}

hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/inet/PostgreSQLInetTypesOtherContributorTest.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)