Search in sources :

Example 56 with KernelServicesBuilder

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

the class EeSubsystemTestCase method testTransformers1_1_x_reject.

private void testTransformers1_1_x_reject(ModelTestControllerVersion controllerVersion) throws Exception {
    String subsystemXml = readResource("subsystem.xml");
    //Use the non-runtime version of the extension which will happen on the HC
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
    List<ModelNode> xmlOps = builder.parseXml(subsystemXml);
    ModelVersion modelVersion = ModelVersion.create(1, 1);
    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-ee:" + controllerVersion.getMavenGavVersion());
    KernelServices mainServices = builder.build();
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    FailedOperationTransformationConfig config = new FailedOperationTransformationConfig().addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, PathElement.pathElement(EESubsystemModel.CONTEXT_SERVICE)), REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, PathElement.pathElement(EESubsystemModel.MANAGED_THREAD_FACTORY)), REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, PathElement.pathElement(EESubsystemModel.MANAGED_EXECUTOR_SERVICE)), REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, PathElement.pathElement(EESubsystemModel.MANAGED_SCHEDULED_EXECUTOR_SERVICE)), REJECTED_RESOURCE);
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, xmlOps, config);
}
Also used : FailedOperationTransformationConfig(org.jboss.as.model.test.FailedOperationTransformationConfig) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 57 with KernelServicesBuilder

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

the class WebservicesSubsystemParserTestCase method testRejections_2_0_0.

private void testRejections_2_0_0(ModelTestControllerVersion controllerVersion) throws Exception {
    // create builder for current subsystem version
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
    // create builder for legacy subsystem version
    ModelVersion version_2_0_0 = ModelVersion.create(2, 0, 0);
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, version_2_0_0).addMavenResourceURL("org.jboss.eap:wildfly-webservices-server-integration:" + controllerVersion.getMavenGavVersion()).configureReverseControllerCheck(AdditionalInitialization.MANAGEMENT, null).dontPersistXml();
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(version_2_0_0);
    Assert.assertNotNull(legacyServices);
    Assert.assertTrue("main services did not boot", mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    List<ModelNode> xmlOps = builder.parseXmlResource("ws-subsystem20.xml");
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version_2_0_0, xmlOps, getFailedTransformationConfig());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 58 with KernelServicesBuilder

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

the class WebservicesSubsystemRuntimeTestCase method testSubsystem.

@Test
public void testSubsystem() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    //WSDL soap:address rewrite engine options test
    ServerConfig serverConfig = getMSCService(mainServices.getContainer(), WSServices.CONFIG_SERVICE, ServerConfig.class);
    Assert.assertTrue(serverConfig.isModifySOAPAddress());
    Assert.assertEquals("localhost", serverConfig.getWebServiceHost());
    Assert.assertEquals(9895, serverConfig.getWebServicePort());
    Assert.assertEquals(9944, serverConfig.getWebServiceSecurePort());
    Assert.assertEquals("https", serverConfig.getWebServiceUriScheme());
    //Client & Endpoint predefined configuration tests
    //HACK: we need to manually reload the client/endpoint configs as the ServerConfigService is actually not starting in this test;
    //the reason is that it requires services which are not installed here and even if those were available it would fail to start
    //because we're not running in a modular environment and hence it won't be able to detect the proper ws stack implementation.
    //Even if we made the subsystem work with a flat classloader (which would not make sense except for the tests here), we'd have
    //to deal a hell of ws specific maven dependencies here... so really not worth the effort.
    serverConfig.reloadClientConfigs();
    ClientConfig clCfg = serverConfig.getClientConfig("My-Client-Config");
    Assert.assertNotNull(clCfg);
    Assert.assertEquals(1, clCfg.getProperties().size());
    Assert.assertEquals("bar3", clCfg.getProperties().get("foo3"));
    Assert.assertEquals(2, clCfg.getPreHandlerChains().size());
    Map<String, UnifiedHandlerChainMetaData> map = new HashMap<String, UnifiedHandlerChainMetaData>();
    for (UnifiedHandlerChainMetaData uhc : clCfg.getPreHandlerChains()) {
        map.put(uhc.getId(), uhc);
    }
    Assert.assertTrue(map.get("my-handlers").getHandlers().isEmpty());
    Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", map.get("my-handlers").getProtocolBindings());
    Assert.assertEquals(1, map.get("my-handlers2").getHandlers().size());
    Assert.assertEquals("MyHandler", map.get("my-handlers2").getHandlers().get(0).getHandlerName());
    Assert.assertEquals("org.jboss.ws.common.invocation.MyHandler", map.get("my-handlers2").getHandlers().get(0).getHandlerClass());
    Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", map.get("my-handlers").getProtocolBindings());
    Assert.assertEquals(1, clCfg.getPostHandlerChains().size());
    Assert.assertEquals("my-handlers2", clCfg.getPostHandlerChains().get(0).getId());
    Assert.assertEquals(1, clCfg.getPostHandlerChains().get(0).getHandlers().size());
    Assert.assertEquals("MyHandler2", clCfg.getPostHandlerChains().get(0).getHandlers().get(0).getHandlerName());
    Assert.assertEquals("org.jboss.ws.common.invocation.MyHandler2", clCfg.getPostHandlerChains().get(0).getHandlers().get(0).getHandlerClass());
    Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", clCfg.getPostHandlerChains().get(0).getProtocolBindings());
    serverConfig.reloadEndpointConfigs();
    EndpointConfig epCfg = serverConfig.getEndpointConfig("Standard-Endpoint-Config");
    Assert.assertNotNull(epCfg);
    Assert.assertTrue(epCfg.getProperties().isEmpty());
    Assert.assertTrue(epCfg.getPreHandlerChains().isEmpty());
    Assert.assertTrue(epCfg.getPostHandlerChains().isEmpty());
    epCfg = serverConfig.getEndpointConfig("Recording-Endpoint-Config");
    Assert.assertNotNull(epCfg);
    Assert.assertEquals(2, epCfg.getProperties().size());
    Assert.assertEquals("bar", epCfg.getProperties().get("foo"));
    Assert.assertEquals("bar2", epCfg.getProperties().get("foo2"));
    Assert.assertEquals(1, epCfg.getPreHandlerChains().size());
    Assert.assertEquals("recording-handlers", epCfg.getPreHandlerChains().get(0).getId());
    Assert.assertEquals(2, epCfg.getPreHandlerChains().get(0).getHandlers().size());
    Assert.assertEquals("RecordingHandler", epCfg.getPreHandlerChains().get(0).getHandlers().get(0).getHandlerName());
    Assert.assertEquals("org.jboss.ws.common.invocation.RecordingServerHandler", epCfg.getPreHandlerChains().get(0).getHandlers().get(0).getHandlerClass());
    Assert.assertEquals("AnotherRecordingHandler", epCfg.getPreHandlerChains().get(0).getHandlers().get(1).getHandlerName());
    Assert.assertEquals("org.jboss.ws.common.invocation.RecordingServerHandler", epCfg.getPreHandlerChains().get(0).getHandlers().get(1).getHandlerClass());
    Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", epCfg.getPreHandlerChains().get(0).getProtocolBindings());
    Assert.assertEquals(1, epCfg.getPostHandlerChains().size());
    Assert.assertEquals("recording-handlers2", epCfg.getPostHandlerChains().get(0).getId());
    Assert.assertEquals(2, epCfg.getPostHandlerChains().get(0).getHandlers().size());
    Assert.assertEquals("RecordingHandler2", epCfg.getPostHandlerChains().get(0).getHandlers().get(0).getHandlerName());
    Assert.assertEquals("org.jboss.ws.common.invocation.RecordingServerHandler", epCfg.getPostHandlerChains().get(0).getHandlers().get(0).getHandlerClass());
    Assert.assertEquals("AnotherRecordingHandler2", epCfg.getPostHandlerChains().get(0).getHandlers().get(1).getHandlerName());
    Assert.assertEquals("org.jboss.ws.common.invocation.RecordingServerHandler", epCfg.getPostHandlerChains().get(0).getHandlers().get(1).getHandlerClass());
    Assert.assertEquals("##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM", epCfg.getPostHandlerChains().get(0).getProtocolBindings());
}
Also used : ServerConfig(org.jboss.wsf.spi.management.ServerConfig) HashMap(java.util.HashMap) UnifiedHandlerChainMetaData(org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData) KernelServices(org.jboss.as.subsystem.test.KernelServices) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) EndpointConfig(org.jboss.wsf.spi.metadata.config.EndpointConfig) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 59 with KernelServicesBuilder

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

the class Ejb3TransformersTestCase method testRejections.

private void testRejections(ModelVersion model, ModelTestControllerVersion controller, String... mavenResourceURLs) throws Exception {
    // create builder for current subsystem version
    KernelServicesBuilder builder = createKernelServicesBuilder(this.createAdditionalInitialization().withCapabilities(buildDynamicCapabilityName("org.wildfly.security.security-domain", "ApplicationDomain")));
    // initialize the legacy services and add required jars
    builder.createLegacyKernelServicesBuilder(null, controller, model).addMavenResourceURL(mavenResourceURLs).dontPersistXml();
    KernelServices services = builder.build();
    Assert.assertTrue(services.isSuccessfulBoot());
    KernelServices legacyServices = services.getLegacyServices(model);
    Assert.assertNotNull(legacyServices);
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    List<ModelNode> operations = builder.parseXmlResource("subsystem-ejb3-transform-reject.xml");
    ModelTestUtils.checkFailedTransformedBootOperations(services, model, operations, createFailedOperationTransformationConfig(services, model));
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 60 with KernelServicesBuilder

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

the class FederationSubsystem_1_0_TransformerUnitTestCase method testRejectionExpressions.

private void testRejectionExpressions(ModelTestControllerVersion controllerVersion, String picketLinkJBossAs7Version) throws Exception {
    ModelVersion oldVersion = ModelVersion.create(1, 0, 0);
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, oldVersion).setExtensionClassName(FederationExtension.class.getName()).addMavenResourceURL("org.wildfly:wildfly-picketlink:" + controllerVersion.getMavenGavVersion()).addMavenResourceURL("org.picketlink.distribution:picketlink-jbas7:" + picketLinkJBossAs7Version).dontPersistXml();
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(oldVersion);
    Assert.assertNotNull(legacyServices);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    List<ModelNode> ops = builder.parseXmlResource("federation-subsystem-2.0.xml");
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, oldVersion, ops, new FailedOperationTransformationConfig().addFailedAttribute(PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, FederationExtension.SUBSYSTEM_NAME), PathElement.pathElement(ModelElement.FEDERATION.getName()), KeyStoreProviderResourceDefinition.INSTANCE.getPathElement(), KeyResourceDefinition.INSTANCE.getPathElement()), FailedOperationTransformationConfig.REJECTED_RESOURCE));
}
Also used : FailedOperationTransformationConfig(org.jboss.as.model.test.FailedOperationTransformationConfig) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Aggregations

KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)73 KernelServices (org.jboss.as.subsystem.test.KernelServices)69 ModelNode (org.jboss.dmr.ModelNode)33 ModelVersion (org.jboss.as.controller.ModelVersion)28 Test (org.junit.Test)25 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)20 PathAddress (org.jboss.as.controller.PathAddress)13 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)13 ModelFixer (org.jboss.as.model.test.ModelFixer)7 AdditionalInitialization (org.jboss.as.subsystem.test.AdditionalInitialization)6 ModelTestControllerVersion (org.jboss.as.model.test.ModelTestControllerVersion)5 ControllerInitializer (org.jboss.as.subsystem.test.ControllerInitializer)5 Properties (java.util.Properties)4 Session (javax.mail.Session)4 NewAttributesConfig (org.jboss.as.model.test.FailedOperationTransformationConfig.NewAttributesConfig)2 TransactionLogger (org.jboss.as.txn.logging.TransactionLogger)2 HttpHandler (io.undertow.server.HttpHandler)1 PathHandler (io.undertow.server.handlers.PathHandler)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1