Skip to content

Commit

Permalink
[WFCORE-7043] Subsystem-level testing of core-managment is incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
lvydra committed Nov 14, 2024
1 parent f507a48 commit b6ddc37
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2016 Red Hat Inc.
*/
@RunWith(Parameterized.class)
public class CoreManagementSubsystemTestCase extends AbstractSubsystemSchemaTest<CoreManagementSubsystemSchema> {

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<CoreManagementSubsystemSchema> getParameters() {
return EnumSet.allOf(CoreManagementSubsystemSchema.class);
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
-->
<subsystem xmlns="urn:jboss:domain:core-management:1.0">
<configuration-changes max-history="10"/>
<process-state-listener name="x" class="org.acme.foo.MyClass" module="org.acme.foo"/>
<process-state-listener name="x" class="org.acme.foo.MyClass" module="org.acme.foo" timeout="${process.timeout:5000}">
<properties>
<property name="foo" value="true"/>
<property name="bar" value="${bar.prop:2}"/>
</properties>
</process-state-listener>
</subsystem>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
<subsystem xmlns="urn:jboss:domain:core-management:preview:1.0">
<configuration-changes max-history="10"/>
<unstable-api-annotations level="LOG"/>
<process-state-listener name="x" class="org.acme.foo.MyClass" module="org.acme.foo"/>
<process-state-listener name="x" class="org.acme.foo.MyClass" module="org.acme.foo" timeout="${process.timeout:5000}">
<properties>
<property name="foo" value="true"/>
<property name="bar" value="${bar.prop:2}"/>
</properties>
</process-state-listener>
</subsystem>

0 comments on commit b6ddc37

Please sign in to comment.