commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1072448 [1/2] - in /commons/sandbox/digester3/trunk/src/test: java/org/apache/commons/digester3/plugins/ resources/org/apache/commons/digester3/plugins/
Date Sat, 19 Feb 2011 21:46:11 GMT
Author: simonetripodi
Date: Sat Feb 19 21:46:09 2011
New Revision: 1072448

URL: http://svn.apache.org/viewvc?rev=1072448&view=rev
Log:
imported the 'plugins' tests, adapted and tidy version from /trunk - all tests pass, porting complete

Added:
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/AbstractPluginTestCase.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ConfigurablePluginAttributesModule.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Container.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ContainerCustomRules.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/DumperRule.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ObjectTestImpl.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Slider.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestConfigurablePluginAttributes.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDeclaration.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDefaultPlugin.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDelegate.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestInline.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestLocalRules.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRecursion.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRuleInfo.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2RuleInfo.java   (with props)
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Widget.java   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/ObjectTestImplRuleInfo.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test1.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test2.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test3.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test4a.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test4b.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test5a.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test5b.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test5c.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test6.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/test7.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/xmlrules1.xml   (with props)
    commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/xmlrules2.xml   (with props)

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/AbstractPluginTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/AbstractPluginTestCase.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/AbstractPluginTestCase.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/AbstractPluginTestCase.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,37 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.apache.commons.digester3.DigesterLoader.newLoader;
+
+import org.apache.commons.digester3.AbstractTestCase;
+import org.apache.commons.digester3.Digester;
+import org.apache.commons.digester3.RulesModule;
+
+/**
+ * 
+ */
+abstract class AbstractPluginTestCase extends AbstractTestCase {
+
+    protected final Digester newPluginDigester(RulesModule...rulesModules) {
+        return newLoader(rulesModules)
+            .setNamespaceAware(true)
+            .newDigester(new PluginRules());
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/AbstractPluginTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/AbstractPluginTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/AbstractPluginTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ConfigurablePluginAttributesModule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ConfigurablePluginAttributesModule.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ConfigurablePluginAttributesModule.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ConfigurablePluginAttributesModule.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,40 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+
+/**
+ * 
+ */
+final class ConfigurablePluginAttributesModule extends AbstractRulesModule {
+
+    @Override
+    protected void configure() {
+        forPattern("root/plugin").declarePlugin();
+        forPattern("root/widget")
+            .createPlugin().ofType(Widget.class)
+            .then()
+            .setNext("addWidget");
+        forPattern("root/gadget")
+            .createPlugin().ofType(Widget.class)
+            .then()
+            .setNext("addGadget");
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ConfigurablePluginAttributesModule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ConfigurablePluginAttributesModule.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ConfigurablePluginAttributesModule.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Container.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Container.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Container.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Container.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,37 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import java.util.List;
+import java.util.LinkedList;
+
+public class Container implements Widget {
+
+    private LinkedList<Widget> children = new LinkedList<Widget>();
+
+    public Container() {}
+
+    public void addChild(Widget child) {
+        children.add(child);
+    }
+
+    public List<Widget> getChildren() {
+        return children;
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Container.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Container.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Container.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ContainerCustomRules.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ContainerCustomRules.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ContainerCustomRules.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ContainerCustomRules.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,47 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.apache.commons.digester3.DigesterLoader.newLoader;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+
+public class ContainerCustomRules {
+
+    public static void addRules(final Digester digester, final String pattern) {
+        newLoader(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                // A Container object can have subtags called "widget" which
+                // define any object of type Widget. Because a Container is
+                // itself a widget, this allows us to build trees of objects.
+                forPattern(pattern + "/widget")
+                    .createPlugin().ofType(Widget.class)
+                    .then()
+                    .setNext("addChild");
+
+                // allow users to declare plugins under a container as well
+                forPattern(pattern + "/plugin").declarePlugin();
+            }
+
+        }).decorate(digester.getRules());
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ContainerCustomRules.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ContainerCustomRules.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ContainerCustomRules.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/DumperRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/DumperRule.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/DumperRule.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/DumperRule.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,60 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import org.apache.commons.digester3.Rule;
+import org.xml.sax.Attributes;
+
+/**
+ * Demonstrates the behaviour of the Delegate interface.
+ */
+public class DumperRule extends Rule {
+
+    @Override
+    public void begin(String namespace, String name, Attributes attributes) throws Exception {
+        System.out.print("<");
+        System.out.print(name);
+
+        int nAttributes = attributes.getLength();
+        for(int i=0; i<nAttributes; ++i) {
+            String key = attributes.getQName(i);
+            String value = attributes.getValue(i);
+            System.out.print(" ");
+            System.out.print(key);
+            System.out.print("=");
+            System.out.print("'");
+            System.out.print(value);
+            System.out.print("'");
+        }
+        System.out.println(">");
+    }
+
+    @Override
+    public void body(String namespace, String name, String text) throws Exception {
+        System.out.print(text);
+    }
+
+    @Override
+    public void end(String namespace, String name)
+    throws Exception {
+        System.out.print("</");
+        System.out.print(name);
+        System.out.println(">");
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/DumperRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/DumperRule.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/DumperRule.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ObjectTestImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ObjectTestImpl.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ObjectTestImpl.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ObjectTestImpl.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,38 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+/**
+ * Test harness object for holding results of digestion.
+ */
+public class ObjectTestImpl {
+
+    private String value;
+
+    public ObjectTestImpl() {
+    }
+
+    public void setValue(String val) {
+        value = val;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ObjectTestImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ObjectTestImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/ObjectTestImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Slider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Slider.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Slider.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Slider.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,98 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.apache.commons.digester3.DigesterLoader.newLoader;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+
+public class Slider implements Widget {
+
+    private String label = "nolabel";
+
+    private int min = 0;
+
+    private int max = 0;
+
+    // define rules on this class
+    public static void addRules(final Digester digester, final String pattern) {
+        newLoader(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern(pattern).setProperties();
+                forPattern(pattern + "/min")
+                    .callMethod("setMin").withParamTypes(Integer.class).usingElementBodyAsArgument();
+                forPattern(pattern + "/max")
+                    .callMethod("setMax").withParamTypes(Integer.class).usingElementBodyAsArgument();
+            }
+
+        }).decorate(digester.getRules());
+    }
+
+    // define different rules on this class
+    public static void addRangeRules(final Digester digester, final String pattern) {
+        newLoader(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                // note: deliberately no addSetProperties rule
+                forPattern(pattern + "/range")
+                    .callMethod("setRange").withParamTypes(Integer.class, Integer.class)
+                    .then()
+                    .callParam().ofIndex(0).fromAttribute("min")
+                    .then()
+                    .callParam().ofIndex(1).fromAttribute("max");
+            }
+
+        }).decorate(digester.getRules());
+    }
+
+    public Slider() {}
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+    public void setMin(int min) {
+        this.min = min;
+    }
+
+    public int getMin() {
+        return min;
+    }
+
+    public void setMax(int max) {
+        this.max = max;
+    }
+
+    public int getMax() {
+        return max;
+    }
+
+    public void setRange(int min, int max) {
+        this.min = min;
+        this.max = max;
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Slider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Slider.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Slider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestConfigurablePluginAttributes.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestConfigurablePluginAttributes.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestConfigurablePluginAttributes.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestConfigurablePluginAttributes.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,192 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.apache.commons.digester3.DigesterLoader.newLoader;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+import org.junit.Test;
+
+/**
+ * Test cases for functionality which sets what xml attributes specify
+ * the plugin class or plugin declaration id.
+ */
+public class TestConfigurablePluginAttributes extends AbstractPluginTestCase {
+
+    @Test
+    public void testDefaultBehaviour() throws Exception {
+        // tests that by default the attributes used are 
+        // named "plugin-class" and "plugin-id"
+
+        Digester digester = newPluginDigester(new ConfigurablePluginAttributesModule());
+
+        MultiContainer root = new MultiContainer();
+        digester.push(root);
+
+        digester.parse(getInputStream("test7.xml"));
+
+        List<Widget> widgets = root.getWidgets();
+        assertNotNull(widgets);
+        assertEquals(4, widgets.size());
+
+        assertEquals(TextLabel.class, widgets.get(0).getClass());
+        assertEquals(TextLabel.class, widgets.get(1).getClass());
+        assertEquals(TextLabel.class, widgets.get(2).getClass());
+        assertEquals(TextLabel.class, widgets.get(3).getClass());
+
+        List<Widget> gadgets = root.getGadgets();
+        assertNotNull(gadgets);
+        assertEquals(4, gadgets.size());
+
+        assertEquals(TextLabel.class, gadgets.get(0).getClass());
+        assertEquals(TextLabel.class, gadgets.get(1).getClass());
+        assertEquals(TextLabel.class, gadgets.get(2).getClass());
+        assertEquals(TextLabel.class, gadgets.get(3).getClass());
+    }
+
+    @Test
+    public void testGlobalOverride() throws Exception {
+        // Tests that using setDefaultPluginXXXX overrides behaviour for all
+        // PluginCreateRule instances. Also tests specifying attributes
+        // with "null" for namespace (ie attributes not in any namespace).
+        //
+        // note that in order not to screw up all other tests, we need
+        // to reset the global names after we finish here!
+
+        PluginRules rc = new PluginRules();
+        rc.setPluginIdAttribute(null, "id");
+        rc.setPluginClassAttribute(null, "class");
+
+        Digester digester = newLoader(new ConfigurablePluginAttributesModule())
+            .setNamespaceAware(true)
+            .newDigester(rc);
+
+        MultiContainer root = new MultiContainer();
+        digester.push(root);
+
+        digester.parse(getInputStream("test7.xml"));
+
+        List<Widget> widgets = root.getWidgets();
+        assertNotNull(widgets);
+        assertEquals(4, widgets.size());
+
+        assertEquals(Slider.class, widgets.get(0).getClass());
+        assertEquals(Slider.class, widgets.get(1).getClass());
+        assertEquals(Slider.class, widgets.get(2).getClass());
+        assertEquals(Slider.class, widgets.get(3).getClass());
+
+        List<Widget> gadgets = root.getGadgets();
+        assertNotNull(gadgets);
+        assertEquals(4, gadgets.size());
+
+        assertEquals(Slider.class, gadgets.get(0).getClass());
+        assertEquals(Slider.class, gadgets.get(1).getClass());
+        assertEquals(Slider.class, gadgets.get(2).getClass());
+        assertEquals(Slider.class, gadgets.get(3).getClass());
+    }
+
+    @Test
+    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 = newPluginDigester(new AbstractRulesModule() {
+
+                @Override
+                protected void configure() {
+                    forPattern("root/plugin").declarePlugin();
+
+                    // 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".
+                    forPattern("root/widget")
+                        .createPlugin().ofType(Widget.class)
+                            .setPluginIdAttribute("http://commons.apache.org/digester/plugins", "id")
+                            .setPluginClassAttribute("http://commons.apache.org/digester/plugins", "class")
+                        .then()
+                        .setNext("addWidget");
+
+                    forPattern("root/gadget")
+                        .createPlugin().ofType(Widget.class)
+                        .then()
+                        .setNext("addGadget");
+                }
+
+            });
+
+        MultiContainer root = new MultiContainer();
+        digester.push(root);
+
+        digester.parse(getInputStream("test7.xml"));
+
+        List<Widget> widgets = root.getWidgets();
+        assertNotNull(widgets);
+        assertEquals(4, widgets.size());
+
+        assertEquals(TextLabel2.class, widgets.get(0).getClass());
+        assertEquals(TextLabel2.class, widgets.get(1).getClass());
+        assertEquals(TextLabel2.class, widgets.get(2).getClass());
+        assertEquals(TextLabel2.class, widgets.get(3).getClass());
+
+        List<Widget> gadgets = root.getGadgets();
+        assertNotNull(gadgets);
+        assertEquals(4, gadgets.size());
+
+        assertEquals(TextLabel.class, gadgets.get(0).getClass());
+        assertEquals(TextLabel.class, gadgets.get(1).getClass());
+        assertEquals(TextLabel.class, gadgets.get(2).getClass());
+        assertEquals(TextLabel.class, gadgets.get(3).getClass());
+    }
+
+    // inner classes used for testing
+
+    public static class MultiContainer {
+
+        private LinkedList<Widget> widgets = new LinkedList<Widget>();
+
+        private LinkedList<Widget> gadgets = new LinkedList<Widget>();
+
+        public MultiContainer() {}
+
+        public void addWidget(Widget child) {
+            widgets.add(child);
+        }
+
+        public List<Widget> getWidgets() {
+            return widgets;
+        }
+
+        public void addGadget(Widget child) {
+            gadgets.add(child);
+        }
+
+        public List<Widget> getGadgets() {
+            return gadgets;
+        }
+
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestConfigurablePluginAttributes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestConfigurablePluginAttributes.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestConfigurablePluginAttributes.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDeclaration.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDeclaration.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDeclaration.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDeclaration.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,72 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+import org.junit.Test;
+
+/**
+ * Test cases for basic PluginDeclarationRule behaviour.
+ */
+public class TestDeclaration extends AbstractPluginTestCase {
+
+    @Test
+    public void testPredeclaration() throws Exception {
+        // * tests that rules can be declared via a PluginDeclarationRule
+
+        Digester digester = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("root/plugin").declarePlugin();
+                forPattern("root/widget")
+                    .createPlugin().ofType(Widget.class)
+                    .then()
+                    .setNext("addChild");
+            }
+
+        });
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test3.xml"));
+
+        Object child;
+        List<Widget> children = root.getChildren();
+        assertNotNull(children);
+        assertEquals(2, children.size());
+
+        child = children.get(0);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        assertEquals("label1", ((TextLabel)child).getLabel());
+
+        child = children.get(1);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        assertEquals("label2", ((TextLabel)child).getLabel());
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDeclaration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDeclaration.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDeclaration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDefaultPlugin.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDefaultPlugin.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDefaultPlugin.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDefaultPlugin.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,144 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+import org.junit.Test;
+import org.xml.sax.SAXParseException;
+
+public class TestDefaultPlugin extends AbstractPluginTestCase {
+
+    @Test
+    public void testDefaultPlugins1() throws Exception {
+        // * 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 = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("root/widget")
+                    .createPlugin().ofType(Widget.class).usingDefaultPluginClass(TextLabel.class)
+                    .then()
+                    .setNext("addChild");
+            }
+
+        });
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test2.xml"));
+
+        Object child;
+        List<Widget> children = root.getChildren();
+        assertNotNull(children);
+        assertEquals(3, children.size());
+
+        child = children.get(0);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        TextLabel label1 = (TextLabel) child;
+        assertEquals("label1", label1.getLabel());
+
+        child = children.get(1);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        TextLabel label2 = (TextLabel) child;
+        assertEquals("label2", label2.getLabel());
+
+        child = children.get(2);
+        assertNotNull(child);
+        assertEquals(Slider.class, child.getClass());
+        Slider slider1 = (Slider) child;
+        assertEquals("slider1", slider1.getLabel());
+    }
+
+    public void testDefaultPlugins2() 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 = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("root/widget")
+                    .addRule(new PluginCreateRule(Widget.class))
+                    .then()
+                    .setNext("addChild");
+            }
+
+        });
+        PluginRules rc = new PluginRules();
+        digester.setRules(rc);
+
+        Container root = new Container();
+        digester.push(root);
+
+        Exception exception = null;
+        try {
+            digester.parse(getInputStream("test2.xml"));
+        } catch(Exception e) {
+            exception = e;
+        }
+
+        assertNotNull(exception);
+        assertEquals(SAXParseException.class, exception.getClass());
+        assertEquals(
+            PluginInvalidInputException.class, 
+            ((SAXParseException)exception).getException().getClass());
+    }
+
+    public void testDefaultPlugins3() throws Exception {
+        // * tests that the default plugin must implement or extend the
+        //   plugin base class.
+        Digester digester = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("root/widget")
+                    .addRule(new PluginCreateRule(Widget.class, Object.class))
+                    .then()
+                    .setNext("addChild");
+            }
+
+        });
+
+        Container root = new Container();
+        digester.push(root);
+
+        Exception exception = null;
+        try {
+            digester.parse(getInputStream("test2.xml"));
+        } catch(Exception e) {
+            exception = e;
+        }
+
+        assertNotNull(exception);
+        assertEquals(SAXParseException.class, exception.getClass());
+        assertEquals(
+            PluginConfigurationException.class, 
+            ((SAXParseException)exception).getException().getClass());
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDefaultPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDefaultPlugin.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDefaultPlugin.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDelegate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDelegate.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDelegate.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDelegate.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,52 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+import org.junit.Test;
+
+/**
+ * Test cases for Delegate behaviour.
+ */
+public class TestDelegate extends AbstractPluginTestCase {
+
+    @Test
+    public void testDummy() {
+        // it is an error if a TestSuite doesn't have at least one test,
+        // so here is one...
+    }
+
+    public void ignoretestDelegate() throws Exception {
+        // this method tests the Delegate functionality by capturing all
+        // data below the specified pattern, and printing it to stdout.
+        // I can't for the moment think how to turn this into a unit test,
+        // so this test is disabled.
+        Digester digester = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("root").addRule(new DumperRule());
+            }
+
+        });
+
+        digester.parse(getInputStream("test1.xml"));
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDelegate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDelegate.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestDelegate.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestInline.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestInline.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestInline.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestInline.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,125 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test cases for declaration of plugin classes "inline" (ie by specifying
+ * plugin-class).
+ */
+public class TestInline extends AbstractPluginTestCase {
+
+    private Digester digester;
+
+    @Before
+    public void setUp() throws Exception {
+        digester = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("root/widget")
+                    .createPlugin().ofType(Widget.class)
+                    .then()
+                    .setNext("addChild");
+            }
+
+        });
+    }
+
+    @After
+    public void tearDown() {
+        this.digester = null;
+    }
+
+    @Test
+    public void testInlineDeclaration() throws Exception {
+        // * tests that plugins can be specified by class, and that the
+        //   correct class gets loaded.
+        // * tests that autosetproperties works
+        // * tests that multiple different classes can be loaded via the
+        //   same plugin rule (ie at the same pattern).
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test1.xml"));
+
+        Object child;
+        List<Widget> children = root.getChildren();
+        assertNotNull(children);
+        assertEquals(2, children.size());
+
+        child = children.get(0);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        TextLabel label1 = (TextLabel) child;
+        assertEquals("anonymous", label1.getId());
+        assertEquals("1", label1.getLabel());
+
+        child = children.get(1);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        TextLabel label2 = (TextLabel) child;
+        assertEquals("L1", label2.getId());
+        assertEquals("2", label2.getLabel());
+    }
+
+    @Test
+    public void testLeadingSlash() throws Exception {
+        // Tests that PluginRules handles patterns with a leading slash.
+        // 
+        // This test doesn't really belong in this class. If a separate test 
+        // case class is created for PluginRules, then this method should be
+        // moved there.
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test1.xml"));
+
+        Object child;
+        List<Widget> children = root.getChildren();
+        assertNotNull(children);
+        assertEquals(2, children.size());
+
+        child = children.get(0);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        TextLabel label1 = (TextLabel) child;
+        assertEquals("anonymous", label1.getId());
+        assertEquals("1", label1.getLabel());
+
+        child = children.get(1);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        TextLabel label2 = (TextLabel) child;
+        assertEquals("L1", label2.getId());
+        assertEquals("2", label2.getLabel());
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestInline.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestInline.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestInline.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestLocalRules.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestLocalRules.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestLocalRules.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestLocalRules.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,149 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test cases for defining custom rules on the plugin class itself.
+ */
+public class TestLocalRules extends AbstractPluginTestCase {
+
+    private Digester digester;
+
+    @Before
+    public void setUp() throws Exception {
+        digester = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("root/plugin").declarePlugin();
+                forPattern("root/widget")
+                    .createPlugin().ofType(Widget.class)
+                    .then()
+                    .setNext("addChild");
+            }
+
+        });
+    }
+
+    @After
+    public void tearDown() {
+        this.digester = null;
+    }
+
+    @Test
+    public void testLocalRules() throws Exception {
+        // * tests that the plugin class can define an addRules method,
+        //   which gets detected and executed.
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test4a.xml"));
+
+        Object child;
+        List<Widget> children = root.getChildren();
+        assertNotNull(children);
+        assertEquals(3, children.size());
+
+        // min/max rules should be in effect
+        // setproperties should be in effect
+        child = children.get(0);
+        assertNotNull(child);
+        assertEquals(Slider.class, child.getClass());
+        Slider slider1 = (Slider) child;
+        assertEquals("slider1", slider1.getLabel());
+        assertEquals(1, slider1.getMin());
+        assertEquals(2, slider1.getMax());
+
+        // range rules should not be in effect
+        // setproperties should be in effect
+        child = children.get(1);
+        assertNotNull(child);
+        assertEquals(Slider.class, child.getClass());
+        Slider slider2 = (Slider) child;
+        assertEquals("slider2", slider2.getLabel());
+        assertEquals(0, slider2.getMin());
+        assertEquals(0, slider2.getMax());
+
+        // setproperties should be working on text label
+        child = children.get(2);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        assertEquals("text1", ((TextLabel)child).getLabel());
+    }
+
+    @Test
+    public void testNonStandardLocalRules() throws Exception {
+        // * tests that using PluginDeclarationRule to declare an alternate
+        //   rule method name invokes that alternate method instead (the
+        //   input xml specifies that a method other than addRules is to
+        //   be used)
+        // * tests that if a rule method is defined, then a SetProperties
+        //   rule is not automatically added.
+        // * tests that a SetProperties rule applying to one class doesn't
+        //   apply to different plugin classes mounted at the same rule.
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test4b.xml"));
+
+        Object child;
+        List<Widget> children = root.getChildren();
+        assertNotNull(children);
+        assertEquals(3, children.size());
+
+        // min/max rules should not  be in effect
+        // setproperties should not be in effect
+        child = children.get(0);
+        assertNotNull(child);
+        assertEquals(Slider.class, child.getClass());
+        Slider slider1 = (Slider) child;
+        assertEquals("nolabel", slider1.getLabel());
+        assertEquals(0, slider1.getMin());
+        assertEquals(0, slider1.getMax());
+
+        // range rules should be in effect
+        // setproperties should not be in effect
+        child = children.get(1);
+        assertNotNull(child);
+        assertEquals(Slider.class, child.getClass());
+        Slider slider2 = (Slider) child;
+        assertEquals("nolabel", slider2.getLabel());
+        assertEquals(10, slider2.getMin());
+        assertEquals(20, slider2.getMax());
+
+        // setproperties should be working on text label
+        child = children.get(2);
+        assertNotNull(child);
+        assertEquals(TextLabel.class, child.getClass());
+        assertEquals("text1", ((TextLabel)child).getLabel());
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestLocalRules.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestLocalRules.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestLocalRules.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRecursion.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRecursion.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRecursion.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRecursion.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,74 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+import org.junit.Test;
+
+/**
+ * Test cases for plugins with custom rules which include PluginCreateRule
+ * instances, allowing recursive datastructures to be processed.
+ */
+public class TestRecursion extends AbstractPluginTestCase {
+
+    @Test
+    public void testRecursiveRules() throws Exception {
+        // * tests that a rule can declare custom PluginCreateRules
+        //   that allow it to plug in instances of itself below
+        //   itself.
+
+        Digester digester = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("*/plugin").declarePlugin();
+                forPattern("root/widget")
+                    .createPlugin().ofType(Widget.class)
+                    .then()
+                    .setNext("addChild");
+            }
+
+        });
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test6.xml"));
+
+        int nDescendants = countWidgets(root);
+        assertEquals(10, nDescendants);
+    }
+
+    private int countWidgets(Container c) {
+        List<Widget> l = c.getChildren();
+        int sum = 0;
+        for(Widget w : l) {
+            ++sum; 
+            if (w instanceof Container) {
+                sum += countWidgets((Container) w);
+            }
+        }
+        return sum;
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRecursion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRecursion.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRecursion.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRuleInfo.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRuleInfo.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRuleInfo.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRuleInfo.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,137 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test cases for the declaration of custom rules for a plugin using
+ * a separate class to define the rules.
+ */
+public class TestRuleInfo extends AbstractPluginTestCase {
+
+    private Digester digester;
+
+    @Before
+    public void setUp() throws Exception {
+        digester = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("root/plugin").declarePlugin();
+                forPattern("root/widget")
+                    .createPlugin().ofType(Widget.class)
+                    .then()
+                    .setNext("addChild");
+            }
+
+        });
+    }
+
+    @After
+    public void tearDown() {
+        this.digester = null;
+    }
+
+    @Test
+    public void testRuleInfoExplicitClass() throws Exception {
+        // * tests that custom rules can be declared on a 
+        //   separate class by explicitly declaring the rule class.
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test5a.xml"));
+
+        Object child;
+        List<Widget> children = root.getChildren();
+        assertNotNull(children);
+        assertEquals(1, children.size());
+
+        child = children.get(0);
+        assertNotNull(child);
+        assertEquals(TextLabel2.class, child.getClass());
+        TextLabel2 label = (TextLabel2) child;
+
+        // id should not be mapped, label should
+        assertEquals("anonymous", label.getId());
+        assertEquals("std label", label.getLabel());
+    }
+
+    @Test
+    public void testRuleInfoExplicitMethod() throws Exception {
+        // * tests that custom rules can be declared on a 
+        //   separate class by explicitly declaring the rule class.
+        //   and explicitly declaring the rule method name.
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test5b.xml"));
+
+        Object child;
+        List<Widget> children = root.getChildren();
+        assertNotNull(children);
+        assertEquals(1, children.size());
+
+        child = children.get(0);
+        assertNotNull(child);
+        assertEquals(TextLabel2.class, child.getClass());
+        TextLabel2 label = (TextLabel2) child;
+
+        // id should not be mapped, altlabel should
+        assertEquals("anonymous", label.getId());
+        assertEquals("alt label", label.getLabel());
+    }
+
+    @Test
+    public void testRuleInfoAutoDetect() throws Exception {
+        // * tests that custom rules can be declared on a 
+        //   separate class with name {plugin-class}RuleInfo,
+        //   and they are automatically detected and loaded.
+
+        Container root = new Container();
+        digester.push(root);
+
+        digester.parse(getInputStream("test5c.xml"));
+
+        Object child;
+        List<Widget> children = root.getChildren();
+        assertNotNull(children);
+        assertEquals(1, children.size());
+
+        child = children.get(0);
+        assertNotNull(child);
+        assertEquals(TextLabel2.class, child.getClass());
+        TextLabel2 label = (TextLabel2) child;
+
+        // id should not be mapped, label should
+        assertEquals("anonymous", label.getId());
+        assertEquals("std label", label.getLabel());
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRuleInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRuleInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestRuleInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,128 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.StringReader;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test cases for the declaration of custom rules for a plugin using
+ * xmlrules format files.
+ */
+public class TestXmlRuleInfo extends AbstractPluginTestCase {
+
+    private Digester digester;
+
+    @Before
+    public void setUp() throws Exception {
+        digester = newPluginDigester(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern("root/plugin").declarePlugin();
+                forPattern("root/object").createPlugin().ofType(ObjectTestImpl.class);
+            }
+
+        });
+    }
+
+    @After
+    public void tearDown() {
+        this.digester = null;
+    }
+
+    @Test
+    public void testXmlRuleInfoExplicitFile() throws Exception {
+        // * tests that custom rules can be declared on a 
+        //   separate class by explicitly declaring a file containing
+        //   the rules, using a relative or absolute path name.
+
+        StringBuffer input = new StringBuffer();
+        input.append("<root>");
+        input.append(" <plugin");
+        input.append("  id='testobject'"); 
+        input.append("  class='org.apache.commons.digester3.plugins.ObjectTestImpl'");
+        input.append("  file='src/test/resources/org/apache/commons/digester3/plugins/xmlrules1.xml'");
+        input.append("  />");
+        input.append("  <object plugin-id='testobject' />");
+        input.append("</root>");
+
+        digester.parse(new StringReader(input.toString()));
+
+        Object root = digester.getRoot();
+        assertEquals(ObjectTestImpl.class, root.getClass());
+        ObjectTestImpl testObject = (ObjectTestImpl) root;
+        assertEquals("xmlrules1", testObject.getValue());
+    }
+
+    @Test
+    public void testXmlRuleInfoExplicitResource() throws Exception {
+        // * tests that custom rules can be declared on a 
+        //   separate class by explicitly declaring the rule class.
+        //   and explicitly declaring a file which is somewhere in the 
+        //   classpath.
+
+        StringBuffer input = new StringBuffer();
+        input.append("<root>");
+        input.append(" <plugin");
+        input.append("  id='testobject'"); 
+        input.append("  class='org.apache.commons.digester3.plugins.ObjectTestImpl'");
+        input.append("  resource='org/apache/commons/digester3/plugins/xmlrules2.xml'");
+        input.append("  />");
+        input.append("  <object plugin-id='testobject' />");
+        input.append("</root>");
+
+        digester.parse(new StringReader(input.toString()));
+
+        Object root = digester.getRoot();
+        assertEquals(ObjectTestImpl.class, root.getClass());
+        ObjectTestImpl testObject = (ObjectTestImpl) root;
+        assertEquals("xmlrules2", testObject.getValue());
+    }
+
+    @Test
+    public void testXmlRuleImplicitResource() throws Exception {
+        // * tests that custom rules can be declared on a 
+        //   separate class by explicitly declaring the rule class.
+        //   and explicitly declaring a file which is somewhere in the 
+        //   classpath.
+
+        StringBuffer input = new StringBuffer();
+        input.append("<root>");
+        input.append(" <plugin");
+        input.append("  id='testobject'"); 
+        input.append("  class='org.apache.commons.digester3.plugins.ObjectTestImpl' />");
+        input.append("  <object plugin-id='testobject' />");
+        input.append("</root>");
+
+        digester.parse(new StringReader(input.toString()));
+
+        Object root = digester.getRoot();
+        assertEquals(ObjectTestImpl.class, root.getClass());
+        ObjectTestImpl testObject = (ObjectTestImpl) root;
+        assertEquals("xmlrules-ruleinfo", testObject.getValue());
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,44 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+public class TextLabel implements Widget {
+
+    private String id = "anonymous";
+
+    private String label = "nolabel";
+
+    public TextLabel() {}
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,44 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+public class TextLabel2 implements Widget {
+
+    private String id = "anonymous";
+
+    private String label = "nolabel";
+
+    public TextLabel2() {}
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2RuleInfo.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2RuleInfo.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2RuleInfo.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2RuleInfo.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,53 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+import static org.apache.commons.digester3.DigesterLoader.newLoader;
+
+import org.apache.commons.digester3.AbstractRulesModule;
+import org.apache.commons.digester3.Digester;
+
+public class TextLabel2RuleInfo {
+
+    // define default rules
+    public static void addRules(Digester digester, final String pattern) {
+        newLoader(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern(pattern + "/id").callMethod("setId").usingElementBodyAsArgument();
+                forPattern(pattern + "/label").callMethod("setLabel").usingElementBodyAsArgument();
+            }
+
+        }).decorate(digester.getRules());
+    }
+
+    // define different rules on this class
+    public static void addAltRules(Digester digester, final String pattern) {
+        newLoader(new AbstractRulesModule() {
+
+            @Override
+            protected void configure() {
+                forPattern(pattern + "/alt-id").callMethod("setId").usingElementBodyAsArgument();
+                forPattern(pattern + "/alt-label").callMethod("setLabel").usingElementBodyAsArgument();
+            }
+
+        }).decorate(digester.getRules());
+    }
+
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2RuleInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2RuleInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TextLabel2RuleInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Widget.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Widget.java?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Widget.java (added)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Widget.java Sat Feb 19 21:46:09 2011
@@ -0,0 +1,21 @@
+/* $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.plugins;
+
+public interface Widget {
+}

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Widget.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Widget.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/Widget.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/ObjectTestImplRuleInfo.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/ObjectTestImplRuleInfo.xml?rev=1072448&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/ObjectTestImplRuleInfo.xml (added)
+++ commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/ObjectTestImplRuleInfo.xml Sat Feb 19 21:46:09 2011
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE digester-rules PUBLIC "-//Apache Commons //DTD digester-rules XML V1.0//EN" "http://commons.apache.org/digester/dtds/digester-rules.dtd">
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<digester-rules>
+    <pattern value="">
+        <call-method-rule methodname="setValue" paramcount="1" />
+        <object-param-rule paramnumber="0" type="java.lang.String" value="xmlrules-ruleinfo" />
+    </pattern>
+</digester-rules>

Propchange: commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/ObjectTestImplRuleInfo.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/ObjectTestImplRuleInfo.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: commons/sandbox/digester3/trunk/src/test/resources/org/apache/commons/digester3/plugins/ObjectTestImplRuleInfo.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message