Unit tests that exercise the new (in 1.8) methods for passing in URL arguments instead of strings.
URL
8687888990919293949596
*/ @Test public void testMandatoryProperties() throws SAXException, IOException { Digester digester = newLoader( new AbstractRulesModule() { @Override protected void configure() {
131132133134135136137138139140141
*/ @Test public void testCustomisedProperties1() throws SAXException, IOException { Digester digester = newLoader( new AbstractRulesModule() { @Override protected void configure() {
173174175176177178179180181182183
*/ @Test public void testCustomisedProperties2a() throws SAXException, IOException { Digester digester = newLoader( new AbstractRulesModule() { @Override protected void configure() {
38394041424344454647484950515253
/** * {@inheritDoc} */ public void handle( SetProperty annotation, Field element, RulesBinder rulesBinder ) { SetPropertiesBuilder builder = rulesBinder .forPattern( annotation.pattern() ) .withNamespaceURI( annotation.namespaceURI() ) .setProperties(); if ( annotation.attributeName() != null && annotation.attributeName().length() > 0 && !element.getName().equals( annotation.attributeName() ) ) { builder.addAlias( annotation.attributeName(), element.getName() ); } }
4546474849505152535455
// or id is specified in the xml file. Digester digester = new Digester(); PluginRules rc = new PluginRules(); digester.setRules( rc ); PluginCreateRule pcr = new PluginCreateRule( Widget.class, TextLabel.class ); digester.addRule( "root/widget", pcr ); digester.addSetNext( "root/widget", "addChild" ); Container root = new Container(); digester.push( root );
949596979899100101102103104
// not to have one of plugin-class or plugin-id specified Digester digester = new Digester(); PluginRules rc = new PluginRules(); digester.setRules( rc ); PluginCreateRule pcr = new PluginCreateRule( Widget.class ); digester.addRule( "root/widget", pcr ); digester.addSetNext( "root/widget", "addChild" ); Container root = new Container(); digester.push( root );
// plugin base class. Digester digester = new Digester(); PluginRules rc = new PluginRules(); digester.setRules( rc ); PluginCreateRule pcr = new PluginCreateRule( Widget.class, Object.class ); digester.addRule( "root/widget", pcr ); digester.addSetNext( "root/widget", "addChild" ); Container root = new Container(); digester.push( root );
4243444546474849505152
{ // * tests that when a PluginCreateRule is defined with a default // class, that the default class is instantiated when no class // or id is specified in the xml file. Digester digester = new Digester(); PluginRules rc = new PluginRules(); digester.setRules( rc ); PluginCreateRule pcr = new PluginCreateRule( Widget.class, TextLabel.class ); digester.addRule( "root/widget", pcr ); digester.addSetNext( "root/widget", "addChild" );
919293949596979899100101
throws Exception { // * tests that when there is no default plugin, it is an error // not to have one of plugin-class or plugin-id specified Digester digester = new Digester(); PluginRules rc = new PluginRules(); digester.setRules( rc ); PluginCreateRule pcr = new PluginCreateRule( Widget.class ); digester.addRule( "root/widget", pcr ); digester.addSetNext( "root/widget", "addChild" );
128129130131132133134135136137138
throws Exception { // * tests that the default plugin must implement or extend the // plugin base class. Digester digester = new Digester(); PluginRules rc = new PluginRules(); digester.setRules( rc ); PluginCreateRule pcr = new PluginCreateRule( Widget.class, Object.class ); digester.addRule( "root/widget", pcr ); digester.addSetNext( "root/widget", "addChild" );