HHH-17030 Followup: move schema check to launcher listener
This commit is contained in:
parent
86a2b19b77
commit
045053ff8a
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -26,10 +26,6 @@ import org.jboss.logging.Logger;
|
||||||
@RunWith(EnversRunner.class)
|
@RunWith(EnversRunner.class)
|
||||||
public abstract class AbstractEnversTest {
|
public abstract class AbstractEnversTest {
|
||||||
|
|
||||||
static {
|
|
||||||
DatabaseCleaner.clearSchemas();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final Logger log = Logger.getLogger( getClass() );
|
protected final Logger log = Logger.getLogger( getClass() );
|
||||||
|
|
||||||
private String auditStrategy;
|
private String auditStrategy;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
|
@ -62,13 +62,6 @@ public class BytecodeEnhancedTestEngine extends HierarchicalTestEngine<JupiterEn
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
|
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
|
||||||
// Make sure this runs first
|
|
||||||
try {
|
|
||||||
BaseUnitTestCase.checkClearSchema();
|
|
||||||
}
|
|
||||||
catch (Throwable e) {
|
|
||||||
throw new RuntimeException( e );
|
|
||||||
}
|
|
||||||
JupiterConfiguration configuration = new CachingJupiterConfiguration(
|
JupiterConfiguration configuration = new CachingJupiterConfiguration(
|
||||||
new DefaultJupiterConfiguration( discoveryRequest.getConfigurationParameters() ) );
|
new DefaultJupiterConfiguration( discoveryRequest.getConfigurationParameters() ) );
|
||||||
JupiterEngineDescriptor engineDescriptor = new BytecodeEnhancedEngineDescriptor( uniqueId, configuration );
|
JupiterEngineDescriptor engineDescriptor = new BytecodeEnhancedEngineDescriptor( uniqueId, configuration );
|
||||||
|
|
|
@ -16,8 +16,6 @@ import jakarta.transaction.SystemException;
|
||||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||||
|
|
||||||
import org.hibernate.testing.AfterClassOnce;
|
import org.hibernate.testing.AfterClassOnce;
|
||||||
import org.hibernate.testing.BeforeClassOnce;
|
|
||||||
import org.hibernate.testing.cleaner.DatabaseCleaner;
|
|
||||||
import org.hibernate.testing.jdbc.leak.ConnectionLeakUtil;
|
import org.hibernate.testing.jdbc.leak.ConnectionLeakUtil;
|
||||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -36,24 +34,6 @@ import org.jboss.logging.Logger;
|
||||||
@RunWith( CustomRunner.class )
|
@RunWith( CustomRunner.class )
|
||||||
public abstract class BaseUnitTestCase {
|
public abstract class BaseUnitTestCase {
|
||||||
|
|
||||||
private static Throwable schemaClearError;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
DatabaseCleaner.clearSchemas();
|
|
||||||
}
|
|
||||||
catch (Throwable t) {
|
|
||||||
schemaClearError = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClassOnce
|
|
||||||
public static void checkClearSchema() throws Throwable {
|
|
||||||
if (schemaClearError!=null) {
|
|
||||||
throw schemaClearError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final Logger log = Logger.getLogger( getClass() );
|
protected final Logger log = Logger.getLogger( getClass() );
|
||||||
|
|
||||||
private static boolean enableConnectionLeakDetection = Boolean.TRUE.toString()
|
private static boolean enableConnectionLeakDetection = Boolean.TRUE.toString()
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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.testing.schema;
|
||||||
|
|
||||||
|
import org.hibernate.testing.cleaner.DatabaseCleaner;
|
||||||
|
import org.junit.platform.launcher.LauncherSession;
|
||||||
|
import org.junit.platform.launcher.LauncherSessionListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This listener should be called before the discovery request is sent to the test engines.
|
||||||
|
* <p>
|
||||||
|
* Note, it is on purpose not registered as a service within the {@code hibernate-testing} (i.e. in {@code META-INF/services} of this jar).
|
||||||
|
* This is to prevent this listener be invoked by non Hibernate ORM users of the {@code hibernate-testing} lib.
|
||||||
|
* <p>
|
||||||
|
* See also <a href="https://junit.org/junit5/docs/current/user-guide/#launcher-api-launcher-session-listeners-tool-example-usage">...</a>
|
||||||
|
*/
|
||||||
|
public class CheckClearSchemaListener implements LauncherSessionListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void launcherSessionOpened(LauncherSession session) {
|
||||||
|
DatabaseCleaner.clearSchemas();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
org.hibernate.testing.schema.CheckClearSchemaListener
|
Loading…
Reference in New Issue