You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/05/20 21:21:57 UTC

svn commit: r1125518 - /commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/NamespaceSnapshotTestCase.java

Author: simonetripodi
Date: Fri May 20 19:21:57 2011
New Revision: 1125518

URL: http://svn.apache.org/viewvc?rev=1125518&view=rev
Log:
NamespaceSnapshotTestCase migrated to Digester EDSL

Modified:
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/NamespaceSnapshotTestCase.java

Modified: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/NamespaceSnapshotTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/NamespaceSnapshotTestCase.java?rev=1125518&r1=1125517&r2=1125518&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/NamespaceSnapshotTestCase.java (original)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/NamespaceSnapshotTestCase.java Fri May 20 19:21:57 2011
@@ -18,16 +18,16 @@
 
 package org.apache.commons.digester3;
 
+import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.digester3.Digester;
-import org.apache.commons.digester3.Rule;
+import org.apache.commons.digester3.binder.AbstractRulesModule;
+import org.apache.commons.digester3.binder.RuleProvider;
 import org.junit.Test;
 import org.xml.sax.Attributes;
 
@@ -54,6 +54,20 @@ public class NamespaceSnapshotTestCase
             Map<String, String> namespaces = d.getCurrentNamespaces();
             ( (NamespacedBox) d.peek() ).setNamespaces( namespaces );
         }
+
+        public static class Provider implements RuleProvider<NamespaceSnapshotRule>
+        {
+
+            /**
+             * {@inheritDoc}
+             */
+            public NamespaceSnapshotRule get()
+            {
+                return new NamespaceSnapshotRule();
+            }
+
+        }
+
     }
 
     /**
@@ -64,15 +78,27 @@ public class NamespaceSnapshotTestCase
         throws Exception
     {
 
-        Digester digester = new Digester();
-        digester.setNamespaceAware( true );
-        digester.addObjectCreate( "box", NamespacedBox.class );
-        digester.addSetProperties( "box" );
-        digester.addRule( "box", new NamespaceSnapshotRule() );
-        digester.addObjectCreate( "box/subBox", NamespacedBox.class );
-        digester.addSetProperties( "box/subBox" );
-        digester.addRule( "box/subBox", new NamespaceSnapshotRule() );
-        digester.addSetNext( "box/subBox", "addChild" );
+        Digester digester = newLoader( new AbstractRulesModule()
+        {
+
+            @Override
+            protected void configure()
+            {
+                forPattern( "box" ).createObject().ofType( NamespacedBox.class )
+                    .then()
+                    .setProperties()
+                    .then()
+                    .addRuleCreatedBy( new NamespaceSnapshotRule.Provider() );
+                forPattern( "box/subBox" ).createObject().ofType( NamespacedBox.class )
+                    .then()
+                    .setProperties()
+                    .then()
+                    .addRuleCreatedBy( new NamespaceSnapshotRule.Provider() )
+                    .then()
+                    .setNext( "addChild" );
+            }
+
+        }).setNamespaceAware( true ).newDigester();
 
         NamespacedBox root = digester.parse( getInputStream( "Test11.xml" ) );