Refactor move tests from ebean-core to ebean-test

This commit is contained in:
rbygrave committed 2021-09-08 22:49:23 +12:00
1 parent 0b00a14fd3
commit eab56d323b
1650 files changed
+185 -147

No files matched your search

@@ -0,0 +1,78 @@
package io.ebeaninternal.server.lib;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.DatabaseFactory;
import io.ebean.event.ShutdownManager;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class ShutdownManagerTest extends BaseTestCase {
/**
* Run this test manually. Most typical when we want the application code to control shutdown.
*/
@Disabled
@Test
public void test_disableShutdownHook_shutdownManually() {
// disable hook to make sure app code controls when shutdown is executed
ShutdownManager.deregisterShutdownHook();
DB.getDefault();
System.out.println("shutdown manually ... ");
// application code explicitly calls shutdown()
ShutdownManager.shutdown();
}
/**
* Run this test manually.
*/
@Disabled
@Test
public void test_shutdownHook() {
DB.getDefault(); // shutdown fired via shutdown hook, default behaviour
}
/**
* Run this test manually.
*/
@Disabled
@Test
public void test_disableShutdownHook() {
DB.getDefault();
ShutdownManager.deregisterShutdownHook(); // no shutdown is run here (not great, don't do this)
}
/**
* Run this test manually.
*/
@Disabled
@Test
public void test_shutdownManually() {
DB.getDefault();
System.out.println("shutdown manually ... ");
// note this removes the shutdown hook, only "useful" if it runs BEFORE a JVM shutdown is invoked (hook invoked)
DatabaseFactory.shutdown();
}
/**
* Run this test manually.
*/
@Disabled
@Test
public void test_deregisterShutdownHook() {
DB.getDefault();
ShutdownManager.deregisterShutdownHook();
}
/**
* Run this test manually.
*/
@Disabled
@Test
public void test_noShutdownHook() {
System.setProperty("ebean.registerShutdownHook", "false");
DB.getDefault();
}
}