@Test public void testParseDecoratorNoPattern() throws Exception { // You may just want a named decorator that can be used when invoking sitemesh directly parse("<decorator key=\"key\" page=\"/templates/page.vmd\"></decorator>"); assertEquals("/templates/page.vmd", desc.getPage()); assertNull(desc.getPattern()); }
@Test public void testParseDecorator() throws Exception { parse( "<decorator key=\"key\" page=\"/templates/page.vmd\"><pattern>/path/*</pattern></decorator>"); assertEquals("/templates/page.vmd", desc.getPage()); assertTrue(desc.getPattern().matcher("/path/servlet").matches()); assertFalse(desc.getPattern().matcher("/other/servlet").matches()); }
private void parse(String xml) throws Exception { Document document = DocumentHelper.parseText(xml); desc.init(new StaticPlugin(), document.getRootElement()); }