Search in sources :

Example 51 with KernelServices

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

the class JacORBTransformersTestCase method testTransformers.

private void testTransformers(ModelTestControllerVersion controllerVersion, ModelVersion modelVersion) throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC).setSubsystemXmlResource("subsystem-transform.xml");
    // Add legacy subsystems
    builder.createLegacyKernelServicesBuilder(AdditionalInitialization.ADMIN_ONLY_HC, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-jacorb:" + controllerVersion.getMavenGavVersion()).configureReverseControllerCheck(AdditionalInitialization.ADMIN_ONLY_HC, null);
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    checkSubsystemModelTransformation(mainServices, modelVersion, new ModelFixer() {

        @Override
        public ModelNode fixModel(ModelNode modelNode) {
            //modelNode.get(JacORBSubsystemDefinitions.PERSISTENT_SERVER_ID.getName()).set(JacORBSubsystemDefinitions.PERSISTENT_SERVER_ID.getDefaultValue());
            modelNode.get(JacORBSubsystemDefinitions.INTEROP_CHUNK_RMI_VALUETYPES.getName()).set(JacORBSubsystemDefinitions.INTEROP_CHUNK_RMI_VALUETYPES.getDefaultValue());
            return modelNode;
        }
    });
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelFixer(org.jboss.as.model.test.ModelFixer) ModelNode(org.jboss.dmr.ModelNode) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 52 with KernelServices

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

the class WebSubsystemTestCase method testAliases.

@Test
public void testAliases() throws Exception {
    KernelServices services = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXmlResource("subsystem.xml").build();
    ModelNode noAliasModel = services.readWholeModel();
    ModelNode aliasModel = services.readWholeModel(true);
    testSSLAlias(services, noAliasModel, aliasModel);
    testSSOAlias(services, noAliasModel, aliasModel);
    testAccessLogAlias(services, noAliasModel, aliasModel);
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 53 with KernelServices

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

the class WebSubsystemTestCase method testTransformation_1_3_0.

private void testTransformation_1_3_0(ModelTestControllerVersion controllerVersion) throws Exception {
    ModelVersion modelVersion = ModelVersion.create(1, 3, 0);
    String subsystemXml = readResource("subsystem-1.3.0.xml");
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(subsystemXml);
    builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-web:" + controllerVersion.getMavenGavVersion()).setExtensionClassName("org.jboss.as.web.WebExtension").configureReverseControllerCheck(createAdditionalInitialization(), null);
    KernelServices mainServices = builder.build();
    KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
    Assert.assertTrue(mainServices.isSuccessfulBoot());
    Assert.assertTrue(legacyServices.isSuccessfulBoot());
    checkSubsystemModelTransformation(mainServices, modelVersion, new ModelFixer.CumulativeModelFixer(SSLConfigurationNameFixer.INSTANCE, AccessLogPrefixFixer_1_2_0.INSTANCE));
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) ModelFixer(org.jboss.as.model.test.ModelFixer) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 54 with KernelServices

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

the class MailSubsystem20TestCase method testOperations.

@Test
public void testOperations() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(new MailSubsystem10TestCase.Initializer()).setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    PathAddress sessionAddress = PathAddress.pathAddress(MailExtension.SUBSYSTEM_PATH, PathElement.pathElement(MailExtension.MAIL_SESSION_PATH.getKey(), "defaultMail"));
    ModelNode result;
    ModelNode removeServerOp = Util.createRemoveOperation(sessionAddress.append("server", "imap"));
    removeServerOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    result = mainServices.executeOperation(removeServerOp);
    checkResult(result);
    ModelNode addServerOp = Util.createAddOperation(sessionAddress.append("server", "imap"));
    addServerOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    addServerOp.get("outbound-socket-binding-ref").set("mail-imap");
    addServerOp.get("username").set("user");
    addServerOp.get("password").set("pswd");
    result = mainServices.executeOperation(addServerOp);
    checkResult(result);
    //to make sure noting is left behind
    checkResult(mainServices.executeOperation(removeServerOp));
    checkResult(mainServices.executeOperation(addServerOp));
    ModelNode writeOp = Util.createEmptyOperation(WRITE_ATTRIBUTE_OPERATION, sessionAddress);
    writeOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    writeOp.get("name").set("debug");
    writeOp.get("value").set(false);
    result = mainServices.executeOperation(writeOp);
    checkResult(result);
    ServiceController<?> javaMailService = mainServices.getContainer().getService(MailSessionAdd.MAIL_SESSION_SERVICE_NAME.append("defaultMail"));
    javaMailService.setMode(ServiceController.Mode.ACTIVE);
    Session session = (Session) javaMailService.getValue();
    Assert.assertNotNull("session should not be null", session);
    Properties properties = session.getProperties();
    Assert.assertNotNull("smtp host should be set", properties.getProperty("mail.smtp.host"));
    Assert.assertNotNull("imap host should be set", properties.getProperty("mail.imap.host"));
    PathAddress nonExisting = PathAddress.pathAddress(MailExtension.SUBSYSTEM_PATH, PathElement.pathElement(MailExtension.MAIL_SESSION_PATH.getKey(), "non-existing-session"));
    ModelNode addSession = Util.createAddOperation(nonExisting);
    addSession.get("jndi-name").set("java:/bah");
    checkResult(mainServices.executeOperation(addSession));
    removeServerOp = Util.createRemoveOperation(nonExisting.append("server", "imap"));
    //removeServerOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    result = mainServices.executeOperation(removeServerOp);
    checkForFailure(result);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Properties(java.util.Properties) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) Session(javax.mail.Session) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 55 with KernelServices

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

the class MailSubsystem20TestCase method testRuntime.

@Test
public void testRuntime() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(new MailSubsystem10TestCase.Initializer()).setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    ServiceController<?> javaMailService = mainServices.getContainer().getService(MailSessionAdd.MAIL_SESSION_SERVICE_NAME.append("defaultMail"));
    javaMailService.setMode(ServiceController.Mode.ACTIVE);
    Session session = (Session) javaMailService.getValue();
    Assert.assertNotNull("session should not be null", session);
    Properties properties = session.getProperties();
    Assert.assertNotNull("smtp host should be set", properties.getProperty("mail.smtp.host"));
    Assert.assertNotNull("pop3 host should be set", properties.getProperty("mail.pop3.host"));
    Assert.assertNotNull("imap host should be set", properties.getProperty("mail.imap.host"));
    ServiceController<?> defaultMailService = mainServices.getContainer().getService(MailSessionAdd.MAIL_SESSION_SERVICE_NAME.append("default2"));
    session = (Session) defaultMailService.getValue();
    Assert.assertEquals("Debug should be true", true, session.getDebug());
    ServiceController<?> customMailService = mainServices.getContainer().getService(MailSessionAdd.MAIL_SESSION_SERVICE_NAME.append("custom"));
    session = (Session) customMailService.getValue();
    properties = session.getProperties();
    String host = properties.getProperty("mail.smtp.host");
    Assert.assertNotNull("smtp host should be set", host);
    Assert.assertEquals("mail.example.com", host);
    //this one should be read out of socket binding
    Assert.assertEquals("localhost", properties.get("mail.pop3.host"));
    //this one should be extra property
    Assert.assertEquals("some-custom-prop-value", properties.get("mail.pop3.custom_prop"));
    //this one should be extra property
    Assert.assertEquals("fully-qualified-prop-name", properties.get("some.fully.qualified.property"));
    MailSessionService service = (MailSessionService) customMailService.getService();
    Credentials credentials = service.getConfig().getCustomServers()[0].getCredentials();
    Assert.assertEquals(credentials.getUsername(), "username");
    Assert.assertEquals(credentials.getPassword(), "password");
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) Properties(java.util.Properties) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) Session(javax.mail.Session) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) 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