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;
}
});
}
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);
}
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));
}
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);
}
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");
}
Aggregations