Skip to content

Commit

Permalink
Enable the J2EE Management feature to use the Checkpoint Rule
Browse files Browse the repository at this point in the history
  • Loading branch information
SmithaSubbarao committed Nov 26, 2024
1 parent 80a99c0 commit 2ac0566
Showing 1 changed file with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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");
Expand All @@ -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();
Expand Down

0 comments on commit 2ac0566

Please sign in to comment.