From 2ac0566c86477340d12707e844e17fb679e33744 Mon Sep 17 00:00:00 2001 From: Smitha Subbarao Date: Tue, 26 Nov 2024 14:17:16 -0600 Subject: [PATCH] Enable the J2EE Management feature to use the Checkpoint Rule --- .../j2ee/fat/tests/EJBJ2EEManagementTest.java | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/dev/com.ibm.ws.ejbcontainer.management.j2ee_fat/fat/src/com/ibm/ws/ejbcontainer/management/j2ee/fat/tests/EJBJ2EEManagementTest.java b/dev/com.ibm.ws.ejbcontainer.management.j2ee_fat/fat/src/com/ibm/ws/ejbcontainer/management/j2ee/fat/tests/EJBJ2EEManagementTest.java index 82cedff185e..9fa675e2948 100644 --- a/dev/com.ibm.ws.ejbcontainer.management.j2ee_fat/fat/src/com/ibm/ws/ejbcontainer/management/j2ee/fat/tests/EJBJ2EEManagementTest.java +++ b/dev/com.ibm.ws.ejbcontainer.management.j2ee_fat/fat/src/com/ibm/ws/ejbcontainer/management/j2ee/fat/tests/EJBJ2EEManagementTest.java @@ -24,9 +24,7 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; @@ -35,13 +33,16 @@ import com.ibm.websphere.simplicity.ShrinkHelper.DeployOptions; import com.ibm.websphere.simplicity.config.ServerConfiguration; +import componenttest.annotation.CheckpointTest; import componenttest.annotation.Server; import componenttest.custom.junit.runner.FATRunner; -import componenttest.rules.repeater.FeatureReplacementAction; -import componenttest.rules.repeater.RepeatTests; +import componenttest.rules.repeater.CheckpointRule; +import componenttest.rules.repeater.CheckpointRule.ServerMode; +import componenttest.rules.repeater.EmptyAction; import componenttest.topology.impl.LibertyServer; @RunWith(FATRunner.class) +@CheckpointTest(alwaysRun = true) public class EJBJ2EEManagementTest { private static final String SERVER_NAME = "com.ibm.ws.ejbcontainer.management.j2ee.fat"; private static final String APP_NAME = "EJBJ2EEManagement"; @@ -52,14 +53,22 @@ public class EJBJ2EEManagementTest { @Server("com.ibm.ws.ejbcontainer.management.j2ee.fat") public static LibertyServer server; - @ClassRule - public static RepeatTests r = RepeatTests.with(FeatureReplacementAction.EE7_FEATURES().fullFATOnly().forServers("com.ibm.ws.ejbcontainer.management.j2ee.fat")).andWith(FeatureReplacementAction.EE8_FEATURES().forServers("com.ibm.ws.ejbcontainer.management.j2ee.fat")); + /** + * @ClassRule + * public static RepeatTests r = + * RepeatTests.with(FeatureReplacementAction.EE7_FEATURES().fullFATOnly().forServers("com.ibm.ws.ejbcontainer.management.j2ee.fat")).andWith(FeatureReplacementAction.EE8_FEATURES().forServers("com.ibm.ws.ejbcontainer.management.j2ee.fat")); + **/ @ClassRule + public static CheckpointRule checkpointRule = new CheckpointRule() + .setConsoleLogName(EJBJ2EEManagementTest.class.getSimpleName() + ".log") + .addUnsupportedRepeatIDs(EmptyAction.ID) + .setServerSetup(EJBJ2EEManagementTest::serverSetUp) + .setServerStart(EJBJ2EEManagementTest::serverStart) + .setServerTearDown(EJBJ2EEManagementTest::serverTearDown); private static JMXConnector jmxConnector; private static MBeanServerConnection mbsc; - @BeforeClass - public static void beforeClass() throws Exception { + public static LibertyServer serverSetUp(ServerMode mode) throws Exception { // Use ShrinkHelper to build the EJBJ2EEManagement ear JavaArchive ExcEJBJ2EEManagementJar = ShrinkHelper.buildJavaArchive(MODULE_NAME, "com.ibm.ws.ejbcontainer.management.j2ee.fat.ejb."); ExcEJBJ2EEManagementJar = (JavaArchive) ShrinkHelper.addDirectory(ExcEJBJ2EEManagementJar, "test-applications/EJBJ2EEManagement.jar/resources"); @@ -70,14 +79,17 @@ public static void beforeClass() throws Exception { ShrinkHelper.exportAppToServer(server, EJBJ2EEManagementApp, DeployOptions.SERVER_ONLY); server.setupForRestConnectorAccess(); - server.startServer(); + return server; + } + + public static void serverStart(ServerMode mode, LibertyServer server) throws Exception { + server.startServer(); jmxConnector = server.getJMXRestConnector(); mbsc = jmxConnector.getMBeanServerConnection(); } - @AfterClass - public static void afterClass() throws Exception { + public static void serverTearDown(ServerMode mode, LibertyServer server) throws Exception { if (server != null && server.isStarted()) { if (jmxConnector != null) { jmxConnector.close();