Search in sources :

Example 86 with KernelServices

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

the class WeldSubsystemTestCase method testTransformers10.

private void testTransformers10(ModelTestControllerVersion controllerVersion) throws Exception {
    ModelVersion modelVersion = ModelVersion.create(1, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXmlResource("subsystem_3_0-transformers.xml");
    //which is why we need to include the jboss-as-controller artifact.
    builder.createLegacyKernelServicesBuilder(AdditionalInitialization.MANAGEMENT, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-weld:" + controllerVersion.getMavenGavVersion()).skipReverseControllerCheck().dontPersistXml();
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    assertTrue(mainServices.isSuccessfulBoot());
    assertTrue(legacyServices.isSuccessfulBoot());
    checkSubsystemModelTransformation(mainServices, modelVersion);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 87 with KernelServices

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

the class WeldSubsystemTestCase method testTransformers30.

@Test
public void testTransformers30() throws Exception {
    ModelVersion modelVersion = ModelVersion.create(3, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXmlResource("subsystem_4_0-transformers.xml");
    builder.createLegacyKernelServicesBuilder(AdditionalInitialization.MANAGEMENT, ModelTestControllerVersion.EAP_7_0_0, modelVersion).addMavenResourceURL("org.jboss.eap:wildfly-weld:" + ModelTestControllerVersion.EAP_7_0_0.getMavenGavVersion()).skipReverseControllerCheck().dontPersistXml();
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    assertTrue(mainServices.isSuccessfulBoot());
    assertTrue(legacyServices.isSuccessfulBoot());
    checkSubsystemModelTransformation(mainServices, modelVersion);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 88 with KernelServices

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

the class WeldSubsystemTestCase method testTransformersRejectionEAP700.

@Test
public void testTransformersRejectionEAP700() throws Exception {
    ModelVersion modelVersion = ModelVersion.create(3, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
    builder.createLegacyKernelServicesBuilder(AdditionalInitialization.MANAGEMENT, ModelTestControllerVersion.EAP_7_0_0, modelVersion).addMavenResourceURL("org.jboss.eap:wildfly-weld:" + ModelTestControllerVersion.EAP_7_0_0.getMavenGavVersion()).skipReverseControllerCheck().dontPersistXml();
    KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
    assertTrue(mainServices.getLegacyServices(modelVersion).isSuccessfulBoot());
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, parse(getSubsystemXml("subsystem-reject.xml")), new FailedOperationTransformationConfig().addFailedAttribute(PathAddress.pathAddress(WeldExtension.PATH_SUBSYSTEM), ChainedConfig.createBuilder(WeldResourceDefinition.NON_PORTABLE_MODE_ATTRIBUTE, WeldResourceDefinition.REQUIRE_BEAN_DESCRIPTOR_ATTRIBUTE).addConfig(new NewAttributesConfig(WeldResourceDefinition.THREAD_POOL_SIZE_ATTRIBUTE)).build()));
}
Also used : FailedOperationTransformationConfig(org.jboss.as.model.test.FailedOperationTransformationConfig) NewAttributesConfig(org.jboss.as.model.test.FailedOperationTransformationConfig.NewAttributesConfig) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 89 with KernelServices

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

the class JGroupsSubsystemParsingTestCase method testIndexedAdds.

/**
     * Tests that the 'fork' and 'stack' resources allow indexed adds for the 'protocol' children. This is important for
     * the work being done for WFCORE-401. This work involves calculating the operations to bring the slave domain model
     * into sync with the master domain model. Without ordered resources, that would mean on reconnect if the master
     * had added a protocol somewhere in the middle, the protocol would get added to the end rather at the correct place.
     */
@Test
public void testIndexedAdds() throws Exception {
    if (!this.schema.since(JGroupsSchema.VERSION_3_0))
        return;
    final KernelServices services = this.buildKernelServices();
    ModelNode originalSubsystemModel = services.readWholeModel().get(JGroupsSubsystemResourceDefinition.PATH.getKeyValuePair());
    ModelNode originalChannelModel = originalSubsystemModel.get(ChannelResourceDefinition.pathElement("ee").getKeyValuePair());
    ModelNode originalForkModel = originalChannelModel.get(ForkResourceDefinition.pathElement("web").getKeyValuePair());
    Assert.assertTrue(originalForkModel.isDefined());
    originalForkModel.protect();
    Assert.assertTrue(0 < originalForkModel.get(ProtocolResourceDefinition.WILDCARD_PATH.getKey()).keys().size());
    ModelNode originalStackModel = originalSubsystemModel.get(StackResourceDefinition.pathElement("maximal").getKeyValuePair());
    Assert.assertTrue(originalStackModel.isDefined());
    originalStackModel.protect();
    final PathAddress subsystemAddress = PathAddress.pathAddress(JGroupsSubsystemResourceDefinition.PATH);
    final PathAddress forkAddress = subsystemAddress.append(ChannelResourceDefinition.pathElement("ee")).append(ForkResourceDefinition.pathElement("web"));
    final PathAddress stackAddress = subsystemAddress.append(StackResourceDefinition.pathElement("maximal"));
    //Check the fork protocols honour indexed adds by inserting a protocol at the start
    ModelNode add = Operations.createAddOperation(forkAddress.append(ProtocolResourceDefinition.pathElement("MERGE2")), 0);
    ModelTestUtils.checkOutcome(services.executeOperation(add));
    ModelNode subsystemModel = services.readWholeModel().get(JGroupsSubsystemResourceDefinition.PATH.getKeyValuePair());
    ModelNode channelModel = subsystemModel.get(ChannelResourceDefinition.pathElement("ee").getKeyValuePair());
    ModelNode forkModel = channelModel.get(ForkResourceDefinition.pathElement("web").getKeyValuePair());
    Assert.assertEquals(originalForkModel.keys().size() + 1, forkModel.get(ProtocolResourceDefinition.WILDCARD_PATH.getKey()).keys().size());
    Assert.assertEquals("MERGE2", forkModel.get(ProtocolResourceDefinition.WILDCARD_PATH.getKey()).keys().iterator().next());
    //Check the stack protocols honour indexed adds by removing a protocol in the middle and readding it
    ModelNode remove = Util.createRemoveOperation(stackAddress.append(ProtocolResourceDefinition.pathElement("FD")));
    ModelTestUtils.checkOutcome(services.executeOperation(remove));
    //The original index of the FD protocol
    add = Operations.createAddOperation(stackAddress.append(ProtocolResourceDefinition.pathElement("FD")), 3);
    ModelTestUtils.checkOutcome(services.executeOperation(add));
    subsystemModel = services.readWholeModel().get(JGroupsSubsystemResourceDefinition.PATH.getKeyValuePair());
    ModelNode stackModel = subsystemModel.get(StackResourceDefinition.pathElement("maximal").getKeyValuePair());
    Assert.assertEquals(originalStackModel, stackModel);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) ClusteringSubsystemTest(org.jboss.as.clustering.subsystem.ClusteringSubsystemTest) Test(org.junit.Test)

Example 90 with KernelServices

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

the class JGroupsSubsystemParsingTestCase method testLegacyOperations.

@Test
public void testLegacyOperations() throws Exception {
    List<ModelNode> ops = new LinkedList<>();
    PathAddress subsystemAddress = PathAddress.pathAddress(JGroupsSubsystemResourceDefinition.PATH);
    PathAddress udpAddress = subsystemAddress.append(StackResourceDefinition.pathElement("udp"));
    ModelNode op = Util.createAddOperation(subsystemAddress);
    ///subsystem=jgroups:add(default-stack=udp)
    op.get("default-stack").set("udp");
    ops.add(op);
    //subsystem=jgroups/stack=udp:add(transport={"type"=>"UDP","socket-binding"=>"jgroups-udp"},protocols=["PING","MERGE3","FD_SOCK","FD","VERIFY_SUSPECT","BARRIER","pbcast.NAKACK2","UNICAST2","pbcast.STABLE","pbcast.GMS","UFC","MFC","FRAG2","RSVP"])
    op = Util.createAddOperation(udpAddress);
    ModelNode transport = new ModelNode();
    transport.get("type").set("UDP");
    transport.get("socket-binding").set("jgroups-udp");
    ModelNode protocols = new ModelNode();
    String[] protocolList = { "PING", "MERGE3", "FD_SOCK", "FD", "VERIFY_SUSPECT", "BARRIER", "pbcast.NAKACK2", "UNICAST2", "pbcast.STABLE", "pbcast.GMS", "UFC", "MFC", "FRAG2", "RSVP" };
    for (int i = 0; i < protocolList.length; i++) {
        ModelNode protocol = new ModelNode();
        protocol.get("type").set(protocolList[i]);
        protocols.add(protocol);
    }
    op.get("transport").set(transport);
    op.get("protocols").set(protocols);
    ops.add(op);
    KernelServices servicesA = createKernelServicesBuilder(createAdditionalInitialization()).setBootOperations(ops).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);
    servicesA.shutdown();
    // Test the describe operation
    final ModelNode operation = createDescribeOperation();
    final ModelNode result = servicesA.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();
    servicesA.shutdown();
    final KernelServices servicesC = createKernelServicesBuilder(createAdditionalInitialization()).setBootOperations(operations).build();
    final ModelNode modelC = servicesC.readWholeModel();
    compare(modelA, modelC);
    assertRemoveSubsystemResources(servicesC, getIgnoredChildResourcesForRemovalTest());
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) LinkedList(java.util.LinkedList) ClusteringSubsystemTest(org.jboss.as.clustering.subsystem.ClusteringSubsystemTest) Test(org.junit.Test)

Aggregations

KernelServices (org.jboss.as.subsystem.test.KernelServices)144 ModelNode (org.jboss.dmr.ModelNode)102 Test (org.junit.Test)86 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)69 ModelVersion (org.jboss.as.controller.ModelVersion)30 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)29 PathAddress (org.jboss.as.controller.PathAddress)24 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)21 AbstractSubsystemTest (org.jboss.as.subsystem.test.AbstractSubsystemTest)11 ClusteringSubsystemTest (org.jboss.as.clustering.subsystem.ClusteringSubsystemTest)10 AdditionalInitialization (org.jboss.as.subsystem.test.AdditionalInitialization)8 ModelFixer (org.jboss.as.model.test.ModelFixer)7 ControllerInitializer (org.jboss.as.subsystem.test.ControllerInitializer)6 ModelTestControllerVersion (org.jboss.as.model.test.ModelTestControllerVersion)5 Properties (java.util.Properties)4 Session (javax.mail.Session)4 CompositeOperationBuilder (org.jboss.as.controller.client.helpers.Operations.CompositeOperationBuilder)3 ConnectorLogger (org.jboss.as.connector.logging.ConnectorLogger)2 Operation (org.jboss.as.controller.client.Operation)2 NewAttributesConfig (org.jboss.as.model.test.FailedOperationTransformationConfig.NewAttributesConfig)2