Search in sources :

Example 1 with AdditionalInitialization

use of org.jboss.as.subsystem.test.AdditionalInitialization in project wildfly by wildfly.

the class ModClusterSubsystemParsingTestCase method testSSL.

@Ignore
@Test
public void testSSL() throws Exception {
    if (schema != ModClusterSchema.CURRENT)
        return;
    KernelServicesBuilder builder = createKernelServicesBuilder(new AdditionalInitialization()).setSubsystemXml(getSubsystemXml());
    KernelServices services = builder.build();
    ModelNode model = services.readWholeModel();
    ModelNode config = model.get(SUBSYSTEM, getMainSubsystemName()).get(MOD_CLUSTER_CONFIG, CONFIGURATION);
    ModelNode ssl = config.get(SSL, CONFIGURATION);
    Assert.assertEquals("/home/rhusar/client-keystore.jks", ssl.get("ca-certificate-file").resolve().asString());
    Assert.assertEquals("/home/rhusar/revocations", ssl.get("ca-revocation-url").resolve().asString());
    Assert.assertEquals("/home/rhusar/client-keystore.jks", ssl.get("certificate-key-file").resolve().asString());
    Assert.assertEquals("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,SSL_RSA_WITH_RC4_128_MD5,SSL_RSA_WITH_RC4_128_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA", ssl.get("cipher-suite").resolve().asString());
    Assert.assertEquals("mykeyalias", ssl.get("key-alias").resolve().asString());
    Assert.assertEquals("mypassword", ssl.get("password").resolve().asString());
    Assert.assertEquals("TLSv1", ssl.get("protocol").resolve().asString());
    ServiceController<?> service = services.getContainer().getService(ContainerEventHandlerService.CONFIG_SERVICE_NAME);
    MCMPHandlerConfiguration mcmpHandlerConfiguration = (MCMPHandlerConfiguration) service.getValue();
    Assert.assertTrue(mcmpHandlerConfiguration.isSsl());
    SSLConfiguration sslConfig = (SSLConfiguration) service.getValue();
    Assert.assertEquals("mykeyalias", sslConfig.getSslKeyAlias());
    Assert.assertEquals("mypassword", sslConfig.getSslTrustStorePassword());
    Assert.assertEquals("mypassword", sslConfig.getSslKeyStorePassword());
    Assert.assertEquals("/home/rhusar/client-keystore.jks", sslConfig.getSslKeyStore());
    Assert.assertEquals("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,SSL_RSA_WITH_RC4_128_MD5,SSL_RSA_WITH_RC4_128_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA", sslConfig.getSslCiphers());
    Assert.assertEquals("TLSv1", sslConfig.getSslProtocol());
    Assert.assertEquals("/home/rhusar/client-keystore.jks", sslConfig.getSslTrustStore());
    Assert.assertEquals("/home/rhusar/revocations", sslConfig.getSslCrlFile());
}
Also used : MCMPHandlerConfiguration(org.jboss.modcluster.config.MCMPHandlerConfiguration) SSLConfiguration(org.jboss.modcluster.config.SSLConfiguration) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) AdditionalInitialization(org.jboss.as.subsystem.test.AdditionalInitialization) Ignore(org.junit.Ignore) ClusteringSubsystemTest(org.jboss.as.clustering.subsystem.ClusteringSubsystemTest) Test(org.junit.Test)

Example 2 with AdditionalInitialization

use of org.jboss.as.subsystem.test.AdditionalInitialization in project wildfly by wildfly.

the class EeLegacySubsystemTestCase method createAdditionalInitialization.

@Override
protected AdditionalInitialization createAdditionalInitialization() {
    return new AdditionalInitialization() {

        @Override
        protected RunningMode getRunningMode() {
            return RunningMode.ADMIN_ONLY;
        }

        @Override
        protected void initializeExtraSubystemsAndModel(ExtensionRegistry extensionRegistry, Resource rootResource, ManagementResourceRegistration rootRegistration, RuntimeCapabilityRegistry capabilityRegistry) {
            if (!extensionAdded) {
                // extensionAdded = true;
                // bean validation depends on EE, so we can't use the real subsystem here
                final OperationDefinition removeExtension = new SimpleOperationDefinitionBuilder("remove", NonResolvingResourceDescriptionResolver.INSTANCE).build();
                final OperationDefinition addExtension = new SimpleOperationDefinitionBuilder("add", NonResolvingResourceDescriptionResolver.INSTANCE).addParameter(new SimpleAttributeDefinitionBuilder("module", ModelType.STRING).setRequired(true).build()).build();
                PathElement bvExtension = PathElement.pathElement(EXTENSION, "org.wildfly.extension.bean-validation");
                ManagementResourceRegistration extensionRegistration = rootRegistration.registerSubModel(new SimpleResourceDefinition(bvExtension, NonResolvingResourceDescriptionResolver.INSTANCE));
                extensionRegistration.registerReadOnlyAttribute(new SimpleAttributeDefinitionBuilder("module", ModelType.STRING).setRequired(true).build(), null);
                extensionRegistration.registerOperationHandler(removeExtension, new ReloadRequiredRemoveStepHandler());
                extensionRegistration.registerOperationHandler(addExtension, new ReloadRequiredAddStepHandler(new SimpleAttributeDefinitionBuilder("module", ModelType.STRING).setRequired(true).build()));
                final OperationDefinition removeSubsystem = new SimpleOperationDefinitionBuilder("remove", NonResolvingResourceDescriptionResolver.INSTANCE).build();
                final OperationDefinition addSubsystem = new SimpleOperationDefinitionBuilder("add", NonResolvingResourceDescriptionResolver.INSTANCE).build();
                PathElement bvSubsystem = PathElement.pathElement(SUBSYSTEM, "bean-validation");
                ManagementResourceRegistration subsystemRegistration = rootRegistration.registerSubModel(new SimpleResourceDefinition(bvSubsystem, NonResolvingResourceDescriptionResolver.INSTANCE));
                subsystemRegistration.registerOperationHandler(removeSubsystem, new ReloadRequiredRemoveStepHandler());
                subsystemRegistration.registerOperationHandler(addSubsystem, new ReloadRequiredAddStepHandler());
            }
        }
    };
}
Also used : RuntimeCapabilityRegistry(org.jboss.as.controller.capability.registry.RuntimeCapabilityRegistry) SimpleOperationDefinitionBuilder(org.jboss.as.controller.SimpleOperationDefinitionBuilder) PathElement(org.jboss.as.controller.PathElement) Resource(org.jboss.as.controller.registry.Resource) SimpleResourceDefinition(org.jboss.as.controller.SimpleResourceDefinition) ReloadRequiredRemoveStepHandler(org.jboss.as.controller.ReloadRequiredRemoveStepHandler) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) AdditionalInitialization(org.jboss.as.subsystem.test.AdditionalInitialization) OperationDefinition(org.jboss.as.controller.OperationDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) ReloadRequiredAddStepHandler(org.jboss.as.controller.ReloadRequiredAddStepHandler) ExtensionRegistry(org.jboss.as.controller.extension.ExtensionRegistry)

Example 3 with AdditionalInitialization

use of org.jboss.as.subsystem.test.AdditionalInitialization in project wildfly by wildfly.

the class FederationSubsystem_2_0_UnitTestCase method testRuntime.

@Test
public void testRuntime() throws Exception {
    System.setProperty("jboss.server.data.dir", System.getProperty("java.io.tmpdir"));
    System.setProperty("jboss.home.dir", System.getProperty("java.io.tmpdir"));
    System.setProperty("jboss.server.server.dir", System.getProperty("java.io.tmpdir"));
    KernelServicesBuilder builder = createKernelServicesBuilder(new AdditionalInitialization() {

        @Override
        protected RunningMode getRunningMode() {
            return RunningMode.NORMAL;
        }

        @Override
        protected void setupController(ControllerInitializer controllerInitializer) {
            super.setupController(controllerInitializer);
            controllerInitializer.addPath("jboss.server.data.dir", System.getProperty("java.io.tmpdir"), null);
        }
    }).setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ControllerInitializer(org.jboss.as.subsystem.test.ControllerInitializer) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) AdditionalInitialization(org.jboss.as.subsystem.test.AdditionalInitialization) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 4 with AdditionalInitialization

use of org.jboss.as.subsystem.test.AdditionalInitialization in project wildfly by wildfly.

the class IDMSubsystem_2_0_UnitTestCase method testRuntime.

@Test
public void testRuntime() throws Exception {
    System.setProperty("jboss.server.data.dir", System.getProperty("java.io.tmpdir"));
    System.setProperty("jboss.home.dir", System.getProperty("java.io.tmpdir"));
    System.setProperty("jboss.server.server.dir", System.getProperty("java.io.tmpdir"));
    KernelServicesBuilder builder = createKernelServicesBuilder(new AdditionalInitialization() {

        @Override
        protected RunningMode getRunningMode() {
            return RunningMode.NORMAL;
        }

        @Override
        protected void setupController(ControllerInitializer controllerInitializer) {
            super.setupController(controllerInitializer);
            controllerInitializer.addPath("jboss.server.data.dir", System.getProperty("java.io.tmpdir"), null);
        }
    }).setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ControllerInitializer(org.jboss.as.subsystem.test.ControllerInitializer) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) AdditionalInitialization(org.jboss.as.subsystem.test.AdditionalInitialization) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 5 with AdditionalInitialization

use of org.jboss.as.subsystem.test.AdditionalInitialization in project wildfly by wildfly.

the class IIOPSubsystemTestCase method testDescribeHandler.

@Test
public void testDescribeHandler() throws Exception {
    // parse the subsystem xml and install into the first controller.
    String subsystemXml = "<subsystem xmlns=\"" + Namespace.CURRENT.getUriString() + "\">" + "<orb socket-binding=\"iiop\" ssl-socket-binding=\"iiop-ssl\"/>" + "</subsystem>";
    AdditionalInitialization additionalInit = new AdditionalInitialization() {

        @Override
        protected void setupController(ControllerInitializer controllerInitializer) {
            controllerInitializer.addSocketBinding("iiop", 3528);
            controllerInitializer.addSocketBinding("iiop-ssl", 3529);
        }
    };
    KernelServices servicesA = createKernelServicesBuilder(additionalInit).setSubsystemXml(subsystemXml).build();
    // get the model and the describe operations from the first controller.
    ModelNode modelA = servicesA.readWholeModel();
    ModelNode describeOp = new ModelNode();
    describeOp.get(OP).set(DESCRIBE);
    describeOp.get(OP_ADDR).set(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, IIOPExtension.SUBSYSTEM_NAME)).toModelNode());
    List<ModelNode> operations = checkResultAndGetContents(servicesA.executeOperation(describeOp)).asList();
    servicesA.shutdown();
    Assert.assertEquals(1, operations.size());
    // install the describe options from the first controller into a second controller.
    KernelServices servicesB = createKernelServicesBuilder(additionalInit).setBootOperations(operations).build();
    ModelNode modelB = servicesB.readWholeModel();
    servicesB.shutdown();
    // make sure the models from the two controllers are identical.
    super.compare(modelA, modelB);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ControllerInitializer(org.jboss.as.subsystem.test.ControllerInitializer) ModelNode(org.jboss.dmr.ModelNode) AdditionalInitialization(org.jboss.as.subsystem.test.AdditionalInitialization) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Aggregations

AdditionalInitialization (org.jboss.as.subsystem.test.AdditionalInitialization)6 KernelServices (org.jboss.as.subsystem.test.KernelServices)5 Test (org.junit.Test)4 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)3 ControllerInitializer (org.jboss.as.subsystem.test.ControllerInitializer)3 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)3 ModelNode (org.jboss.dmr.ModelNode)3 ClusteringSubsystemTest (org.jboss.as.clustering.subsystem.ClusteringSubsystemTest)1 OperationDefinition (org.jboss.as.controller.OperationDefinition)1 PathElement (org.jboss.as.controller.PathElement)1 ReloadRequiredAddStepHandler (org.jboss.as.controller.ReloadRequiredAddStepHandler)1 ReloadRequiredRemoveStepHandler (org.jboss.as.controller.ReloadRequiredRemoveStepHandler)1 SimpleAttributeDefinitionBuilder (org.jboss.as.controller.SimpleAttributeDefinitionBuilder)1 SimpleOperationDefinitionBuilder (org.jboss.as.controller.SimpleOperationDefinitionBuilder)1 SimpleResourceDefinition (org.jboss.as.controller.SimpleResourceDefinition)1 RuntimeCapabilityRegistry (org.jboss.as.controller.capability.registry.RuntimeCapabilityRegistry)1 ExtensionRegistry (org.jboss.as.controller.extension.ExtensionRegistry)1 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)1 Resource (org.jboss.as.controller.registry.Resource)1 MCMPHandlerConfiguration (org.jboss.modcluster.config.MCMPHandlerConfiguration)1