org.jboss.as.subsystem.test.KernelServices Java Examples

The following examples show how to use org.jboss.as.subsystem.test.KernelServices. 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: MappersTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testPrincipalTransformerTree() throws Exception {
    KernelServices services = super.createKernelServicesBuilder(new TestEnvironment()).setSubsystemXmlResource("mappers-test.xml").build();
    if (!services.isSuccessfulBoot()) {
        Assert.fail(services.getBootError().toString());
    }

    TestEnvironment.activateService(services, Capabilities.SECURITY_DOMAIN_RUNTIME_CAPABILITY, "TestingDomain");
    ServiceName serviceName = Capabilities.PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY.getCapabilityServiceName("tree");
    PrincipalTransformer transformer = (PrincipalTransformer) services.getContainer().getService(serviceName).getValue();
    Assert.assertNotNull(transformer);

    Assert.assertEquals("[email protected]", transformer.apply(new NamePrincipal("[email protected]")).getName()); // com to org
    Assert.assertEquals("beta", transformer.apply(new NamePrincipal("[email protected]")).getName()); // remove server part
    Assert.assertEquals("[email protected]", transformer.apply(new NamePrincipal("[email protected]")).getName()); // keep
    Assert.assertEquals(null, transformer.apply(new NamePrincipal("invalid"))); // not an e-mail address
    Assert.assertEquals(null, transformer.apply(null));
}
 
Example #2
Source File: SimpleSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Starts a controller with a given subsystem xml and then checks that a second
 * controller started with the xml marshalled from the first one results in the same model
 */
@Test
public void testParseAndMarshalModel() throws Exception {
    //Parse the subsystem xml and install into the first controller
    String subsystemXml =
            "<subsystem xmlns=\"" + SimpleSubsystemExtension.NAMESPACE + "\">" +
            "</subsystem>";
    KernelServices servicesA = createKernelServicesBuilder(null)
            .setSubsystemXml(subsystemXml)
            .build();
    //Get the model and the persisted xml from the first controller
    ModelNode modelA = servicesA.readWholeModel();
    String marshalled = servicesA.getPersistedSubsystemXml();

    //Install the persisted xml from the first controller into a second controller
    KernelServices servicesB = createKernelServicesBuilder(null)
            .setSubsystemXml(marshalled)
            .build();
    ModelNode modelB = servicesB.readWholeModel();

    //Make sure the models from the two controllers are identical
    super.compare(modelA, modelB);
}
 
Example #3
Source File: JBossSubsystemXMLTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testInstallSubsystemXmlWithEnginesAndJobExecutor() throws Exception {
  String subsystemXml = FileUtils.readFile(SUBSYSTEM_WITH_PROCESS_ENGINES_AND_JOB_EXECUTOR);

  KernelServices services = createKernelServicesBuilder(null)
      .setSubsystemXml(subsystemXml)
      .build();
  ServiceContainer container = services.getContainer();

  commonSubsystemServicesAreInstalled(container);
  assertNotNull("process engine controller for engine __default is installed ", container.getService(ServiceNames.forManagedProcessEngine("__default")));
  assertNotNull("process engine controller for engine __test is installed ", container.getService(ServiceNames.forManagedProcessEngine("__test")));

  String persistedSubsystemXml = services.getPersistedSubsystemXml();
  compareXml(null, subsystemXml, persistedSubsystemXml);
}
 
Example #4
Source File: LoggingOperationsSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private ModelNode addFileHandler(final KernelServices kernelServices, final String loggingProfile, final String name,
                                 final Level level, final Path file, final boolean assign) {
    final ModelNode address = createFileHandlerAddress(loggingProfile, name).toModelNode();

    // add file handler
    ModelNode op = SubsystemOperations.createAddOperation(address);
    op.get(CommonAttributes.NAME.getName()).set(name);
    op.get(CommonAttributes.LEVEL.getName()).set(level.getName());
    op.get(CommonAttributes.FILE.getName()).get(PathResourceDefinition.PATH.getName()).set(file.toAbsolutePath().toString());
    op.get(CommonAttributes.AUTOFLUSH.getName()).set(true);
    executeOperation(kernelServices, op);

    // register it with root logger
    if (assign) {
        op = SubsystemOperations.createOperation("root-logger-assign-handler", createRootLoggerAddress(loggingProfile).toModelNode());
        op.get(CommonAttributes.NAME.getName()).set(name);
        executeOperation(kernelServices, op);
    }
    return address;
}
 
Example #5
Source File: LoggingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testEapTransformer(final ModelTestControllerVersion controllerVersion, final ModelVersion legacyModelVersion, final String subsystemXml, final ModelFixer... modelFixers) throws Exception {

        final KernelServicesBuilder builder = createKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance())
                .setSubsystemXml(subsystemXml);

        // Create the legacy kernel
        builder.createLegacyKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance(), controllerVersion, legacyModelVersion)
                .addMavenResourceURL("org.jboss.as:jboss-as-logging:" + controllerVersion.getMavenGavVersion())
                .dontPersistXml()
                .addSingleChildFirstClass(LoggingTestEnvironment.class)
                .configureReverseControllerCheck(LoggingTestEnvironment.getManagementInstance(), null);

        KernelServices mainServices = builder.build();
        Assert.assertTrue(mainServices.isSuccessfulBoot());
        KernelServices legacyServices = mainServices.getLegacyServices(legacyModelVersion);
        Assert.assertTrue(legacyServices.isSuccessfulBoot());
        Assert.assertNotNull(legacyServices);
        checkSubsystemModelTransformation(mainServices, legacyModelVersion, new ChainedModelFixer(modelFixers));
    }
 
Example #6
Source File: JBossSubsystemXMLTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testInstallSubsystemXmlPlatformPlugins() throws Exception {
  String subsystemXml = FileUtils.readFile(SUBSYSTEM_WITH_PROCESS_ENGINES_ELEMENT_ONLY);

  KernelServices services = createKernelServicesBuilder(null)
      .setSubsystemXml(subsystemXml)
      .build();

  ServiceContainer container = services.getContainer();
  ServiceController<?> serviceController = container.getService(ServiceNames.forBpmPlatformPlugins());
  assertNotNull(serviceController);
  Object platformPlugins = serviceController.getValue();
  assertTrue(platformPlugins instanceof BpmPlatformPlugins);
  assertNotNull(platformPlugins);
  List<BpmPlatformPlugin> plugins = ((BpmPlatformPlugins) platformPlugins).getPlugins();
  assertEquals(1, plugins.size());
  assertTrue(plugins.get(0) instanceof ExampleBpmPlatformPlugin);
}
 
Example #7
Source File: RemotingSubsystemTransformersTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void checkRejectOutboundConnectionProtocolNotRemote(KernelServices mainServices, ModelVersion version, String type, String name) throws OperationFailedException {
    ModelNode operation = new ModelNode();
    operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
    ModelNode address = new ModelNode();
    address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);
    address.add(type, name);
    operation.get(OP_ADDR).set(address);
    operation.get(NAME).set(CommonAttributes.PROTOCOL);
    operation.get(VALUE).set(Protocol.HTTP_REMOTING.toString());

    checkReject(operation, mainServices, version);

    PathAddress addr = PathAddress.pathAddress(operation.get(OP_ADDR));
    PathElement element = addr.getLastElement();
    addr = addr.subAddress(0, addr.size() - 1);
    addr = addr.append(PathElement.pathElement(element.getKey(), "remoting-outbound2"));

    operation = Util.createAddOperation(addr);
    operation.get(CommonAttributes.OUTBOUND_SOCKET_BINDING_REF).set("dummy-outbound-socket");
    operation.get(CommonAttributes.USERNAME).set("myuser");
    operation.get(CommonAttributes.PROTOCOL).set(Protocol.HTTP_REMOTING.toString());
    checkReject(operation, mainServices, version);

}
 
Example #8
Source File: ValidateOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Tests that a valid operation passes validation
 */
@Test
public void testValidArgs() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.LONG)
                    .setRequired(true)
                    .setValidator(new LongRangeValidator(0L, 2L))
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set(1);
    KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
            .setBootOperations(Collections.singletonList(operation))
            .build();

    services.validateOperation(operation);
}
 
Example #9
Source File: HandlerLegacyOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testOperations() throws Exception {
    final KernelServices kernelServices = boot();

    testConsoleHandler(kernelServices, null);
    testConsoleHandler(kernelServices, PROFILE);

    testFileHandler(kernelServices, null);
    testFileHandler(kernelServices, PROFILE);

    testPeriodicRotatingFileHandler(kernelServices, null);
    testPeriodicRotatingFileHandler(kernelServices, PROFILE);

    testSizeRotatingFileHandler(kernelServices, null);
    testPeriodicRotatingFileHandler(kernelServices, PROFILE);

    // Run these last as they put the server in reload-required, and the later
    // ones will not update runtime once that is done
    testAsyncHandler(kernelServices, null);
    testAsyncHandler(kernelServices, PROFILE);

    kernelServices.shutdown();
}
 
Example #10
Source File: MappersTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testSourceAddressRoleDecoder() throws Exception {
    KernelServices services = super.createKernelServicesBuilder(new TestEnvironment()).setSubsystemXmlResource("mappers-test.xml").build();
    if (!services.isSuccessfulBoot()) {
        Assert.fail(services.getBootError().toString());
    }
    TestEnvironment.activateService(services, Capabilities.SECURITY_DOMAIN_RUNTIME_CAPABILITY, "TestingDomain");

    ServiceName serviceName = Capabilities.ROLE_DECODER_RUNTIME_CAPABILITY.getCapabilityServiceName("ipRoleDecoder1");
    RoleDecoder roleDecoder = (RoleDecoder) services.getContainer().getService(serviceName).getValue();
    Assert.assertNotNull(roleDecoder);

    String sourceAddress = "10.12.14.16";
    Roles decodedRoles = roleDecoder.decodeRoles(getAuthorizationIdentity(sourceAddress));
    assertTrue(decodedRoles.contains("admin"));
    assertTrue(decodedRoles.contains("user"));
    Assert.assertEquals(Roles.NONE, roleDecoder.decodeRoles(getAuthorizationIdentity("10.12.16.18")));
    Assert.assertEquals(Roles.NONE, roleDecoder.decodeRoles(getAuthorizationIdentity(null)));
    Assert.assertEquals(Roles.NONE, roleDecoder.decodeRoles(getAuthorizationIdentity("0:0:0:0:ffff:0:192.0.2.128")));
}
 
Example #11
Source File: LoggingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testEap7Transformer(final ModelTestControllerVersion controllerVersion, final ModelVersion legacyModelVersion, final String subsystemXml, final ModelFixer... modelFixers) throws Exception {
    final KernelServicesBuilder builder = createKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance())
            .setSubsystemXml(subsystemXml);

    // Create the legacy kernel
    builder.createLegacyKernelServicesBuilder(LoggingTestEnvironment.getManagementInstance(), controllerVersion, legacyModelVersion)
            .addMavenResourceURL(controllerVersion.getCoreMavenGroupId() + ":wildfly-logging:" + controllerVersion.getCoreVersion())
            .dontPersistXml()
            .addSingleChildFirstClass(LoggingTestEnvironment.class)
            .configureReverseControllerCheck(LoggingTestEnvironment.getManagementInstance(), null);

    KernelServices mainServices = builder.build();
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    KernelServices legacyServices = mainServices.getLegacyServices(legacyModelVersion);
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    Assert.assertNotNull(legacyServices);
    checkSubsystemModelTransformation(mainServices, legacyModelVersion, new ChainedModelFixer(modelFixers));
}
 
Example #12
Source File: IdentityOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testClearPassword() throws Exception {
    KernelServices services = createKernelServicesBuilder(null)
            .setSubsystemXmlResource("identity-management.xml")
            .build();
    String principalName = "plainUser";
    PathAddress realmAddress = getSecurityRealmAddress("FileSystemRealm");
    ModelNode operation = createAddIdentityOperation(realmAddress, principalName);
    ModelNode result = services.executeOperation(operation);
    assertSuccessful(result);

    operation = createSetPasswordOperation("default", realmAddress, principalName,
            ModifiableRealmDecorator.SetPasswordHandler.Clear.OBJECT_DEFINITION, "clearPassword", null, null, null, null, null, null);
    result = services.executeOperation(operation);
    assertSuccessful(result);
}
 
Example #13
Source File: RemotingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void checkEndpointSettings(KernelServices services, Map<String, ModelNode> nonDefaults, boolean expectDefaults) throws OperationFailedException {
    // Check the root
    ModelNode readResource = Util.createEmptyOperation(READ_RESOURCE_OPERATION, ROOT_ADDRESS);
    readResource.get(RECURSIVE).set(true);
    readResource.get(INCLUDE_DEFAULTS).set(expectDefaults);
    ModelNode result = services.executeForResult(readResource);
    checkEndpointSettings(result, nonDefaults, expectDefaults);

    // Check the child returned recursively
    assertTrue(result.toString(), result.hasDefined("configuration", "endpoint"));
    checkEndpointSettings(result.get("configuration", "endpoint"), nonDefaults, expectDefaults);

    // Check the child independently read
    readResource = Util.createEmptyOperation(READ_RESOURCE_OPERATION, ENDPOINT_CONFIG_ADDRESS);
    readResource.get(INCLUDE_DEFAULTS).set(expectDefaults);
    result = services.executeForResult(readResource);
    checkEndpointSettings(result, nonDefaults, expectDefaults);
}
 
Example #14
Source File: JBossSubsystemXMLTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 *  Parses and marshall the given subsystemXmlFile into one controller, then reads the model into second one.
 *  Compares the models afterwards.
 * @param subsystemXmlFile the name of the subsystem xml file
 * @throws Exception
 */
protected void parseAndMarshalSubsystemModelFromFile(String subsystemXmlFile) throws Exception {
  String subsystemXml = FileUtils.readFile(subsystemXmlFile);
  // Parse the subsystem xml and install into the first controller
  KernelServices servicesA = createKernelServicesBuilder(null).setSubsystemXml(subsystemXml).build();
  // Get the model and the persisted xml from the first controller
  ModelNode modelA = servicesA.readWholeModel();
  String marshalled = servicesA.getPersistedSubsystemXml();

  // Make sure the xml is the same
  compareXml(null, subsystemXml, marshalled);

  // Install the persisted xml from the first controller into a second controller
  KernelServices servicesB = createKernelServicesBuilder(null).setSubsystemXml(marshalled).build();
  ModelNode modelB = servicesB.readWholeModel();

  // Make sure the models from the two controllers are identical
  compare(modelA, modelB);
}
 
Example #15
Source File: IOSubsystem20TestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testRuntime() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization())
            .setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(String.valueOf(mainServices.getBootError()));
    }
    ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default"));
    workerServiceController.setMode(ServiceController.Mode.ACTIVE);
    workerServiceController.awaitValue();
    XnioWorker worker = workerServiceController.getService().getValue();
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount());
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue());
    PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default");
    ModelNode op = Util.createOperation("read-resource", addr);
    op.get("include-runtime").set(true);
    mainServices.executeOperation(op);
}
 
Example #16
Source File: IdentityOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testOneTimePassword() throws Exception {
    KernelServices services = createKernelServicesBuilder(null)
            .setSubsystemXmlResource("identity-management.xml")
            .build();
    String principalName = "plainUser";
    PathAddress realmAddress = getSecurityRealmAddress("FileSystemRealm");
    ModelNode operation = createAddIdentityOperation(realmAddress, principalName);
    ModelNode result = services.executeOperation(operation);
    assertSuccessful(result);

    operation = createSetPasswordOperation("default", realmAddress, principalName,
            ModifiableRealmDecorator.SetPasswordHandler.OTPassword.OBJECT_DEFINITION, "pass123", null, null, "Elytron Realm", OneTimePassword.ALGORITHM_OTP_MD5, "fghi", 123);

    result = services.executeOperation(operation);
    assertSuccessful(result);
}
 
Example #17
Source File: IdentityOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testSetMultipleCredentials() throws Exception {
    KernelServices services = createKernelServicesBuilder(null)
            .setSubsystemXmlResource("identity-management.xml")
            .build();
    String principalName = "plainUser";
    PathAddress realmAddress = getSecurityRealmAddress("FileSystemRealm");
    ModelNode operation = createAddIdentityOperation(realmAddress, principalName);
    ModelNode result = services.executeOperation(operation);
    assertSuccessful(result);

    operation = createSetPasswordOperation("default", realmAddress, principalName,
            ModifiableRealmDecorator.SetPasswordHandler.Digest.OBJECT_DEFINITION, "digestPassword", null, null, "Elytron Realm", DigestPassword.ALGORITHM_DIGEST_MD5, null, null);

    result = services.executeOperation(operation);
    assertSuccessful(result);

    operation = createSetPasswordOperation("default", realmAddress, principalName,
            ModifiableRealmDecorator.SetPasswordHandler.Clear.OBJECT_DEFINITION, "clearPassword", null, null, null, null, null, null);
    result = services.executeOperation(operation);
    assertSuccessful(result);
}
 
Example #18
Source File: HandlerLegacyOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testUpdateProperties(final KernelServices kernelServices, final ModelNode address, final AttributeDefinition attribute, final String value) {
    final ModelNode original = SubsystemOperations.readResult(executeOperation(kernelServices, SubsystemOperations.createReadResourceOperation(address, true)));
    ModelNode op = OperationBuilder.create(AbstractHandlerDefinition.UPDATE_OPERATION_NAME, address)
            .addAttribute(attribute, value)
            .build();
    executeOperation(kernelServices, op);
    // Value should be changed
    op = SubsystemOperations.createReadAttributeOperation(address, attribute);
    final ModelNode result = executeOperation(kernelServices, op);
    assertEquals(value, SubsystemOperations.readResultAsString(result));

    // Compare the updated model with the original model, slightly modified
    final ModelNode newModel = SubsystemOperations.readResult(executeOperation(kernelServices, SubsystemOperations.createReadResourceOperation(address, true)));
    // Replace the value in the original model, all other attributes should match
    original.get(attribute.getName()).set(value);
    // filter requires special handling
    if (attribute.getName().equals(AbstractHandlerDefinition.FILTER_SPEC.getName())) {
        original.get(CommonAttributes.FILTER.getName()).set(newModel.get(CommonAttributes.FILTER.getName()));
    }
    compare(original, newModel);
}
 
Example #19
Source File: RealmsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testPropertyRealm() throws Exception {
    KernelServices services = super.createKernelServicesBuilder(new TestEnvironment()).setSubsystemXmlResource("realms-test.xml").build();
    if (!services.isSuccessfulBoot()) {
        Assert.fail(services.getBootError().toString());
    }

    ServiceName serviceName = Capabilities.SECURITY_REALM_RUNTIME_CAPABILITY.getCapabilityServiceName("HashedPropertyRealm");
    SecurityRealm securityRealm = (SecurityRealm) services.getContainer().getService(serviceName).getValue();
    testAbstractPropertyRealm(securityRealm);

    ServiceName serviceName2 = Capabilities.SECURITY_REALM_RUNTIME_CAPABILITY.getCapabilityServiceName("ClearPropertyRealm");
    SecurityRealm securityRealm2 = (SecurityRealm) services.getContainer().getService(serviceName2).getValue();
    testAbstractPropertyRealm(securityRealm2);

    RealmIdentity identity1 = securityRealm2.getRealmIdentity(fromName("user1"));
    Object[] groups = identity1.getAuthorizationIdentity().getAttributes().get("groupAttr").toArray();
    Assert.assertArrayEquals(new Object[]{"firstGroup","secondGroup"}, groups);
}
 
Example #20
Source File: RemotingSubsystemTransformersTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testRejectingTransformers(ModelTestControllerVersion controllerVersion, ModelVersion messagingVersion) throws Exception {
    //Boot up empty controllers with the resources needed for the ops coming from the xml to work
    KernelServicesBuilder builder = createKernelServicesBuilder(DEFAULT_ADDITIONAL_INITIALIZATION);
    builder.createLegacyKernelServicesBuilder(DEFAULT_ADDITIONAL_INITIALIZATION, controllerVersion, messagingVersion)
            .addMavenResourceURL(controllerVersion.getCoreMavenGroupId() + ":wildfly-remoting:" + controllerVersion.getCoreVersion())
            .dontPersistXml();

    KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
    assertTrue(mainServices.getLegacyServices(messagingVersion).isSuccessfulBoot());

    List<ModelNode> ops = builder.parseXmlResource("remoting.xml");
    PathAddress subsystemAddress = PathAddress.pathAddress("subsystem", RemotingExtension.SUBSYSTEM_NAME);
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, messagingVersion, ops, new FailedOperationTransformationConfig()
            .addFailedAttribute(subsystemAddress.append(ConnectorResource.PATH),
                    new FailedOperationTransformationConfig.NewAttributesConfig(
                            ConnectorCommon.SASL_AUTHENTICATION_FACTORY,
                            ConnectorResource.SSL_CONTEXT
                    )
            )
            .addFailedAttribute(subsystemAddress.append(HttpConnectorResource.PATH),
                    new FailedOperationTransformationConfig.NewAttributesConfig(ConnectorCommon.SASL_AUTHENTICATION_FACTORY))
            .addFailedAttribute(subsystemAddress.append(RemoteOutboundConnectionResourceDefinition.ADDRESS),
                    new FailedOperationTransformationConfig.NewAttributesConfig(ConnectorCommon.SASL_AUTHENTICATION_FACTORY))
    );
}
 
Example #21
Source File: IOSubsystemTransformerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testRejectingTransformers(ModelTestControllerVersion controllerVersion, FailedOperationTransformationConfig config) throws Exception {
    ModelVersion modelVersion = controllerVersion.getSubsystemModelVersion(getMainSubsystemName());

    //Boot up empty controllers with the resources needed for the ops coming from the xml to work
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
    builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controllerVersion, modelVersion)
            .addMavenResourceURL(controllerVersion.getCoreMavenGroupId() + ":wildfly-io:" + controllerVersion.getCoreVersion())
            .dontPersistXml();

    KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
    assertTrue(mainServices.getLegacyServices(modelVersion).isSuccessfulBoot());

    List<ModelNode> ops = builder.parseXmlResource("io-reject.xml");
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, ops, config);
}
 
Example #22
Source File: SubsystemParsingAllowedClockSkewTestCase.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private void testSubsystem(String value, String unit, int realValue, String realUnit) throws Exception {
    setSubsystemXml(value, unit);
    // perform the common test
    KernelServices s = super.standardSubsystemTest(null, true);
    // get the values for the AllowedClockSkew parameters
    ModelNode idp = ModelTestUtils.getSubModel(s.readWholeModel(), getIdpPath());
    ModelNode allowedClockSkew = idp.get(Constants.Model.ALLOWED_CLOCK_SKEW);
    if (value != null) {
        Assert.assertTrue(allowedClockSkew.isDefined());
        ModelNode allowedClockSkewValue = allowedClockSkew.get(Constants.Model.ALLOWED_CLOCK_SKEW_VALUE);
        ModelNode allowedClockSkewUnit = allowedClockSkew.get(Constants.Model.ALLOWED_CLOCK_SKEW_UNIT);
        allowedClockSkewValue = ExpressionResolver.TEST_RESOLVER.resolveExpressions(allowedClockSkewValue);
        allowedClockSkewUnit = ExpressionResolver.TEST_RESOLVER.resolveExpressions(allowedClockSkewUnit);
        Assert.assertEquals(realValue, allowedClockSkewValue.asInt());
        if (unit != null) {
            Assert.assertEquals(realUnit, allowedClockSkewUnit.asString());
        } else {
            Assert.assertFalse(allowedClockSkewUnit.isDefined());
        }
    } else {
        Assert.assertFalse(allowedClockSkew.isDefined());
    }
}
 
Example #23
Source File: ExtraSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Test that the model created from the xml looks as expected
 */
@Test
public void testInstallIntoController() throws Exception {
    //Parse the subsystem xml and install into the controller
    String subsystemXml =
            "<subsystem xmlns=\"" + DependencySubsystemExtension.NAMESPACE + "\">" +
            "</subsystem>" +
            "<subsystem xmlns=\"" + MainSubsystemExtension.NAMESPACE + "\">" +
            "</subsystem>";
    KernelServices services = createKernelServicesBuilder(new DependencyAdditionalInitialization())
            .setSubsystemXml(subsystemXml)
            .build();

    //Read the whole model and make sure it looks as expected
    ModelNode model = services.readWholeModel();
    Assert.assertTrue(model.get(SUBSYSTEM).hasDefined(DependencySubsystemExtension.SUBSYSTEM_NAME));
    Assert.assertTrue(model.get(SUBSYSTEM).hasDefined(MainSubsystemExtension.SUBSYSTEM_NAME));

    Assert.assertNotNull(services.getContainer().getService(Dependency.NAME));
    Assert.assertNotNull(services.getContainer().getService(MainService.NAME));
    MainService mainService = (MainService)services.getContainer().getService(MainService.NAME).getValue();
    Assert.assertNotNull(mainService.dependencyValue.getValue());

}
 
Example #24
Source File: HandlerLegacyOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void testUpdateProperties(final KernelServices kernelServices, final ModelNode address, final AttributeDefinition attribute, final int value) {
    final ModelNode original = SubsystemOperations.readResult(executeOperation(kernelServices, SubsystemOperations.createReadResourceOperation(address, true)));
    ModelNode op = OperationBuilder.create(AbstractHandlerDefinition.UPDATE_OPERATION_NAME, address)
            .addAttribute(attribute, value)
            .build();
    executeOperation(kernelServices, op);
    // Value should be changed
    op = SubsystemOperations.createReadAttributeOperation(address, attribute);
    final ModelNode result = executeOperation(kernelServices, op);
    assertEquals(value, SubsystemOperations.readResult(result).asInt());

    // Compare the updated model with the original model, slightly modified
    final ModelNode newModel = SubsystemOperations.readResult(executeOperation(kernelServices, SubsystemOperations.createReadResourceOperation(address, true)));
    // Replace the value in the original model, all other attributes should match
    original.get(attribute.getName()).set(value);
    compare(original, newModel);
}
 
Example #25
Source File: JMXSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testParseAndMarshalModelWithRemoteConnectorRef1_1() throws Exception {
    //Parse the subsystem xml and install into the first controller
    String subsystemXml =
            "<subsystem xmlns=\"" + Namespace.JMX_1_1.getUriString() + "\">" +
            "<remoting-connector/> " +
            "</subsystem>";


    AdditionalInitialization additionalInit = new BaseAdditionalInitialization();

    KernelServices servicesA = createKernelServicesBuilder(additionalInit).setSubsystemXml(subsystemXml).build();
    //Get the model and the persisted xml from the first controller
    ModelNode modelA = servicesA.readWholeModel();
    String marshalled = servicesA.getPersistedSubsystemXml();
    servicesA.shutdown();

    compareXml(null, subsystemXml, marshalled, true);

    //Install the persisted xml from the first controller into a second controller
    KernelServices servicesB = createKernelServicesBuilder(additionalInit).setSubsystemXml(marshalled).build();
    ModelNode modelB = servicesB.readWholeModel();

    //Make sure the models from the two controllers are identical
    super.compare(modelA, modelB);
}
 
Example #26
Source File: JBossSubsystemXMLTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testInstallSubsystemWithSingleEngineXml() throws Exception {
  String subsystemXml = FileUtils.readFile(SUBSYSTEM_WITH_SINGLE_ENGINE);

  KernelServices services = createKernelServicesBuilder(null)
      .setSubsystemXml(subsystemXml)
      .build();
  ServiceContainer container = services.getContainer();

  assertNotNull("platform service should be installed", container.getService(PLATFORM_SERVICE_NAME));
  assertNotNull("process engine service should be bound in JNDI", container.getService(processEngineServiceBindingServiceName));

  assertNotNull("process engine controller for engine __default is installed ", container.getService(ServiceNames.forManagedProcessEngine("__default")));

  String persistedSubsystemXml = services.getPersistedSubsystemXml();
  compareXml(null, subsystemXml, persistedSubsystemXml);
}
 
Example #27
Source File: SimpleSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Test that the model created from the xml looks as expected, and that the services are NOT installed
 */
@Test
public void testInstallIntoControllerModelOnly() throws Exception {
    //Parse the subsystem xml and install into the controller
    String subsystemXml =
            "<subsystem xmlns=\"" + SimpleSubsystemExtension.NAMESPACE + "\">" +
            "</subsystem>";
    KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
            .setSubsystemXml(subsystemXml)
            .build();

    //Read the whole model and make sure it looks as expected
    ModelNode model = services.readWholeModel();
    Assert.assertTrue(model.get(SUBSYSTEM).hasDefined(SimpleSubsystemExtension.SUBSYSTEM_NAME));

    //Test that the service was not installed
    Assert.assertNull(services.getContainer().getService(SimpleService.NAME));

    //Check that all the resources were removed
    super.assertRemoveSubsystemResources(services);
    try {
        services.getContainer().getRequiredService(SimpleService.NAME);
        Assert.fail("Should not have found simple service");
    } catch (Exception expected) {
    }
}
 
Example #28
Source File: JMXSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testParseAndMarshalModel1_1WithShowModel() throws Exception {
    //Parse the subsystem xml and install into the first controller
    String subsystemXml =
            "<subsystem xmlns=\"" + Namespace.JMX_1_1.getUriString() + "\">" +
            "<show-model value=\"true\"/>" +
            "</subsystem>";

    String finishedXml =
            "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" +
            "    <expose-resolved-model proper-property-format=\"false\"/>" +
            "</subsystem>";

    AdditionalInitialization additionalInit = new BaseAdditionalInitialization();

    KernelServices servicesA = createKernelServicesBuilder(additionalInit).setSubsystemXml(subsystemXml).build();
    //Get the model and the persisted xml from the first controller
    ModelNode modelA = servicesA.readWholeModel();
    String marshalled = servicesA.getPersistedSubsystemXml();
    servicesA.shutdown();

    Assert.assertTrue(marshalled.contains(Namespace.CURRENT.getUriString()));
    compareXml(null, finishedXml, marshalled, true);

    //Install the persisted xml from the first controller into a second controller
    KernelServices servicesB = createKernelServicesBuilder(additionalInit).setSubsystemXml(marshalled).build();
    ModelNode modelB = servicesB.readWholeModel();

    //Make sure the models from the two controllers are identical
    super.compare(modelA, modelB);
}
 
Example #29
Source File: JMXSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testParseAndMarshalModel1_2WithShowModels() throws Exception {
    //Parse the subsystem xml and install into the first controller
    String subsystemXml =
            "<subsystem xmlns=\"" + Namespace.JMX_1_2.getUriString() + "\">" +
            "   <expose-resolved-model domain-name=\"jboss.RESOLVED\"/>" +
            "   <expose-expression-model domain-name=\"jboss.EXPRESSION\"/>" +
            "</subsystem>";

    AdditionalInitialization additionalInit = new BaseAdditionalInitialization();

    KernelServices servicesA = createKernelServicesBuilder(additionalInit).setSubsystemXml(subsystemXml).build();
    //Get the model and the persisted xml from the first controller
    ModelNode modelA = servicesA.readWholeModel();
    String marshalled = servicesA.getPersistedSubsystemXml();
    servicesA.shutdown();

    Assert.assertTrue(marshalled.contains(Namespace.CURRENT.getUriString()));
    compareXml(null, subsystemXml, marshalled, true);

    //Install the persisted xml from the first controller into a second controller
    KernelServices servicesB = createKernelServicesBuilder(additionalInit).setSubsystemXml(marshalled).build();
    ModelNode modelB = servicesB.readWholeModel();

    //Make sure the models from the two controllers are identical
    super.compare(modelA, modelB);
}
 
Example #30
Source File: HandlerOperationsTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void testUndefineCommonAttributes(final KernelServices kernelServices, final ModelNode address) {
    testUndefine(kernelServices, address, CommonAttributes.LEVEL);
    testUndefine(kernelServices, address, CommonAttributes.ENABLED);
    testUndefine(kernelServices, address, CommonAttributes.ENCODING);
    testUndefine(kernelServices, address, AbstractHandlerDefinition.FORMATTER);
    testUndefine(kernelServices, address, AbstractHandlerDefinition.FILTER_SPEC);

    // Remove a pattern-formatter
    testUndefine(kernelServices, address, AbstractHandlerDefinition.NAMED_FORMATTER);
    removePatternFormatter(kernelServices, LoggingProfileOperations.getLoggingProfileName(PathAddress.pathAddress(address)), "PATTERN");
}