Skip to content

Conversation

sebersole
Copy link
Member

@sebersole sebersole commented Oct 9, 2025

Dropping usage of JUnit 4


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-19846

}

public Set getEnrollments() {
public Set<Enrollment> getEnrollments() {

Check notice

Code scanning / CodeQL

Exposing internal representation Note test

getEnrollments exposes the internal representation stored in field enrollments. The value may be modified
after this call to getEnrollments
.
Cannot convert...
* org.hibernate.orm.test.hql.PostgreSQLFunctionSelectClauseTest - registering custom function
* org.hibernate.orm.test.hql.PostgreSQLFunctionWhereClauseTest - aux-db-object
Cannot convert...
* org.hibernate.orm.test.hql.PostgreSQLFunctionSelectClauseTest - registering custom function
* org.hibernate.orm.test.hql.PostgreSQLFunctionWhereClauseTest - aux-db-object
Cannot convert...
* 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
Cannot convert...
* 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
Cannot convert...
* 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
Cannot convert...
* 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
Cannot convert...
* 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
Cannot convert...
* 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
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
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 (see org.hibernate.orm.test.tm.InterceptorTransactionTest)
@Override
public StandardServiceRegistry produceServiceRegistry(StandardServiceRegistryBuilder builder) {
try {
var dropOutput = File.createTempFile( "drop_script", ".sql" );

Check warning

Code scanning / CodeQL

Local information disclosure in a temporary directory Medium test

Local information disclosure vulnerability due to use of file readable by other local users.
public StandardServiceRegistry produceServiceRegistry(StandardServiceRegistryBuilder builder) {
try {
var dropOutput = File.createTempFile( "drop_script", ".sql" );
var createOutput = File.createTempFile( "create_script", ".sql" );

Check warning

Code scanning / CodeQL

Local information disclosure in a temporary directory Medium test

Local information disclosure vulnerability due to use of file readable by other local users.
public void testBooleanType() {
final Boolean original = Boolean.TRUE;
//noinspection UnnecessaryBoxing,removal,BooleanConstructorCall

Check notice

Code scanning / CodeQL

Inefficient primitive constructor Note test

Inefficient constructor for boolean value, use Boolean.valueOf(...) instead.
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 (see org.hibernate.orm.test.tm.InterceptorTransactionTest)
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 (see org.hibernate.orm.test.tm.InterceptorTransactionTest)
public class BackrefPropertyRefTest extends BackrefTest {
@Test
void verifyMapping(DomainModelScope modelScope, SessionFactoryScope factoryScope) {

Check notice

Code scanning / CodeQL

Useless parameter Note test

The parameter 'factoryScope' is never used.
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 (see org.hibernate.orm.test.tm.InterceptorTransactionTest)
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 (see org.hibernate.orm.test.tm.InterceptorTransactionTest)
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 (see org.hibernate.orm.test.tm.InterceptorTransactionTest)
private MetadataImplementor metadata;
private final List<AutoCloseable> toClose = new ArrayList<>();
private SessionFactoryImplementor sessionFactory;
private SessionFactoryScope factoryScope;

Check warning

Code scanning / CodeQL

Unsafe use of getResource Warning test

The idiom getClass().getResource() is unsafe for classes that may be extended.
private final List<AutoCloseable> toClose = new ArrayList<>();
private SessionFactoryImplementor sessionFactory;
private SessionFactoryScope factoryScope;

Check warning

Code scanning / CodeQL

Unsafe use of getResource Warning test

The idiom getClass().getResource() is unsafe for classes that may be extended.
private SessionFactoryImplementor sessionFactory;
private SessionFactoryScope factoryScope;

private final List<AutoCloseable> autoCloseables = new ArrayList<>();

Check warning

Code scanning / CodeQL

Unsafe use of getResource Warning test

The idiom getClass().getResource() is unsafe for classes that may be extended.
private SessionFactoryScope factoryScope;

private final List<AutoCloseable> autoCloseables = new ArrayList<>();

Check warning

Code scanning / CodeQL

Unsafe use of getResource Warning test

The idiom getClass().getResource() is unsafe for classes that may be extended.

private final List<AutoCloseable> autoCloseables = new ArrayList<>();

public DefaultCatalogAndSchemaTest(Options options) {

Check warning

Code scanning / CodeQL

Unsafe use of getResource Warning test

The idiom getClass().getResource() is unsafe for classes that may be extended.
private final List<AutoCloseable> autoCloseables = new ArrayList<>();

public DefaultCatalogAndSchemaTest(Options options) {
this.options = options;

Check warning

Code scanning / CodeQL

Unsafe use of getResource Warning test

The idiom getClass().getResource() is unsafe for classes that may be extended.
metadataSources.addInputStream( getClass().getResourceAsStream( "database-object-using-catalog-placeholder.orm.xml" ) );
metadataSources.addInputStream( getClass().getResourceAsStream( "database-object-using-schema-placeholder.orm.xml" ) );
if ( options.xmlMapping != null ) {
metadataSources.addInputStream( getClass().getResourceAsStream( options.xmlMapping ) );

Check warning

Code scanning / CodeQL

Unsafe use of getResource Warning test

The idiom getClass().getResource() is unsafe for classes that may be extended.
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 (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
)
@DomainModel(annotatedClasses = TheEntity.class)
@SessionFactory
public void testIt(CdiContainerScope containerScope, SessionFactoryScope factoryScope) {

Check notice

Code scanning / CodeQL

Useless parameter Note test

The parameter 'containerScope' is never used.
))
@DomainModel(annotatedClasses = TheEntity.class)
@SessionFactory
public void testAnnotations(CdiContainerScope containerScope, SessionFactoryScope factoryScope) {

Check notice

Code scanning / CodeQL

Useless parameter Note test

The parameter 'containerScope' is never used.
))
@DomainModel(annotatedClasses = TheEntity.class, xmlMappings = "org/hibernate/test/cdi/converters/orm.xml")
@SessionFactory
public void testOrmXml(CdiContainerScope cdiScope, SessionFactoryScope factoryScope) {

Check notice

Code scanning / CodeQL

Useless parameter Note test

The parameter 'cdiScope' is never used.
}

interface SettingResolver {
Object resolve(StandardServiceRegistryBuilder registryBuilder, ExtensionContext junitContext);

Check notice

Code scanning / CodeQL

Useless parameter Note test

The parameter 'registryBuilder' is never used.
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 (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
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 (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
Comment on lines +92 to +113
long count = session.doReturningWork( (connection) -> {
// in this current form, users must handle try/catches themselves for proper resource release
Statement statement = null;
long personCount = 0;
try {
statement = session.getJdbcCoordinator().getStatementPreparer().createStatement();
ResultSet resultSet = null;
try {
resultSet = session.getJdbcCoordinator().getResultSetReturn().extract( statement, "select count(*) from T_JDBC_PERSON" );
resultSet.next();
personCount = resultSet.getLong( 1 );
assertEquals( 1L, personCount );
}
finally {
releaseQuietly( session, resultSet, statement );
}
}
);
session2.getTransaction().commit();
session2.close();
assertEquals( 1L, count );

session = openSession();
session.beginTransaction();
session.remove( p );
session.getTransaction().commit();
session.close();
finally {
releaseQuietly( session, statement );
}
return personCount;
} );

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'long count' is never read.
finally {
session.close();
factoryScope.inTransaction( session, (s) -> session.doWork( connection -> {
final Statement stmnt = connection.createStatement();

Check warning

Code scanning / CodeQL

Potential database resource leak Warning test

This Statement is not always closed on method exit.
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 (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
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 (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
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 (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
persistenceContext.getCollectionsByKey().values().contains( publisher.getAuthors() ) );
Assertions.assertEquals( 0, actionQueue.numberOfCollectionRemovals() );

Set<Author> authorsOld = publisher.getAuthors();

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'Set authorsOld' is never read.
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 (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
Comment on lines 160 to +167
List<Object> objects = session.createQuery(
"from java.lang.Object",
Object.class)
.getResultList();
"from java.lang.Object",
Object.class)
.getResultList();

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'List objects' is never read.
Comment on lines 166 to +172
List<Person> persons = session.createQuery(
"from Person", Person.class)
.getResultList();
"from Person", Person.class)
.getResultList();

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'List persons' is never read.
Comment on lines 172 to +179
LocalDateTime datetime = session.createQuery(
"select local datetime",
LocalDateTime.class)
.getSingleResult();
"select local datetime",
LocalDateTime.class)
.getSingleResult();

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'LocalDateTime datetime' is never read.
public void test_jpql_api_named_query_example() {
doInJPA(this::entityManagerFactory, entityManager -> {
public void test_jpql_api_named_query_example(SessionFactoryScope factoryScope) {
factoryScope.inTransaction( entityManager -> {

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'Query query' is never read.
Comment on lines 1108 to +959
List<Person> persons = personStream
.skip(5)
.limit(5)
.collect(Collectors.toList());
.toList();

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'List persons' is never read.
public void test_hql_api_positional_parameter_example() {
doInJPA(this::entityManagerFactory, entityManager -> {
@Test
@ExpectedException( IllegalArgumentException.class )

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'Date timestamp' is never read.

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'List calls1' is never read.
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 (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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant