SingleRrdParser { void parse(ResourceAddress address, ModelNode modelNode) throws ParserException { if (modelNode.getType() == ModelType.LIST) { for (ModelNode nestedNode : modelNode.asList()) { ResourceAddress nestedAddress = new ResourceAddress(nestedNode.get(ADDRESS)); ModelNode nestedResult = nestedNode.get(RESULT); parseSingle(nestedAddress, nestedResult); } } else { parseSingle(address, modelNode); } } SingleRrdParser(RrdResult rrdResult);   }
@Test public void concreteResourceDescriptionOnly() { ResourceAddress address = AddressTemplate.of("/subsystem=mail").resolve(StatementContext.NOOP); ModelNode modelNode = ExternalModelNode .read(SingleRrdParserTest.class.getResourceAsStream("rrd_concrete_resource_description_only.dmr")); new SingleRrdParser(rrdResult).parse(address, modelNode); assertResourceDescriptions(rrdResult, 6, "/subsystem=mail", "/subsystem=mail/mail-session=*", "/subsystem=mail/mail-session=*/server=smtp", "/subsystem=mail/mail-session=*/server=pop3", "/subsystem=mail/mail-session=*/server=imap", "/subsystem=mail/mail-session=*/custom=*"); }
@Test public void concreteResourceSecurityContextOnly() { ResourceAddress address = AddressTemplate.of("/subsystem=mail").resolve(StatementContext.NOOP); ModelNode modelNode = ExternalModelNode .read(SingleRrdParserTest.class.getResourceAsStream("rrd_concrete_resource_security_only.dmr")); new SingleRrdParser(rrdResult).parse(address, modelNode); assertSecurityContexts(rrdResult, 6, "/subsystem=mail", "/subsystem=mail/mail-session=*", "/subsystem=mail/mail-session=*/server=smtp", "/subsystem=mail/mail-session=*/server=pop3", "/subsystem=mail/mail-session=*/server=imap", "/subsystem=mail/mail-session=*/custom=*"); }
@Test public void concreteResourceCombined() { ResourceAddress address = AddressTemplate.of("/subsystem=mail").resolve(StatementContext.NOOP); ModelNode modelNode = ExternalModelNode .read(SingleRrdParserTest.class.getResourceAsStream("rrd_concrete_resource_combined.dmr")); new SingleRrdParser(rrdResult).parse(address, modelNode); assertResourceDescriptions(rrdResult, 6, "/subsystem=mail", "/subsystem=mail/mail-session=*", "/subsystem=mail/mail-session=*/server=smtp", "/subsystem=mail/mail-session=*/server=pop3", "/subsystem=mail/mail-session=*/server=imap", "/subsystem=mail/mail-session=*/custom=*"); assertSecurityContexts(rrdResult, 6, "/subsystem=mail", "/subsystem=mail/mail-session=*", "/subsystem=mail/mail-session=*/server=smtp", "/subsystem=mail/mail-session=*/server=pop3", "/subsystem=mail/mail-session=*/server=imap", "/subsystem=mail/mail-session=*/custom=*"); }
@Test public void wildcardResourceDescriptionOnly() { ResourceAddress address = AddressTemplate.of("/subsystem=mail/mail-session=*/server=*") .resolve(StatementContext.NOOP); ModelNode modelNode = ExternalModelNode .read(SingleRrdParserTest.class.getResourceAsStream("rrd_wildcard_resource_description_only.dmr")); new SingleRrdParser(rrdResult).parse(address, modelNode); assertResourceDescriptions(rrdResult, 3, "/subsystem=mail/mail-session=*/server=smtp", "/subsystem=mail/mail-session=*/server=pop3", "/subsystem=mail/mail-session=*/server=imap"); }
@Test public void wildcardResourceSecurityContextOnly() { ResourceAddress address = AddressTemplate.of("/subsystem=mail/mail-session=*/server=*") .resolve(StatementContext.NOOP); ModelNode modelNode = ExternalModelNode .read(SingleRrdParserTest.class.getResourceAsStream("rrd_wildcard_resource_security_only.dmr")); new SingleRrdParser(rrdResult).parse(address, modelNode); assertSecurityContexts(rrdResult, 3, "/subsystem=mail/mail-session=*/server=smtp", "/subsystem=mail/mail-session=*/server=pop3", "/subsystem=mail/mail-session=*/server=imap"); }
@Test public void wildcardResourceCombined() { ResourceAddress address = AddressTemplate.of("/subsystem=mail/mail-session=*/server=*") .resolve(StatementContext.NOOP); ModelNode modelNode = ExternalModelNode .read(SingleRrdParserTest.class.getResourceAsStream("rrd_wildcard_resource_combined.dmr")); new SingleRrdParser(rrdResult).parse(address, modelNode); assertResourceDescriptions(rrdResult, 3, "/subsystem=mail/mail-session=*/server=smtp", "/subsystem=mail/mail-session=*/server=pop3", "/subsystem=mail/mail-session=*/server=imap"); assertSecurityContexts(rrdResult, 3, "/subsystem=mail/mail-session=*/server=smtp", "/subsystem=mail/mail-session=*/server=pop3", "/subsystem=mail/mail-session=*/server=imap"); }
@Test public void securityExceptions() { ResourceAddress address = AddressTemplate.of("/server-group=*").resolve(StatementContext.NOOP); ModelNode modelNode = ExternalModelNode .read(SingleRrdParserTest.class.getResourceAsStream("rrd_security_exceptions.dmr")); new SingleRrdParser(rrdResult).parse(address, modelNode); assertSecurityContexts(rrdResult, 8, "/server-group=*", "/server-group=*/deployment=*", "/server-group=*/jvm=*", "/server-group=*/deployment-overlay=*", "/server-group=*/deployment-overlay=*/deployment=*", "/server-group=*/system-property=*", "/server-group=other-server-group", "/server-group=other-server-group/jvm=default"); }