Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFCORE-7043] Subsystem-level testing of core-managment is incomplete #6235

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Comment on lines +7 to +12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lvydra You also need to add the test case that reads the subsystem with the expression resolved and assert that the values resolved are the expected ones.

</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>
Loading