use of org.jboss.dmr.Property in project eap-additional-testsuite by jboss-set.
the class LoggingDeploymentResourceTestCase method testDeploymentConfigurationResource.
@OperateOnDeployment(EAR_PARENT_DEPLOYMENT_NAME)
@Test
public void testDeploymentConfigurationResource() throws Exception {
ModelNode loggingConfiguration = readDeploymentResource(EAR_PARENT_DEPLOYMENT_NAME, EAR_PARENT_DEPLOYMENT_NAME + "/META-INF/logging.properties");
// The address should have logging.properties
Deque<Property> resultAddress = new ArrayDeque<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList());
Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties"));
ModelNode handler = loggingConfiguration.get("handler", "FILE");
Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined());
Assert.assertTrue(handler.hasDefined("properties"));
String fileName = null;
// Find the fileName property
for (Property property : handler.get("properties").asPropertyList()) {
if ("fileName".equals(property.getName())) {
fileName = property.getValue().asString();
break;
}
}
Assert.assertNotNull("fileName property not found", fileName);
Assert.assertTrue(fileName.endsWith("test-logging-parent-ear.log"));
// Check the WAR which should have it's own configuration
loggingConfiguration = readSubDeploymentResource(EAR_PARENT_DEPLOYMENT_NAME, EAR_CHILD_WAR_DEPLOYMENT_NAME, EAR_CHILD_WAR_DEPLOYMENT_NAME + "/META-INF/logging.properties");
// The address should have logging.properties
resultAddress = new ArrayDeque<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList());
Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties"));
handler = loggingConfiguration.get("handler", "FILE");
Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined());
Assert.assertTrue(handler.hasDefined("properties"));
fileName = null;
// Find the fileName property
for (Property property : handler.get("properties").asPropertyList()) {
if ("fileName".equals(property.getName())) {
fileName = property.getValue().asString();
break;
}
}
Assert.assertNotNull("fileName property not found", fileName);
Assert.assertTrue(fileName.endsWith("test-logging-child-war.log"));
}
use of org.jboss.dmr.Property in project eap-additional-testsuite by jboss-set.
the class AddressControlManagementTestCase method testSubsystemRootOperations.
@Test
public void testSubsystemRootOperations() throws Exception {
ModelNode op = getSubsystemOperation("read-children-types");
op.get("child-type").set("core-address");
ModelNode result = execute(op, true);
Assert.assertTrue(result.isDefined());
boolean found = false;
for (ModelNode type : result.asList()) {
if ("core-address".equals(type.asString())) {
found = true;
break;
}
}
Assert.assertTrue(found);
op = getSubsystemOperation("read-children-names");
op.get("child-type").set("core-address");
result = execute(op, true);
Assert.assertTrue(result.isDefined());
found = false;
for (ModelNode address : result.asList()) {
if (getAddress().equals(address.asString())) {
found = true;
break;
}
}
Assert.assertTrue(found);
op = getSubsystemOperation("read-children-resources");
op.get("child-type").set("core-address");
result = execute(op, true);
Assert.assertTrue(result.isDefined());
found = false;
for (Property address : result.asPropertyList()) {
if (getAddress().equals(address.getName())) {
found = true;
break;
}
}
Assert.assertTrue(found);
}
use of org.jboss.dmr.Property in project eap-additional-testsuite by jboss-set.
the class BatchFileTestCase method testRunBatchFile.
// It does not work with 6.3.x
@Ignore
@Test
public void testRunBatchFile() throws Exception {
createFile(new String[] { "/system-property=batchfiletest:add(value=true)", "", "# comments", "/system-property=batchfiletest:write-attribute(value=false)" });
final CommandContext ctx = CLITestUtil.getCommandContext();
try {
ctx.connectController();
final ModelNode batchRequest = ctx.buildRequest("run-batch --file=" + TMP_FILE.getAbsolutePath() + " --headers={allow-resource-service-restart=true}");
assertTrue(batchRequest.hasDefined("operation"));
assertEquals("composite", batchRequest.get("operation").asString());
assertTrue(batchRequest.hasDefined("address"));
assertTrue(batchRequest.get("address").asList().isEmpty());
assertTrue(batchRequest.hasDefined("steps"));
List<ModelNode> steps = batchRequest.get("steps").asList();
assertEquals(2, steps.size());
ModelNode op = steps.get(0);
assertTrue(op.hasDefined("address"));
List<Property> address = op.get("address").asPropertyList();
assertEquals(1, address.size());
assertEquals("system-property", address.get(0).getName());
assertEquals("batchfiletest", address.get(0).getValue().asString());
assertTrue(op.hasDefined("operation"));
assertEquals("add", op.get("operation").asString());
assertEquals("true", op.get("value").asString());
op = steps.get(1);
assertTrue(op.hasDefined("address"));
address = op.get("address").asPropertyList();
assertEquals(1, address.size());
assertEquals("system-property", address.get(0).getName());
assertEquals("batchfiletest", address.get(0).getValue().asString());
assertTrue(op.hasDefined("operation"));
assertEquals("write-attribute", op.get("operation").asString());
assertEquals("false", op.get("value").asString());
assertTrue(batchRequest.hasDefined("operation-headers"));
final ModelNode headers = batchRequest.get("operation-headers");
assertEquals("true", headers.get("allow-resource-service-restart").asString());
} finally {
ctx.terminateSession();
}
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class ModClusterSubsystemAdd method addLoadMetrics.
private void addLoadMetrics(Set<LoadMetric> metrics, ModelNode nodes, final OperationContext context) throws OperationFailedException {
for (Property p : nodes.asPropertyList()) {
ModelNode node = p.getValue();
double capacity = CAPACITY.resolveModelAttribute(context, node).asDouble();
int weight = WEIGHT.resolveModelAttribute(context, node).asInt();
Map<String, String> propertyMap = PROPERTY.unwrap(context, node);
Class<? extends LoadMetric> loadMetricClass = null;
if (node.hasDefined(CommonAttributes.TYPE)) {
String type = TYPE.resolveModelAttribute(context, node).asString();
// MODCLUSTER-288 Metric "mem" has been dropped, keep it in the model for versions prior to 8.0
if (type.equals("mem")) {
ROOT_LOGGER.unsupportedMetric(type);
continue;
}
LoadMetricEnum metric = LoadMetricEnum.forType(type);
loadMetricClass = (metric != null) ? metric.getLoadMetricClass() : null;
} else {
String className = CustomLoadMetricDefinition.CLASS.resolveModelAttribute(context, node).asString();
try {
loadMetricClass = this.getClass().getClassLoader().loadClass(className).asSubclass(LoadMetric.class);
} catch (ClassNotFoundException e) {
ROOT_LOGGER.errorAddingMetrics(e);
}
}
if (loadMetricClass != null) {
try {
LoadMetric metric = loadMetricClass.newInstance();
metric.setCapacity(capacity);
metric.setWeight(weight);
// Apply Java Bean properties if any are set
if (propertyMap != null && !propertyMap.isEmpty()) {
Properties props = new Properties();
props.putAll(propertyMap);
try {
BeanUtils.mapJavaBeanProperties(metric, props, true);
} catch (Exception ex) {
ROOT_LOGGER.errorApplyingMetricProperties(ex, loadMetricClass.getCanonicalName());
// Do not add this incomplete metric.
continue;
}
}
metrics.add(metric);
} catch (InstantiationException | IllegalAccessException e) {
ROOT_LOGGER.errorAddingMetrics(e);
}
}
}
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class ModClusterSubsystemXMLReader_1_0 method readProperties.
static void readProperties(XMLExtendedStreamReader reader, ModelNode metric) throws XMLStreamException {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case PROPERTY:
final Property property = ParseUtils.readProperty(reader, true);
metric.get(CommonAttributes.PROPERTY).get(property.getName()).set(property.getValue());
break;
default:
throw unexpectedElement(reader);
}
}
}
Aggregations