directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: rev 74437 - in incubator/directory/janus/trunk/script/src: java/org/apache/janus/script/xml test/org/apache/janus/script/xml
Date Tue, 16 Nov 2004 00:31:37 GMT
Author: vtence
Date: Mon Nov 15 16:31:35 2004
New Revision: 74437

Modified:
   incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java
   incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java
Log:
Made it easier to provide global XML files by reading at the element level

Modified: incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java
==============================================================================
--- incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java
(original)
+++ incubator/directory/janus/trunk/script/src/java/org/apache/janus/script/xml/Dom4JRealmBuilder.java
Mon Nov 15 16:31:35 2004
@@ -44,7 +44,7 @@
 public class Dom4JRealmBuilder implements RealmBuilder
 {
     private final RealmBuilderMonitor m_monitor;
-    private Document m_doc;
+    private Element m_root;
 
     public Dom4JRealmBuilder( Reader reader ) throws DocumentException
     {
@@ -54,15 +54,23 @@
     public Dom4JRealmBuilder( Reader reader, RealmBuilderMonitor monitor )
             throws DocumentException
     {
-        m_doc = readDocument( reader );
+        this( readDocument( reader ).getRootElement(), monitor );
+    }
+
+    public Dom4JRealmBuilder( Element element )
+    {
+        this( element, new NullRealmBuilderMonitor() );
+    }
+
+    public Dom4JRealmBuilder( Element element, RealmBuilderMonitor monitor )
+    {
+        m_root = element;
         m_monitor = monitor;
     }
 
     public void buildRealm( MutableRealm realm ) throws IOException
     {
-        Element root = m_doc.getRootElement();
-        Element users = root.element( "users" );
-        addUsers( realm, users );
+        addUsers( realm, m_root );
     }
 
     private void addUsers( MutableRealm realm, Element users )
@@ -89,7 +97,7 @@
         }
     }
 
-    private Document readDocument( Reader reader ) throws DocumentException
+    private static Document readDocument( Reader reader ) throws DocumentException
     {
         SAXReader xmlReader = new SAXReader();
         Document doc = xmlReader.read( reader );

Modified: incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java
==============================================================================
--- incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java
(original)
+++ incubator/directory/janus/trunk/script/src/test/org/apache/janus/script/xml/Dom4JRealmBuilderTest.java
Mon Nov 15 16:31:35 2004
@@ -38,7 +38,7 @@
         junit.textui.TestRunner.run( Dom4JRealmBuilderTest.class );
     }
 
-    public void testSimpleBuild() throws Exception
+    public void testAddsIdentitiesToRealm() throws Exception
     {
         Dom4JRealmBuilder builder = new Dom4JRealmBuilder( new StringReader( simpleRealm()
) );
 
@@ -55,10 +55,8 @@
     {
         String content = "<?xml version=\"1.0\"?>\n"
                 + "<realm>\n"
-                + "    <users>\n"
-                + "        <user username=\"john\" password=\"doe\"/>\n"
-                + "        <user username=\"jane\" password=\"doe\"/>\n"
-                + "    </users>\n"
+                + "    <user username=\"john\" password=\"doe\"/>\n"
+                + "    <user username=\"jane\" password=\"doe\"/>\n"
                 + "</realm>";
         return content;
     }
@@ -95,10 +93,8 @@
     {
         String content = "<?xml version=\"1.0\"?>\n"
                 + "<realm>\n"
-                + "    <users>\n"
-                + "        <user username=\"john\" password=\"doe\"/>\n"
-                + "        <user username=\"john\" password=\"doe\"/>\n"
-                + "    </users>\n"
+                + "    <user username=\"john\" password=\"doe\"/>\n"
+                + "    <user username=\"john\" password=\"doe\"/>\n"
                 + "</realm>";
         return content;
     }

Mime
View raw message