public void testDatasource() throws Exception{
// Only contain the subsystem xml, e.g.
// <subsystem xmlns="urn:jboss:domain:datasources:1.0"> ... </subsystem>
String xml = readResource("datasource.xml");
KernelServices services = super.installInController(AdditionalInitialization.MANAGEMENT, xml);
ModelNode model = services.readWholeModel();
//Check model..
final String complexDs = "complexDs";
final String complexDsJndi = "java:jboss/datasources/" + complexDs;
Properties params=nonXaDsProperties(complexDsJndi);
ModelNode modelDs=model.get("subsystem", "datasources","data-source",complexDs+"_Pool");
checkModelParams(modelDs,params);
Assert.assertEquals(modelDs.asString(),"UTF-8",modelDs.get("connection-properties","char.encoding","value").asString());
Assert.assertEquals(modelDs.asString(),"Property2",modelDs.get("valid-connection-checker-properties","name").asString());
Assert.assertEquals(modelDs.asString(),"Property4",modelDs.get("exception-sorter-properties","name").asString());
Assert.assertEquals(modelDs.asString(),"Property3",modelDs.get("stale-connection-checker-properties","name").asString());
Assert.assertEquals(modelDs.asString(),"Property1",modelDs.get("reauth-plugin-properties","name").asString());
final String complexXaDs = "complexXaDs";
final String complexXaDsJndi = "java:jboss/xa-datasources/" + complexXaDs;
params=xaDsProperties(complexXaDsJndi);
ModelNode modelXaDs=model.get("subsystem", "datasources","xa-data-source",complexXaDs+"_Pool");
checkModelParams(modelXaDs,params);
Assert.assertEquals(modelXaDs.asString(),"jdbc:h2:mem:test",modelXaDs.get("xa-datasource-properties","URL","value").asString());
Assert.assertEquals(modelXaDs.asString(),"Property2",modelXaDs.get("valid-connection-checker-properties","name").asString());
Assert.assertEquals(modelXaDs.asString(),"Property4",modelXaDs.get("exception-sorter-properties","name").asString());
Assert.assertEquals(modelXaDs.asString(),"Property3",modelXaDs.get("stale-connection-checker-properties","name").asString());
Assert.assertEquals(modelXaDs.asString(),"Property1",modelXaDs.get("reauth-plugin-properties","name").asString());
Assert.assertEquals(modelXaDs.asString(),"Property5",modelXaDs.get("recovery-plugin-properties","name").asString());
Assert.assertEquals(modelXaDs.asString(),"Property6",modelXaDs.get("recovery-plugin-properties","name1").asString());
//Marshal the xml to see that it is the same as before
String marshalled = services.getPersistedSubsystemXml();
// Assert.assertEquals(normalizeXML(xml), normalizeXML(marshalled));
services = super.installInController(AdditionalInitialization.MANAGEMENT, marshalled);
//Check that the model looks the same
ModelNode modelReloaded = services.readWholeModel();
compare(model, modelReloaded);
assertRemoveSubsystemResources(services);
}