use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.
the class MailSubsystem21TestCase 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"));
PasswordAuthentication auth = session.requestPasswordAuthentication(InetAddress.getLocalHost(), 25, "smtp", "", "");
Assert.assertEquals("nobody", auth.getUserName());
Assert.assertEquals("pass", auth.getPassword());
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");
}
use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.
the class MessagingSubsystem30TestCase method testTransformers.
private void testTransformers(ModelTestControllerVersion controllerVersion, ModelVersion messagingVersion, ModelFixer fixer, ModelFixer legacyModelFixer) throws Exception {
//Boot up empty controllers with the resources needed for the ops coming from the xml to work
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXmlResource("subsystem_3_0.xml");
builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controllerVersion, messagingVersion).addMavenResourceURL(getMessagingGAV(controllerVersion)).addMavenResourceURL(getHornetQDependencies(controllerVersion)).configureReverseControllerCheck(createAdditionalInitialization(), fixer).dontPersistXml();
KernelServices mainServices = builder.build();
assertTrue(mainServices.isSuccessfulBoot());
assertTrue(mainServices.getLegacyServices(messagingVersion).isSuccessfulBoot());
checkSubsystemModelTransformation(mainServices, messagingVersion, legacyModelFixer);
}
use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.
the class MessagingSubsystem30TestCase method createKernelServicesBuilder.
private KernelServicesBuilder createKernelServicesBuilder(ModelTestControllerVersion controllerVersion, ModelVersion messagingVersion, ModelFixer fixer, String xmlFileName) throws IOException, XMLStreamException, ClassNotFoundException {
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXmlResource(xmlFileName);
// create builder for legacy subsystem version
builder.createLegacyKernelServicesBuilder(createAdditionalInitialization(), controllerVersion, messagingVersion).addMavenResourceURL(getMessagingGAV(controllerVersion)).configureReverseControllerCheck(createAdditionalInitialization(), fixer).addMavenResourceURL(getHornetQDependencies(controllerVersion)).dontPersistXml();
return builder;
}
use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.
the class MessagingSubsystem30TestCase method testRejectExpressionsEAP_6_3_0.
@Test
public void testRejectExpressionsEAP_6_3_0() throws Exception {
KernelServicesBuilder builder = createKernelServicesBuilder(EAP_6_3_0, VERSION_1_3_0, PATH_FIXER, "empty_subsystem_3_0.xml");
doTestRejectExpressions_1_3_0(builder);
}
use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.
the class WebSubsystemTestCase method testRejectingTransformers_1_4_0.
private void testRejectingTransformers_1_4_0(ModelTestControllerVersion controllerVersion) throws Exception {
ModelVersion modelVersion = ModelVersion.create(1, 4, 0);
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
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("main services did not boot", mainServices.isSuccessfulBoot());
Assert.assertTrue(legacyServices.isSuccessfulBoot());
final PathAddress subsystem = PathAddress.EMPTY_ADDRESS.append("subsystem", "web");
List<ModelNode> xmlOps = builder.parseXmlResource("subsystem-2.2.0.xml");
FailedOperationTransformationConfig config = new FailedOperationTransformationConfig().addFailedAttribute(subsystem, new IntExpressionConfig("default-session-timeout")).addFailedAttribute(subsystem.append("virtual-server", "default-host").append("configuration", "sso"), new BooleanExpressionConfig("http-only"));
ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, xmlOps, config);
}
Aggregations