Author: brett
Date: Fri Jan  6 03:21:44 2006
New Revision: 366474

URL: http://svn.apache.org/viewcvs?rev=366474&view=rev
Log:
[MSITE-62] improve tests

Added:
    
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-relative-urls-multiple-resolved.xml
   (with props)
    
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-urls-file.xml
   (with props)
Modified:
    
maven/doxia/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
    
maven/doxia/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java

Modified: 
maven/doxia/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java?rev=366474&r1=366473&r2=366474&view=diff
==============================================================================
--- 
maven/doxia/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
 (original)
+++ 
maven/doxia/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
 Fri Jan  6 03:21:44 2006
@@ -339,19 +339,12 @@
 
                         if ( !mismatched && parentPath.startsWith( part ) )
                         {
-                            parentPath = parentPath.substring( part.length() );
-                            if ( parentPath.startsWith( "/" ) )
-                            {
-                                parentPath = parentPath.substring( 1 );
-                            }
+                            parentPath = parentPath.substring( part.length() + 
1 );
                         }
                         else
                         {
                             mismatched = true;
-                            if ( parentPath.length() > 0 )
-                            {
-                                prefix += "../";
-                            }
+                            prefix += "../";
                         }
                     }
                     prefix += parentPath;
@@ -380,7 +373,7 @@
             {
                 String path = host.substring( pathIndex );
                 host = host.substring( 0, pathIndex );
-                if ( host.length() == 0 && "file".equals( "protocol" ) )
+                if ( host.length() == 0 && "file".equals( protocol ) )
                 {
                     host = "localhost";
                 }

Modified: 
maven/doxia/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java?rev=366474&r1=366473&r2=366474&view=diff
==============================================================================
--- 
maven/doxia/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
 (original)
+++ 
maven/doxia/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
 Fri Jan  6 03:21:44 2006
@@ -356,6 +356,38 @@
         assertEquals( "Check result", resolvedModel, model );
     }
 
+    public void testResolvingAllSiteChildUrlsMultipleLevels()
+        throws IOException, XmlPullParserException
+    {
+        DecorationModel model = readModel( "subsite-urls.xml" );
+
+        assembler.resolvePaths( model, "http://maven.apache.org/banner/right"; 
);
+
+        DecorationModel resolvedModel = readModel( 
"subsite-relative-urls-multiple-resolved.xml" );
+        assertEquals( "Check result", resolvedModel, model );
+    }
+
+    public void testResolvingAllSiteChildFilesystemUrls()
+        throws IOException, XmlPullParserException
+    {
+        DecorationModel model = readModel( "subsite-urls-file.xml" );
+
+        assembler.resolvePaths( model, 
"file://localhost/www/maven.apache.org/foo" );
+
+        DecorationModel resolvedModel = readModel( 
"subsite-relative-urls-resolved.xml" );
+        assertEquals( "Check result", resolvedModel, model );
+    }
+
+    public void testResolvingEmptyDescriptor()
+        throws IOException, XmlPullParserException
+    {
+        DecorationModel model = readModel( "empty.xml" );
+        assembler.resolvePaths( model, "http://maven.apache.org"; );
+
+        DecorationModel resolvedModel = readModel( "empty.xml" );
+        assertEquals( "Check result", resolvedModel, model );
+    }
+
     private DecorationModel readModel( String name )
         throws IOException, XmlPullParserException
     {

Added: 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-relative-urls-multiple-resolved.xml
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-relative-urls-multiple-resolved.xml?rev=366474&view=auto
==============================================================================
--- 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-relative-urls-multiple-resolved.xml
 (added)
+++ 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-relative-urls-multiple-resolved.xml
 Fri Jan  6 03:21:44 2006
@@ -0,0 +1,46 @@
+<!--
+  ~ Copyright 2004-2006 The Apache Software Foundation.
+  ~
+  ~ Licensed 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.
+  ~
+  -->
+
+<project name="Parent Name">
+  <bannerLeft>
+    <name>The Jakarta Project</name>
+    <src>../../images/jakarta-logo.gif</src>
+    <href>../left</href>
+  </bannerLeft>
+  <bannerRight>
+    <name>Jakarta Commons Sandbox</name>
+    <src>../../commons/images/logo.png</src>
+    <href></href>
+  </bannerRight>
+
+  <poweredBy>
+    <logo name="Tomcat" href="../../tomcat" img="../../tomcat/logo.gif"/>
+  </poweredBy>
+
+  <body>
+    <breadcrumbs>
+      <item name="Apache" href="../../apache"/>
+    </breadcrumbs>
+
+    <links>
+      <item name="Bouncy Castle" href="../../bouncycastle/"/>
+    </links>
+
+    <menu name="Special" inherit="top">
+      <item name="Special" href="../../special/"/>
+    </menu>
+  </body>
+</project>

Propchange: 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-relative-urls-multiple-resolved.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-relative-urls-multiple-resolved.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-urls-file.xml
URL: 
http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-urls-file.xml?rev=366474&view=auto
==============================================================================
--- 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-urls-file.xml
 (added)
+++ 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-urls-file.xml
 Fri Jan  6 03:21:44 2006
@@ -0,0 +1,46 @@
+<!--
+  ~ Copyright 2004-2006 The Apache Software Foundation.
+  ~
+  ~ Licensed 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.
+  ~
+  -->
+
+<project name="Parent Name">
+  <bannerLeft>
+    <name>The Jakarta Project</name>
+    <src>file:///www/maven.apache.org/images/jakarta-logo.gif</src>
+    <href>file:///www/maven.apache.org/banner/left</href>
+  </bannerLeft>
+  <bannerRight>
+    <name>Jakarta Commons Sandbox</name>
+    <src>file:///www/maven.apache.org/commons/images/logo.png</src>
+    <href>file:///www/maven.apache.org/banner/right/</href>
+  </bannerRight>
+
+  <poweredBy>
+    <logo name="Tomcat" href="tomcat" 
img="file:///www/maven.apache.org/tomcat/logo.gif"/>
+  </poweredBy>
+
+  <body>
+    <breadcrumbs>
+      <item name="Apache" href="file:///www/maven.apache.org/apache"/>
+    </breadcrumbs>
+
+    <links>
+      <item name="Bouncy Castle" 
href="file:///www/maven.apache.org/bouncycastle/"/>
+    </links>
+
+    <menu name="Special" inherit="top">
+      <item name="Special" href="file:///www/maven.apache.org/special/"/>
+    </menu>
+  </body>
+</project>

Propchange: 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-urls-file.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/doxia/trunk/doxia-decoration-model/src/test/resources/subsite-urls-file.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision


Reply via email to