* Test that the model created from the xml looks as expected
*/
public void testInstallIntoController() throws Exception {
// Parse the subsystem xml and install into the controller
String subsystemXml = getSubsystemXml();
KernelServices services = super.installInController(subsystemXml);
// Read the whole model and make sure it looks as expected
ModelNode model = services.readWholeModel();
// System.out.println(model);
Assert.assertTrue(model.get(SUBSYSTEM).hasDefined(AgentSubsystemExtension.SUBSYSTEM_NAME));
Assert.assertTrue(model.get(SUBSYSTEM, AgentSubsystemExtension.SUBSYSTEM_NAME).hasDefined(
AgentSubsystemExtension.AGENT_ENABLED));
Assert.assertTrue(model
.get(SUBSYSTEM, AgentSubsystemExtension.SUBSYSTEM_NAME, AgentSubsystemExtension.AGENT_ENABLED).resolve()
.asBoolean());
Assert.assertTrue(model.get(SUBSYSTEM, AgentSubsystemExtension.SUBSYSTEM_NAME).hasDefined(
AgentSubsystemExtension.PLUGINS_ELEMENT));
List<Property> plugins = model.get(SUBSYSTEM, AgentSubsystemExtension.SUBSYSTEM_NAME)
.get(AgentSubsystemExtension.PLUGINS_ELEMENT).asPropertyList();
Assert.assertEquals(plugins.size(), 2);
Assert.assertEquals(plugins.get(0).getName(), "platform"); // platform plugin is first in the xml
Assert.assertEquals(plugins.get(0).getValue().asBoolean(), true);
Assert.assertEquals(plugins.get(1).getName(), "blah"); // blah plugin is first in the xml
Assert.assertEquals(plugins.get(1).getValue().asBoolean(), false);
// Sanity check to test the service was there
AgentService agent = (AgentService) services.getContainer().getRequiredService(AgentService.SERVICE_NAME)
.getValue();
assert 2 == agent.getPlugins().size();
Assert.assertTrue(agent.getPlugins().get("platform"));
Assert.assertFalse(agent.getPlugins().get("blah"));
}