Skip to content

Commit 3ab1246

Browse files
committed
HHH-19846 - Drop JUnit 4 usage
Not converted... * org.hibernate.orm.test.hql.PostgreSQLFunctionSelectClauseTest - registering custom function * org.hibernate.orm.test.hql.PostgreSQLFunctionWhereClauseTest - aux-db-object * org.hibernate.orm.test.id.usertype - type registrations * org.hibernate.orm.test.idgen.enhanced.HiloOptimizerConcurrencyTest - recreation of SF during tests * org.hibernate.orm.test.type.AbstractJavaTimeTypeTest subtypes - crazy parameterization
1 parent 7f75d1c commit 3ab1246

File tree

65 files changed

+775
-825
lines changed

Some content is hidden

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

65 files changed

+775
-825
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/java/AbstractDescriptorTest.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,38 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.mapping.type.java;
6-
import java.io.Serializable;
7-
import java.sql.Blob;
8-
import java.sql.Clob;
9-
import java.util.TimeZone;
106

117
import org.hibernate.dialect.Dialect;
128
import org.hibernate.dialect.H2Dialect;
139
import org.hibernate.engine.jdbc.LobCreator;
1410
import org.hibernate.engine.jdbc.env.internal.NonContextualLobCreator;
1511
import org.hibernate.engine.spi.SharedSessionContractImplementor;
12+
import org.hibernate.testing.orm.junit.BaseUnitTest;
13+
import org.hibernate.testing.orm.junit.JiraKey;
1614
import org.hibernate.type.descriptor.WrapperOptions;
1715
import org.hibernate.type.descriptor.java.JavaType;
1816
import org.hibernate.type.descriptor.jdbc.JdbcType;
19-
2017
import org.hibernate.type.format.FormatMapper;
2118
import org.hibernate.type.spi.TypeConfiguration;
22-
import org.junit.Before;
23-
import org.junit.Test;
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
2421

25-
import org.hibernate.testing.junit4.BaseUnitTestCase;
26-
import org.hibernate.testing.orm.junit.JiraKey;
22+
import java.io.Serializable;
23+
import java.sql.Blob;
24+
import java.sql.Clob;
25+
import java.util.TimeZone;
2726

28-
import static org.junit.Assert.assertFalse;
29-
import static org.junit.Assert.assertTrue;
27+
import static org.junit.jupiter.api.Assertions.assertEquals;
28+
import static org.junit.jupiter.api.Assertions.assertFalse;
29+
import static org.junit.jupiter.api.Assertions.assertNotSame;
30+
import static org.junit.jupiter.api.Assertions.assertSame;
31+
import static org.junit.jupiter.api.Assertions.assertTrue;
3032

3133
/**
3234
* @author Steve Ebersole
3335
*/
34-
public abstract class AbstractDescriptorTest<T> extends BaseUnitTestCase {
36+
@BaseUnitTest
37+
public abstract class AbstractDescriptorTest<T> {
3538
protected static class Data<T> {
3639
private final T originalValue;
3740
private final T copyOfOriginalValue;
@@ -108,7 +111,7 @@ public AbstractDescriptorTest(JavaType<T> typeDescriptor) {
108111

109112
private Data<T> testData;
110113

111-
@Before
114+
@BeforeEach
112115
public void setUp() throws Exception {
113116
testData = getTestData();
114117
}
@@ -128,7 +131,7 @@ protected boolean isIdentityDifferentFromEquality() {
128131
@Test
129132
public void testEquality() {
130133
if ( isIdentityDifferentFromEquality() ) {
131-
assertFalse( testData.originalValue == testData.copyOfOriginalValue );
134+
assertNotSame( testData.originalValue, testData.copyOfOriginalValue );
132135
}
133136
assertTrue( typeDescriptor.areEqual( testData.originalValue, testData.originalValue ) );
134137
assertTrue( typeDescriptor.areEqual( testData.originalValue, testData.copyOfOriginalValue ) );
@@ -162,7 +165,7 @@ public void testPassThrough() {
162165

163166
@Test
164167
public void testMutabilityPlan() {
165-
assertTrue( shouldBeMutable() == typeDescriptor.getMutabilityPlan().isMutable() );
168+
assertEquals( shouldBeMutable(), typeDescriptor.getMutabilityPlan().isMutable() );
166169

167170
if ( testData.copyOfOriginalValue instanceof Clob
168171
|| testData.copyOfOriginalValue instanceof Blob ) {
@@ -172,15 +175,15 @@ public void testMutabilityPlan() {
172175
T copy = typeDescriptor.getMutabilityPlan().deepCopy( testData.copyOfOriginalValue );
173176
assertTrue( typeDescriptor.areEqual( copy, testData.copyOfOriginalValue ) );
174177
if ( ! shouldBeMutable() ) {
175-
assertTrue( copy == testData.copyOfOriginalValue );
178+
assertSame( copy, testData.copyOfOriginalValue );
176179
}
177180

178181
// ensure the symmetry of assemble/disassebly
179182
// NOTE: these should not use Session, so we just pass null
180183

181184
Serializable cached = typeDescriptor.getMutabilityPlan().disassemble( testData.copyOfOriginalValue, null );
182185
if ( ! shouldBeMutable() ) {
183-
assertTrue( cached == testData.copyOfOriginalValue );
186+
assertSame( cached, testData.copyOfOriginalValue );
184187
}
185188
T reassembled = typeDescriptor.getMutabilityPlan().assemble( cached, null );
186189
assertTrue( typeDescriptor.areEqual( testData.originalValue, reassembled ) );

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/java/BasicCollectionJavaTypeDescriptorTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
import org.hibernate.testing.orm.junit.JiraKey;
1212
import org.hibernate.type.descriptor.java.StringJavaType;
1313
import org.hibernate.type.descriptor.java.spi.BasicCollectionJavaType;
14-
import org.junit.Test;
14+
import org.junit.jupiter.api.Test;
1515

1616
import java.lang.reflect.ParameterizedType;
1717
import java.util.LinkedHashSet;
1818
import java.util.Set;
1919

20-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2121

2222
/**
2323
* @author Yanming Zhou
@@ -29,14 +29,15 @@ public class BasicCollectionJavaTypeDescriptorTest {
2929
@Test
3030
@JiraKey( "HHH-18073" )
3131
public void wrapShouldRetainOrderOfSet() {
32-
assertTrue("BasicCollectionJavaType.wrap() should retain order of Set",
33-
stringSetJavaType.wrap(Set.of( "foo", "bar" ), null) instanceof LinkedHashSet);
32+
assertInstanceOf( LinkedHashSet.class, stringSetJavaType.wrap( Set.of( "foo", "bar" ), null ),
33+
"BasicCollectionJavaType.wrap() should retain order of Set" );
3434
}
3535

3636
@Test
3737
public void deepCopyShouldRetainOrderOfSet() {
38-
assertTrue("BasicCollectionJavaType.getMutabilityPlan().deepCopy() should retain order of Set",
39-
stringSetJavaType.getMutabilityPlan().deepCopy(Set.of( "foo", "bar" )) instanceof LinkedHashSet);
38+
assertInstanceOf( LinkedHashSet.class,
39+
stringSetJavaType.getMutabilityPlan().deepCopy( Set.of( "foo", "bar" ) ),
40+
"BasicCollectionJavaType.getMutabilityPlan().deepCopy() should retain order of Set" );
4041
}
4142

4243
@SuppressWarnings("unchecked")

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/java/BigDecimalDescriptorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public BigDecimalDescriptorTest() {
2121

2222
@Override
2323
protected Data<BigDecimal> getTestData() {
24-
return new Data<BigDecimal>( original, copy, different );
24+
return new Data<>( original, copy, different );
2525
}
2626

2727
@Override

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/java/BigIntegerDescriptorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public BigIntegerDescriptorTest() {
2121

2222
@Override
2323
protected Data<BigInteger> getTestData() {
24-
return new Data<BigInteger>( original, copy, different );
24+
return new Data<>( original, copy, different );
2525
}
2626

2727
@Override

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/java/BlobDescriptorTest.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
*/
55
package org.hibernate.orm.test.mapping.type.java;
66

7-
import static org.assertj.core.api.Assertions.assertThatCode;
8-
import static org.junit.Assert.assertEquals;
9-
import static org.junit.Assert.assertFalse;
10-
import static org.junit.Assert.assertTrue;
11-
import static org.junit.Assert.fail;
12-
13-
import java.io.IOException;
14-
import java.sql.Blob;
15-
import java.sql.SQLException;
16-
177
import org.hibernate.engine.jdbc.BlobImplementer;
188
import org.hibernate.engine.jdbc.proxy.BlobProxy;
199
import org.hibernate.testing.orm.junit.JiraKey;
2010
import org.hibernate.type.descriptor.java.BlobJavaType;
2111
import org.hibernate.type.descriptor.java.DataHelper;
2212
import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaType;
23-
import org.junit.Test;
13+
import org.junit.jupiter.api.Test;
14+
15+
import java.io.IOException;
16+
import java.sql.Blob;
17+
import java.sql.SQLException;
18+
19+
import static org.assertj.core.api.Assertions.assertThatCode;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertNotSame;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
import static org.junit.jupiter.api.Assertions.fail;
2425

2526

2627
/**
@@ -37,7 +38,7 @@ public BlobDescriptorTest() {
3738

3839
@Override
3940
protected Data<Blob> getTestData() {
40-
return new Data<Blob>( original, copy, different );
41+
return new Data<>( original, copy, different );
4142
}
4243

4344
@Override
@@ -49,12 +50,13 @@ protected boolean shouldBeMutable() {
4950
@Override
5051
public void testEquality() {
5152
// blobs of the same internal value are not really comparable
52-
assertFalse( original == copy );
53+
assertNotSame( original, copy );
5354
assertTrue( BlobJavaType.INSTANCE.areEqual( original, original ) );
5455
assertFalse( BlobJavaType.INSTANCE.areEqual( original, copy ) );
5556
assertFalse( BlobJavaType.INSTANCE.areEqual( original, different ) );
5657
}
5758

59+
@Test
5860
@Override
5961
public void testPassThrough() {
6062
// blobs of the same internal value are not really comparable

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/java/BooleanDescriptorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public BooleanDescriptorTest() {
2121

2222
@Override
2323
protected Data<Boolean> getTestData() {
24-
return new Data<Boolean>( original, copy, different );
24+
return new Data<>( original, copy, different );
2525
}
2626

2727
@Override

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/java/BooleanJavaTypeDescriptorTest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717
import org.hibernate.type.descriptor.java.StringJavaType;
1818
import org.hibernate.type.descriptor.jdbc.IntegerJdbcType;
1919
import org.hibernate.type.descriptor.jdbc.VarcharJdbcType;
20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
21+
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
23+
import static org.junit.jupiter.api.Assertions.assertFalse;
24+
import static org.junit.jupiter.api.Assertions.assertNull;
25+
import static org.junit.jupiter.api.Assertions.assertTrue;
2126

22-
import static org.junit.Assert.*;
2327

2428
public class BooleanJavaTypeDescriptorTest {
25-
private BooleanJavaType underTest = new BooleanJavaType();
29+
private final BooleanJavaType underTest = new BooleanJavaType();
2630

2731
@Test
2832
@JiraKey( "HHH-17275" )
@@ -31,7 +35,7 @@ public void testCheckConditionShouldReturnCorrectStatementWhenNullXStringGiven()
3135
// when
3236
String checkCondition = underTest.getCheckCondition("is_active", VarcharJdbcType.INSTANCE, new BooleanXConverter(), new AnyDialect());
3337
// then
34-
assertEquals("is_active in ('X') or is_active is null", checkCondition);
38+
assertEquals( "is_active in ('X') or is_active is null", checkCondition );
3539
}
3640

3741
@Test
@@ -40,7 +44,7 @@ public void testCheckConditionShouldReturnCorrectStatementWhenTFStringGiven() {
4044
// when
4145
String checkCondition = underTest.getCheckCondition("is_active", VarcharJdbcType.INSTANCE, new TrueFalseConverter(), new AnyDialect());
4246
// then
43-
assertEquals("is_active in ('F','T')", checkCondition);
47+
assertEquals( "is_active in ('F','T')", checkCondition );
4448
}
4549

4650
@Test
@@ -49,7 +53,7 @@ public void testCheckConditionShouldReturnCorrectStatementWhen1AndNullIntegerGiv
4953
// when
5054
String checkCondition = underTest.getCheckCondition("is_active", IntegerJdbcType.INSTANCE, new OneNullBooleanConverter(), new AnyDialect());
5155
// then
52-
assertEquals("is_active in (1) or is_active is null", checkCondition);
56+
assertEquals( "is_active in (1) or is_active is null", checkCondition );
5357
}
5458

5559
@Test

0 commit comments

Comments
 (0)