public void testInstanceOverride() throws Exception {
// Tests that using setPluginXXXX overrides behaviour for only
// that particular PluginCreateRule instance. Also tests that
// attributes can be in namespaces.
Digester digester = new Digester();
digester.setNamespaceAware(true);
PluginRules rc = new PluginRules();
digester.setRules(rc);
PluginDeclarationRule pdr = new PluginDeclarationRule();
digester.addRule("root/plugin", pdr);
// for plugins at pattern "root/widget", use xml attributes "id" and
// "class" in the custom namespace as the values for plugin id and
// class, not the default (and non-namespaced) values of
// "plugin-id" and "plugin-class".
PluginCreateRule widgetPluginRule = new PluginCreateRule(Widget.class);
widgetPluginRule.setPluginIdAttribute(
"http://jakarta.apache.org/digester/plugins", "id");
widgetPluginRule.setPluginClassAttribute(
"http://jakarta.apache.org/digester/plugins", "class");
digester.addRule("root/widget", widgetPluginRule);
digester.addSetNext("root/widget", "addWidget");
PluginCreateRule gadgetPluginRule = new PluginCreateRule(Widget.class);
digester.addRule("root/gadget", gadgetPluginRule);
digester.addSetNext("root/gadget", "addGadget");
MultiContainer root = new MultiContainer();
digester.push(root);
try {
digester.parse(
TestAll.getInputStream(this, "test7.xml"));
} catch(Exception e) {
throw e;
}