Search in sources :

Example 1 with KernelServices

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

the class Ejb3TransformersTestCase method testTransformation.

/**
     * Tests transformation of model from current version into specified version
     * The xml used should parse on legacy servers without rejections.
     *
     * @param model
     * @param controller
     * @param mavenResourceURLs
     * @throws Exception
     */
private void testTransformation(ModelVersion model, ModelTestControllerVersion controller, String... mavenResourceURLs) throws Exception {
    // create builder for current subsystem version
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXmlResource("subsystem-ejb3-transform.xml");
    // initialize the legacy services and add required jars
    builder.createLegacyKernelServicesBuilder(null, controller, model).addMavenResourceURL(mavenResourceURLs).skipReverseControllerCheck();
    KernelServices services = builder.build();
    Assert.assertTrue(services.isSuccessfulBoot());
    Assert.assertTrue(services.getLegacyServices(model).isSuccessfulBoot());
    // check that both versions of the legacy model are the same and valid
    checkSubsystemModelTransformation(services, model, null);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 2 with KernelServices

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

the class SubsystemOperationsTestCase method testRemoveThreadPool.

@Test
public void testRemoveThreadPool() throws Exception {
    final KernelServices kernelServices = boot(getSubsystemXml("/minimal-subsystem.xml"));
    final ModelNode address = createAddress(BatchSubsystemDefinition.THREAD_POOL_PATH);
    // Remove the thread pool
    final ModelNode removeOp = SubsystemOperations.createRemoveOperation(address);
    executeOperation(kernelServices, removeOp);
    // Reboot with a default thread pool
    String marshalledXml = kernelServices.getPersistedSubsystemXml();
    try {
        boot(marshalledXml);
        Assert.fail("Should be missing <thread-pool/>");
    } catch (XMLStreamException ignore) {
    }
    // Add back a thread-pool, must be named batch
    final ModelNode addOp = SubsystemOperations.createAddOperation(address);
    addOp.get("max-threads").set(10);
    final ModelNode keepAlive = addOp.get("keepalive-time");
    keepAlive.get("time").set(100L);
    keepAlive.get("unit").set(TimeUnit.MILLISECONDS.toString());
    executeOperation(kernelServices, addOp);
    // Get the serialized output and boot
    marshalledXml = kernelServices.getPersistedSubsystemXml();
    try {
        final KernelServices k = boot(marshalledXml);
        Assert.assertTrue(k.isSuccessfulBoot());
    } catch (XMLStreamException e) {
        final StringWriter writer = new StringWriter();
        e.printStackTrace(new PrintWriter(writer));
        Assert.fail("Failed to parse XML; " + writer.toString());
    }
    // Remove and add in a composite operation
    final Operation compositeOp = CompositeOperationBuilder.create().addStep(removeOp).addStep(addOp).build();
    executeOperation(kernelServices, compositeOp);
    // Get the serialized output and boot
    marshalledXml = kernelServices.getPersistedSubsystemXml();
    try {
        final KernelServices k = boot(marshalledXml);
        Assert.assertTrue(k.isSuccessfulBoot());
    } catch (XMLStreamException e) {
        final StringWriter writer = new StringWriter();
        e.printStackTrace(new PrintWriter(writer));
        Assert.fail("Failed to parse XML; " + writer.toString());
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) StringWriter(java.io.StringWriter) KernelServices(org.jboss.as.subsystem.test.KernelServices) Operation(org.jboss.as.controller.client.Operation) ModelNode(org.jboss.dmr.ModelNode) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 3 with KernelServices

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

the class SubsystemOperationsTestCase method testFailure.

@Test
public void testFailure() throws Exception {
    final KernelServices kernelServices = boot();
    // Add another named job-repository
    ModelNode op = SubsystemOperations.createAddOperation(createAddress(JobRepositoryDefinition.NAME, "foo"));
    ModelNode result = kernelServices.executeOperation(op);
    Assert.assertFalse(SubsystemOperations.isSuccessfulOutcome(result));
    // Add another named thread-pool
    op = SubsystemOperations.createAddOperation(createAddress(BatchConstants.THREAD_POOL, "foo"));
    result = kernelServices.executeOperation(op);
    Assert.assertFalse(SubsystemOperations.isSuccessfulOutcome(result));
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 4 with KernelServices

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

the class DatasourcesSubsystemTestCase method testTransformer.

/**
     * Tests transformation of model from latest version into one passed into modelVersion parameter.
     *
     * @throws Exception
     */
private void testTransformer(String subsystemXml, ModelTestControllerVersion controllerVersion, final ModelVersion modelVersion) throws Exception {
    //Use the non-runtime version of the extension which will happen on the HC
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
    KernelServices mainServices = initialKernelServices(builder, controllerVersion, modelVersion);
    List<ModelNode> ops = builder.parseXmlResource(subsystemXml);
    PathAddress subsystemAddress = PathAddress.pathAddress(DataSourcesSubsystemRootDefinition.PATH_SUBSYSTEM);
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, ops, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(DataSourceDefinition.PATH_DATASOURCE), new FailedOperationTransformationConfig.NewAttributesConfig(TRACKING)).addFailedAttribute(subsystemAddress.append(XaDataSourceDefinition.PATH_XA_DATASOURCE), new FailedOperationTransformationConfig.NewAttributesConfig(TRACKING)));
}
Also used : FailedOperationTransformationConfig(org.jboss.as.model.test.FailedOperationTransformationConfig) PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 5 with KernelServices

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

the class DatasourcesSubsystemTestCase method testTransformerElytronEnabled.

/**
     * Tests transformation of model from latest version into one passed into modelVersion parameter.
     *
     * @throws Exception
     */
private void testTransformerElytronEnabled(String subsystemXml, ModelTestControllerVersion controllerVersion, final ModelVersion modelVersion) throws Exception {
    //Use the non-runtime version of the extension which will happen on the HC
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
    KernelServices mainServices = initialKernelServices(builder, controllerVersion, modelVersion);
    List<ModelNode> ops = builder.parseXmlResource(subsystemXml);
    PathAddress subsystemAddress = PathAddress.pathAddress(DataSourcesSubsystemRootDefinition.PATH_SUBSYSTEM);
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, ops, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(DataSourceDefinition.PATH_DATASOURCE), new FailedOperationTransformationConfig.NewAttributesConfig(TRACKING, ELYTRON_ENABLED, AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE)).addFailedAttribute(subsystemAddress.append(XaDataSourceDefinition.PATH_XA_DATASOURCE), new FailedOperationTransformationConfig.NewAttributesConfig(TRACKING, ELYTRON_ENABLED, AUTHENTICATION_CONTEXT, RECOVERY_ELYTRON_ENABLED, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE) {

        @Override
        protected boolean isAttributeWritable(String attributeName) {
            return false;
        }

        @Override
        protected boolean checkValue(String attrName, ModelNode attribute, boolean isWriteAttribute) {
            if (attribute.isDefined()) {
                return true;
            } else {
                return false;
            }
        }

        @Override
        protected ModelNode correctValue(ModelNode toResolve, boolean isWriteAttribute) {
            return new ModelNode();
        }
    }));
}
Also used : FailedOperationTransformationConfig(org.jboss.as.model.test.FailedOperationTransformationConfig) PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Aggregations

KernelServices (org.jboss.as.subsystem.test.KernelServices)263 ModelNode (org.jboss.dmr.ModelNode)175 Test (org.junit.Test)156 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)132 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)58 PathAddress (org.jboss.as.controller.PathAddress)51 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)43 ModelVersion (org.jboss.as.controller.ModelVersion)34 AbstractSubsystemTest (org.jboss.as.subsystem.test.AbstractSubsystemTest)32 ModelFixer (org.jboss.as.model.test.ModelFixer)13 ClusteringSubsystemTest (org.jboss.as.clustering.subsystem.ClusteringSubsystemTest)12 ServiceContainer (org.jboss.msc.service.ServiceContainer)10 AdditionalInitialization (org.jboss.as.subsystem.test.AdditionalInitialization)9 Properties (java.util.Properties)7 Session (javax.mail.Session)7 ModelTestControllerVersion (org.jboss.as.model.test.ModelTestControllerVersion)5 AdditionalInitialization (org.jboss.as.clustering.subsystem.AdditionalInitialization)4 ServiceController (org.jboss.msc.service.ServiceController)4 FileReader (java.io.FileReader)3 PasswordAuthentication (javax.mail.PasswordAuthentication)3