From b6ddc379c2e1391589abfb100b356f13b7d5f287 Mon Sep 17 00:00:00 2001 From: lvydra Date: Thu, 7 Nov 2024 13:39:08 +0100 Subject: [PATCH] [WFCORE-7043] Subsystem-level testing of core-managment is incomplete --- .../CoreManagementSubsystemTestCase.java | 34 +++++++++++++++++++ .../core/management/core-management-1.0.xml | 7 +++- .../core-management-preview-1.0.xml | 7 +++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/core-management/core-management-subsystem/src/test/java/org/wildfly/extension/core/management/CoreManagementSubsystemTestCase.java b/core-management/core-management-subsystem/src/test/java/org/wildfly/extension/core/management/CoreManagementSubsystemTestCase.java index 6b6c5c17034..ff22a6b2083 100644 --- a/core-management/core-management-subsystem/src/test/java/org/wildfly/extension/core/management/CoreManagementSubsystemTestCase.java +++ b/core-management/core-management-subsystem/src/test/java/org/wildfly/extension/core/management/CoreManagementSubsystemTestCase.java @@ -5,19 +5,32 @@ package org.wildfly.extension.core.management; +import org.jboss.as.controller.client.helpers.Operations; +import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.subsystem.test.AbstractSubsystemSchemaTest; import org.jboss.as.subsystem.test.AdditionalInitialization; +import org.jboss.as.subsystem.test.KernelServices; +import org.jboss.as.subsystem.test.KernelServicesBuilder; +import org.jboss.dmr.ModelNode; +import org.junit.Assert; +import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.EnumSet; +import static org.junit.Assert.assertEquals; + /** * @author Jeff Mesnil (c) 2016 Red Hat Inc. */ @RunWith(Parameterized.class) public class CoreManagementSubsystemTestCase extends AbstractSubsystemSchemaTest { + public static final String PROCESS_STATE_LISTENER = "process-state-listener"; + public static final String PROPERTIES = "properties"; + public static final String TIMEOUT = "timeout"; + @Parameterized.Parameters(name = "{0}") public static Iterable getParameters() { return EnumSet.allOf(CoreManagementSubsystemSchema.class); @@ -32,4 +45,25 @@ protected AdditionalInitialization createAdditionalInitialization() { return new AdditionalInitialization.AdminOnlyHostControllerAdditionalInitialization(getSubsystemSchema()); } + @Test + public void testExpressionAttributesResolved() throws Exception { + KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml()); + KernelServices kernelServices = builder.build(); + Assert.assertTrue("Subsystem boot failed!", kernelServices.isSuccessfulBoot()); + + ModelNode address = Operations.createAddress("subsystem", "core-management"); + ModelNode op = Operations.createReadResourceOperation(address, true); + op.get(ModelDescriptionConstants.RESOLVE_EXPRESSIONS).set(true); + ModelNode result = kernelServices.executeOperation(op).get("result"); + + ModelNode processStateListener = result.get(PROCESS_STATE_LISTENER).get("x"); + ModelNode processStateListenerProperties = processStateListener.get(PROPERTIES); + + assertEquals("5000", getValue(processStateListener, TIMEOUT)); + assertEquals("2", getValue(processStateListenerProperties, "bar")); + } + + private Object getValue(ModelNode node, String attributeName) { + return node.get(attributeName).asString(); + } } diff --git a/core-management/core-management-subsystem/src/test/resources/org/wildfly/extension/core/management/core-management-1.0.xml b/core-management/core-management-subsystem/src/test/resources/org/wildfly/extension/core/management/core-management-1.0.xml index 7ab654653a6..19eb96767f2 100644 --- a/core-management/core-management-subsystem/src/test/resources/org/wildfly/extension/core/management/core-management-1.0.xml +++ b/core-management/core-management-subsystem/src/test/resources/org/wildfly/extension/core/management/core-management-1.0.xml @@ -4,5 +4,10 @@ --> - + + + + + + \ No newline at end of file diff --git a/core-management/core-management-subsystem/src/test/resources/org/wildfly/extension/core/management/core-management-preview-1.0.xml b/core-management/core-management-subsystem/src/test/resources/org/wildfly/extension/core/management/core-management-preview-1.0.xml index 89d671fd23b..5a54c715a87 100644 --- a/core-management/core-management-subsystem/src/test/resources/org/wildfly/extension/core/management/core-management-preview-1.0.xml +++ b/core-management/core-management-subsystem/src/test/resources/org/wildfly/extension/core/management/core-management-preview-1.0.xml @@ -5,5 +5,10 @@ - + + + + + + \ No newline at end of file