Java Code Examples for org.jboss.as.controller.operations.common.Util#getUndefineAttributeOperation()
The following examples show how to use
org.jboss.as.controller.operations.common.Util#getUndefineAttributeOperation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractConfigurationChangesTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void createConfigurationChanges(ModelControllerClient client) throws Exception { ModelNode setAllowedOrigins = Util.createEmptyOperation("list-add", ALLOWED_ORIGINS_ADDRESS); setAllowedOrigins.get(ModelDescriptionConstants.NAME).set(ModelDescriptionConstants.ALLOWED_ORIGINS); setAllowedOrigins.get(ModelDescriptionConstants.VALUE).set("http://www.wildfly.org"); client.execute(setAllowedOrigins); ModelNode setSystemProperty = Util.createAddOperation(SYSTEM_PROPERTY_ADDRESS); setSystemProperty.get(ModelDescriptionConstants.VALUE).set("changeConfig"); client.execute(setSystemProperty); ModelNode unsetAllowedOrigins = Util.getUndefineAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ModelDescriptionConstants.ALLOWED_ORIGINS); client.execute(unsetAllowedOrigins); ModelNode unsetSystemProperty = Util.createRemoveOperation(SYSTEM_PROPERTY_ADDRESS); client.execute(unsetSystemProperty); //read client.execute(Util.getReadAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ModelDescriptionConstants.ALLOWED_ORIGINS)); //invalid operation client.execute(Util.getUndefineAttributeOperation(ALLOWED_ORIGINS_ADDRESS, "not-exists-attribute")); //invalid operation client.execute(Util.getWriteAttributeOperation(ALLOWED_ORIGINS_ADDRESS, "not-exists-attribute", "123456")); //write operation, failed ModelNode setAllowedOriginsFails = Util.getWriteAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ModelDescriptionConstants.ALLOWED_ORIGINS, "123456"); //wrong type, expected is LIST, op list-add client.execute(setAllowedOriginsFails); }
Example 2
Source File: RecursiveDiscardAndRemoveTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void sanityTestNonDiscardedResource() throws Exception { ModelNode op = Util.createAddOperation(PathAddress.pathAddress(PATH)); TransformedOperation transformed = transformOperation(op); Assert.assertEquals(op, transformed.getTransformedOperation()); Assert.assertFalse(transformed.rejectOperation(success())); Assert.assertNull(transformed.getFailureDescription()); op = Util.getWriteAttributeOperation(PathAddress.pathAddress(PATH), "test", new ModelNode("a")); transformed = transformOperation(op); Assert.assertEquals(op, transformed.getTransformedOperation()); Assert.assertFalse(transformed.rejectOperation(success())); Assert.assertNull(transformed.getFailureDescription()); op = Util.getUndefineAttributeOperation(PathAddress.pathAddress(PATH), "test"); transformed = transformOperation(op); Assert.assertEquals(op, transformed.getTransformedOperation()); Assert.assertFalse(transformed.rejectOperation(success())); Assert.assertNull(transformed.getFailureDescription()); }
Example 3
Source File: ConfigurationChangesHistoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@After public void clearConfigurationChanges() throws UnsuccessfulOperationException { final ModelNode remove = Util.createRemoveOperation(ADDRESS); getManagementClient().executeForResult(remove); ModelNode configureSensitivity = Util.getUndefineAttributeOperation(SYSTEM_PROPERTY_CLASSIFICATION_ADDRESS, CONFIGURED_REQUIRES_ADDRESSABLE); getManagementClient().executeForResult(configureSensitivity); configureSensitivity = Util.getUndefineAttributeOperation(SYSTEM_PROPERTY_CLASSIFICATION_ADDRESS, CONFIGURED_REQUIRES_READ); getManagementClient().executeForResult(configureSensitivity); }
Example 4
Source File: InMemoryAuditReportTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Before public void createConfigurationChanges() throws Exception { ManagementInterface client = getClientForUser(SUPERUSER_USER); ModelNode setAllowedOrigins = Util.getWriteAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ALLOWED_ORIGINS, "http://www.wildfly.org"); client.execute(setAllowedOrigins); ModelNode setSystemProperty = Util.createAddOperation(SYSTEM_PROPERTY_ADDRESS); setSystemProperty.get(VALUE).set("changeConfig"); client.execute(setSystemProperty); ModelNode readSystemProperty = Util.createOperation(READ_RESOURCE_OPERATION, SYSTEM_PROPERTY_ADDRESS); client.execute(readSystemProperty); ModelNode unsetAllowedOrigins = Util.getUndefineAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ALLOWED_ORIGINS); client.execute(unsetAllowedOrigins); ModelNode unsetSystemProperty = Util.createRemoveOperation(SYSTEM_PROPERTY_ADDRESS); client.execute(unsetSystemProperty); }
Example 5
Source File: LegacyConfigurationChangesHistoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@After public void clearConfigurationChanges() throws UnsuccessfulOperationException { final ModelNode remove = Util.createRemoveOperation(ADDRESS); getManagementClient().executeForResult(remove); ModelNode configureSensitivity = Util.getUndefineAttributeOperation(SYSTEM_PROPERTY_CLASSIFICATION_ADDRESS, CONFIGURED_REQUIRES_ADDRESSABLE); getManagementClient().executeForResult(configureSensitivity); configureSensitivity = Util.getUndefineAttributeOperation(SYSTEM_PROPERTY_CLASSIFICATION_ADDRESS, CONFIGURED_REQUIRES_READ); getManagementClient().executeForResult(configureSensitivity); }
Example 6
Source File: ReadConfigAsFeaturesStandaloneTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void undefineParameterTest() throws UnsuccessfulOperationException { ModelNode undefineParameterOperation = Util.getUndefineAttributeOperation( PathAddress.pathAddress(SUBSYSTEM, "security-manager").append("deployment-permissions", "default"), "maximum-permissions"); ModelNode expectedConfigAsFeatures = defaultConfigAsFeatures.clone(); ModelNode securityManagerSubsystem = getFeatureNodeChild(expectedConfigAsFeatures.get(0), "subsystem.security-manager"); securityManagerSubsystem.get(CHILDREN).get(0).remove(PARAMS); doTest(Collections.singletonList(undefineParameterOperation), expectedConfigAsFeatures); }
Example 7
Source File: AbstractConfigurationChangesTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void createConfigurationChanges(PathElement host) throws Exception { DomainClient client = domainMasterLifecycleUtil.getDomainClient(); final ModelNode add = Util.createAddOperation(PathAddress.pathAddress().append(host).append(getAddress())); add.get(LegacyConfigurationChangeResourceDefinition.MAX_HISTORY.getName()).set(MAX_HISTORY_SIZE); executeForResult(client, add); // 0 -- write to host subsystem PathAddress allowedOrigins = PathAddress.pathAddress().append(host).append(ALLOWED_ORIGINS_ADDRESS); ModelNode setAllowedOrigins = Util.createEmptyOperation("list-add", allowedOrigins); setAllowedOrigins.get(ModelDescriptionConstants.NAME).set(ModelDescriptionConstants.ALLOWED_ORIGINS); setAllowedOrigins.get(ModelDescriptionConstants.VALUE).set("http://www.wildfly.org"); client.execute(setAllowedOrigins); // 1 -- write to host core PathAddress auditLogAddress = PathAddress.pathAddress().append(host).append(AUDIT_LOG_ADDRESS); ModelNode disableLogBoot = Util.getWriteAttributeOperation(auditLogAddress, ModelDescriptionConstants.LOG_BOOT, false); client.execute(disableLogBoot); // 2 -- write to host core //read client.execute(Util.getReadAttributeOperation(allowedOrigins, ModelDescriptionConstants.ALLOWED_ORIGINS)); //invalid operation; not recorded client.execute(Util.getUndefineAttributeOperation(allowedOrigins, "not-exists-attribute")); //invalid operation; not recorded client.execute(Util.getWriteAttributeOperation(allowedOrigins, "not-exists-attribute", "123456")); //write operation, failed ModelNode setAllowedOriginsFails = Util.getWriteAttributeOperation(allowedOrigins, ModelDescriptionConstants.ALLOWED_ORIGINS, "123456"); //wrong type, expected is LIST, op list-add client.execute(setAllowedOriginsFails); // 3 -- write to host core (recorded despite failure) PathAddress systemPropertyAddress = PathAddress.pathAddress().append(host).append(SYSTEM_PROPERTY_ADDRESS); ModelNode setSystemProperty = Util.createAddOperation(systemPropertyAddress); setSystemProperty.get(ModelDescriptionConstants.VALUE).set("changeConfig"); client.execute(setSystemProperty); // 4 -- write to host core ModelNode unsetAllowedOrigins = Util.getUndefineAttributeOperation(allowedOrigins, ModelDescriptionConstants.ALLOWED_ORIGINS); client.execute(unsetAllowedOrigins); // 5 -- write to host core ModelNode enableLogBoot = Util.getWriteAttributeOperation(auditLogAddress, ModelDescriptionConstants.LOG_BOOT, true); client.execute(enableLogBoot); // 6 -- write to host core ModelNode unsetSystemProperty = Util.createRemoveOperation(systemPropertyAddress); client.execute(unsetSystemProperty); // 7 -- write to host core PathAddress inMemoryAddress = PathAddress.pathAddress().append(host).append(IN_MEMORY_HANDLER_ADDRESS); ModelNode addInMemoryHandler = Util.createAddOperation(inMemoryAddress); client.execute(addInMemoryHandler); // 8 -- write to host core ModelNode editInMemoryHandler = Util.getWriteAttributeOperation(inMemoryAddress, ModelDescriptionConstants.MAX_HISTORY, 50); client.execute(editInMemoryHandler); // 9 -- write to host core ModelNode removeInMemoryHandler = Util.createRemoveOperation(inMemoryAddress); client.execute(removeInMemoryHandler); // 10 -- write to host core }
Example 8
Source File: RecursiveDiscardAndRemoveTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void discardResourceOperationsTest(PathAddress pathAddress) throws Exception { ModelNode op = Util.createAddOperation(pathAddress); TransformedOperation transformed = transformOperation(op); assertDiscarded(transformed); op = Util.getWriteAttributeOperation(pathAddress, "test", new ModelNode("a")); transformed = transformOperation(op); assertDiscarded(transformed); op = Util.getUndefineAttributeOperation(pathAddress, "test"); transformed = transformOperation(op); assertDiscarded(transformed); }
Example 9
Source File: RecursiveDiscardAndRemoveTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void rejectResourceOperationsTest(PathAddress pathAddress) throws Exception { ModelNode op = Util.createAddOperation(pathAddress); TransformedOperation transformed = transformOperation(op); assertRejected(op, transformed); op = Util.getWriteAttributeOperation(pathAddress, "test", new ModelNode("a")); transformed = transformOperation(op); assertRejected(op, transformed); op = Util.getUndefineAttributeOperation(pathAddress, "test"); transformed = transformOperation(op); assertRejected(op, transformed); }
Example 10
Source File: ConfigurationChangesHistoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Before public void createConfigurationChanges() throws Exception { ManagementInterface client = getClientForUser(SUPERUSER_USER); final ModelNode add = Util.createAddOperation(PathAddress.pathAddress(ADDRESS)); add.get("max-history").set(MAX_HISTORY_SIZE); client.execute(add); // WFCORE-3995 sensitivity classification system property default configured-requires-read is false. // Need to write configured-requires-read before configured-requires-addressable ModelNode configureSensitivity = Util.getWriteAttributeOperation(SYSTEM_PROPERTY_CLASSIFICATION_ADDRESS, CONFIGURED_REQUIRES_READ, true); client.execute(configureSensitivity); configureSensitivity = Util.getWriteAttributeOperation(SYSTEM_PROPERTY_CLASSIFICATION_ADDRESS, CONFIGURED_REQUIRES_ADDRESSABLE, true); client.execute(configureSensitivity); ModelNode setAllowedOrigins = Util.createEmptyOperation("list-add", ALLOWED_ORIGINS_ADDRESS); setAllowedOrigins.get(NAME).set(ALLOWED_ORIGINS); setAllowedOrigins.get(VALUE).set( "http://www.wildfly.org"); client.execute(setAllowedOrigins); ModelNode disableLogBoot = Util.getWriteAttributeOperation(AUDIT_LOG_ADDRESS, LOG_BOOT, false); client.execute(disableLogBoot); //read client.execute(Util.getReadAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ALLOWED_ORIGINS)); //invalid operation client.execute(Util.getUndefineAttributeOperation(ALLOWED_ORIGINS_ADDRESS, "not-exists-attribute")); //invalid operation client.execute(Util.getWriteAttributeOperation(ALLOWED_ORIGINS_ADDRESS, "not-exists-attribute", "123456")); //write operation, failed ModelNode setAllowedOriginsFails = Util.getWriteAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ALLOWED_ORIGINS, "123456");//wrong type, expected is LIST, op list-add client.execute(setAllowedOriginsFails); ModelNode setSystemProperty = Util.createAddOperation(SYSTEM_PROPERTY_ADDRESS); setSystemProperty.get(VALUE).set("changeConfig"); client.execute(setSystemProperty); ModelNode unsetAllowedOrigins = Util.getUndefineAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ALLOWED_ORIGINS); client.execute(unsetAllowedOrigins); ModelNode enableLogBoot = Util.getWriteAttributeOperation(AUDIT_LOG_ADDRESS, LOG_BOOT, true); client.execute(enableLogBoot); ModelNode unsetSystemProperty = Util.createRemoveOperation(SYSTEM_PROPERTY_ADDRESS); client.execute(unsetSystemProperty); ModelNode addInMemoryHandler = Util.createAddOperation(IN_MEMORY_HANDLER_ADDRESS); client.execute(addInMemoryHandler); ModelNode editInMemoryHandler = Util.getWriteAttributeOperation(IN_MEMORY_HANDLER_ADDRESS, MAX_HISTORY, 50); client.execute(editInMemoryHandler); ModelNode removeInMemoryHandler = Util.createRemoveOperation(IN_MEMORY_HANDLER_ADDRESS); client.execute(removeInMemoryHandler); }
Example 11
Source File: LegacyConfigurationChangesHistoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Before public void createConfigurationChanges() throws Exception { ManagementClient client = getManagementClient(); final ModelNode add = Util.createAddOperation(PathAddress.pathAddress(ADDRESS)); add.get(LegacyConfigurationChangeResourceDefinition.MAX_HISTORY.getName()).set(MAX_HISTORY_SIZE); client.executeForResult(add); // WFCORE-3995 sensitivity classification system property default configured-requires-read is false. // Need to write configured-requires-read before configured-requires-addressable ModelNode configureSensitivity = Util.getWriteAttributeOperation(SYSTEM_PROPERTY_CLASSIFICATION_ADDRESS, CONFIGURED_REQUIRES_READ, true); client.executeForResult(configureSensitivity); configureSensitivity = Util.getWriteAttributeOperation(SYSTEM_PROPERTY_CLASSIFICATION_ADDRESS, CONFIGURED_REQUIRES_ADDRESSABLE, true); client.executeForResult(configureSensitivity); ModelNode setAllowedOrigins = Util.createEmptyOperation("list-add", ALLOWED_ORIGINS_ADDRESS); setAllowedOrigins.get(NAME).set(ALLOWED_ORIGINS); setAllowedOrigins.get(VALUE).set("http://www.wildfly.org"); client.executeForResult(setAllowedOrigins); ModelNode disableLogBoot = Util.getWriteAttributeOperation(AUDIT_LOG_ADDRESS, LOG_BOOT, false); client.executeForResult(disableLogBoot); //read client.executeForResult(Util.getReadAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ALLOWED_ORIGINS)); //invalid operation client.getControllerClient().execute(Util.getUndefineAttributeOperation(ALLOWED_ORIGINS_ADDRESS, "not-exists-attribute")); //invalid operation client.getControllerClient().execute(Util.getWriteAttributeOperation(ALLOWED_ORIGINS_ADDRESS, "not-exists-attribute", "123456")); //write operation, failed ModelNode setAllowedOriginsFails = Util.getWriteAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ALLOWED_ORIGINS, "123456");//wrong type, expected is LIST, op list-add client.getControllerClient().execute(setAllowedOriginsFails); ModelNode setSystemProperty = Util.createAddOperation(SYSTEM_PROPERTY_ADDRESS); setSystemProperty.get(VALUE).set("changeConfig"); client.getControllerClient().execute(setSystemProperty); ModelNode unsetAllowedOrigins = Util.getUndefineAttributeOperation(ALLOWED_ORIGINS_ADDRESS, ALLOWED_ORIGINS); client.getControllerClient().execute(unsetAllowedOrigins); ModelNode enableLogBoot = Util.getWriteAttributeOperation(AUDIT_LOG_ADDRESS, LOG_BOOT, true); client.getControllerClient().execute(enableLogBoot); ModelNode unsetSystemProperty = Util.createRemoveOperation(SYSTEM_PROPERTY_ADDRESS); client.getControllerClient().execute(unsetSystemProperty); ModelNode addInMemoryHandler = Util.createAddOperation(IN_MEMORY_HANDLER_ADDRESS); client.getControllerClient().execute(addInMemoryHandler); ModelNode editInMemoryHandler = Util.getWriteAttributeOperation(IN_MEMORY_HANDLER_ADDRESS, MAX_HISTORY, 50); client.getControllerClient().execute(editInMemoryHandler); ModelNode removeInMemoryHandler = Util.createRemoveOperation(IN_MEMORY_HANDLER_ADDRESS); client.getControllerClient().execute(removeInMemoryHandler); }
Example 12
Source File: AbstractSystemPropertyTransformersTest.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testSystemPropertyTransformer() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(TestModelType.DOMAIN) .setXmlResource(serverGroup ? "domain-servergroup-systemproperties.xml" : "domain-systemproperties.xml"); if (serverGroup) { builder.setModelInitializer(StandardServerGroupInitializers.XML_MODEL_INITIALIZER, StandardServerGroupInitializers.XML_MODEL_WRITE_SANITIZER); } LegacyKernelServicesInitializer legacyInitializer = builder.createLegacyKernelServicesBuilder(modelVersion, testControllerVersion); if (serverGroup) { StandardServerGroupInitializers.addServerGroupInitializers(legacyInitializer); } KernelServices mainServices = builder.build(); Assert.assertTrue(mainServices.isSuccessfulBoot()); KernelServices legacyServices = mainServices.getLegacyServices(modelVersion); Assert.assertTrue(legacyServices.isSuccessfulBoot()); ModelFixer fixer = new StandardServerGroupInitializers.Fixer(modelVersion); ModelNode legacyModel = checkCoreModelTransformation(mainServices, modelVersion, fixer, fixer); ModelNode properties = legacyModel; if (serverGroup) { properties = legacyModel.get(SERVER_GROUP, "test"); } properties = properties.get(SYSTEM_PROPERTY); Assert.assertEquals(expectedUndefined, properties.get("sys.prop.test.one", BOOT_TIME)); Assert.assertEquals(1, properties.get("sys.prop.test.one", VALUE).asInt()); Assert.assertEquals(ModelNode.TRUE, properties.get("sys.prop.test.two", BOOT_TIME)); Assert.assertEquals(2, properties.get("sys.prop.test.two", VALUE).asInt()); Assert.assertEquals(ModelNode.FALSE, properties.get("sys.prop.test.three", BOOT_TIME)); Assert.assertEquals(3, properties.get("sys.prop.test.three", VALUE).asInt()); Assert.assertEquals(expectedUndefined, properties.get("sys.prop.test.four", BOOT_TIME)); Assert.assertFalse(properties.get("sys.prop.test.four", VALUE).isDefined()); //Test the write attribute handler, the 'add' got tested at boot time PathAddress baseAddress = serverGroup ? PathAddress.pathAddress(PathElement.pathElement(SERVER_GROUP, "test")) : PathAddress.EMPTY_ADDRESS; PathAddress propAddress = baseAddress.append(SYSTEM_PROPERTY, "sys.prop.test.two"); //value should just work ModelNode op = Util.getWriteAttributeOperation(propAddress, VALUE, new ModelNode("test12")); ModelTestUtils.checkOutcome(mainServices.executeOperation(modelVersion, mainServices.transformOperation(modelVersion, op))); Assert.assertEquals("test12", ModelTestUtils.getSubModel(legacyServices.readWholeModel(), propAddress).get(VALUE).asString()); //boot time should be 'true' if undefined op = Util.getWriteAttributeOperation(propAddress, BOOT_TIME, new ModelNode()); ModelTestUtils.checkOutcome(mainServices.executeOperation(modelVersion, mainServices.transformOperation(modelVersion, op))); Assert.assertTrue(ModelTestUtils.getSubModel(legacyServices.readWholeModel(), propAddress).get(BOOT_TIME).asBoolean()); op = Util.getUndefineAttributeOperation(propAddress, BOOT_TIME); ModelTestUtils.checkOutcome(mainServices.executeOperation(modelVersion, mainServices.transformOperation(modelVersion, op))); Assert.assertTrue(ModelTestUtils.getSubModel(legacyServices.readWholeModel(), propAddress).get(BOOT_TIME).asBoolean()); }