Search in sources :

Example 6 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 7 with AdditionalInitialization

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

the class InvalidAttributeManagerDeclarationUnitTestCase method testSubsystem.

@Test
public void testSubsystem() 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();
    assertFalse(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 8 with AdditionalInitialization

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

the class ResourceAdaptersSubsystemTestCase method standardSubsystemTest.

//TODO: remove this special method as soon as RA will have a unique name in DMR marshalled in xml
protected KernelServices standardSubsystemTest(final String configId, final String configIdResolvedModel, boolean compareXml) throws Exception {
    final AdditionalInitialization additionalInit = createAdditionalInitialization();
    // Parse the subsystem xml and install into the first controller
    final String subsystemXml = configId == null ? getSubsystemXml() : getSubsystemXml(configId);
    final KernelServices servicesA = super.createKernelServicesBuilder(additionalInit).setSubsystemXml(subsystemXml).build();
    Assert.assertTrue("Subsystem boot failed!", servicesA.isSuccessfulBoot());
    //Get the model and the persisted xml from the first controller
    final ModelNode modelA = servicesA.readWholeModel();
    validateModel(modelA);
    // Test marshaling
    final String marshalled = servicesA.getPersistedSubsystemXml();
    servicesA.shutdown();
    // validate the the normalized xmls
    String normalizedSubsystem = normalizeXML(subsystemXml);
    if (compareXml) {
        compareXml(configId, normalizedSubsystem, normalizeXML(marshalled));
    }
    //Install the persisted xml from the first controller into a second controller
    final KernelServices servicesB = super.createKernelServicesBuilder(additionalInit).setSubsystemXml(marshalled).build();
    final ModelNode modelB = servicesB.readWholeModel();
    //WE CANT DO THAT FOR RA BECAUSE THEIR NAME IS GENERATED ON THE FLY W/ archive/module concatenated to a counter.
    //IT'S AN ISSUE WM_SECURITY_MAPPING_TO BE FIXED IN SUBSYSTEM
    //Make sure the models from the two controllers are identical
    //compare(modelA, modelB);
    // Test the describe operation
    final ModelNode operation = createDescribeOperation();
    final ModelNode result = servicesB.executeOperation(operation);
    Assert.assertTrue("the subsystem describe operation has to generate a list of operations to recreate the subsystem", !result.hasDefined(ModelDescriptionConstants.FAILURE_DESCRIPTION));
    final List<ModelNode> operations = result.get(ModelDescriptionConstants.RESULT).asList();
    servicesB.shutdown();
    final KernelServices servicesC = super.createKernelServicesBuilder(additionalInit).setBootOperations(operations).build();
    final ModelNode modelC = servicesC.readWholeModel();
    compare(modelB, modelC);
    assertRemoveSubsystemResources(servicesC, getIgnoredChildResourcesForRemovalTest());
    if (configIdResolvedModel != null) {
        final String subsystemResolvedXml = getSubsystemXml(configIdResolvedModel);
        final KernelServices servicesD = super.createKernelServicesBuilder(additionalInit).setSubsystemXml(subsystemResolvedXml).build();
        Assert.assertTrue("Subsystem w/ reolved xml boot failed!", servicesD.isSuccessfulBoot());
        final ModelNode modelD = servicesD.readWholeModel();
        validateModel(modelD);
        resolveandCompareModel(modelA, modelD);
    }
    return servicesA;
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) AdditionalInitialization(org.jboss.as.subsystem.test.AdditionalInitialization)

Example 9 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)9 KernelServices (org.jboss.as.subsystem.test.KernelServices)8 Test (org.junit.Test)7 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)6 ControllerInitializer (org.jboss.as.subsystem.test.ControllerInitializer)6 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)6 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 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)1 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)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