maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r367102 - in /maven/doxia/trunk/doxia-decoration-model/src: main/java/org/apache/maven/doxia/site/decoration/inheritance/ test/java/org/apache/maven/doxia/site/decoration/inheritance/
Date Sun, 08 Jan 2006 21:46:34 GMT
Author: brett
Date: Sun Jan  8 13:46:26 2006
New Revision: 367102

URL: http://svn.apache.org/viewcvs?rev=367102&view=rev
Log:
move null check to the right place and add tests

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=367102&r1=367101&r2=367102&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
Sun Jan  8 13:46:26 2006
@@ -143,13 +143,18 @@
 
     private String resolvePath( String href, String prefix, String baseUrl )
     {
-        String relativePath = getParentPrefix( href, baseUrl );
-
-        if ( relativePath.startsWith( "/" ) )
+        String path = null;
+        if ( href != null )
         {
-            relativePath = relativePath.substring( 1 );
+            String relativePath = getParentPrefix( href, baseUrl );
+
+            if ( relativePath.startsWith( "/" ) )
+            {
+                relativePath = relativePath.substring( 1 );
+            }
+            path = PathTool.calculateLink( relativePath, prefix );
         }
-        return PathTool.calculateLink( relativePath, prefix );
+        return path;
     }
 
     private void assembleCustomInheritance( DecorationModel child, DecorationModel parent
)
@@ -330,16 +335,6 @@
 
     private static String getParentPrefix( String parentUrl, String childUrl )
     {
-        if ( parentUrl == null )
-        {
-            parentUrl = "";
-        }
-
-        if ( childUrl == null )
-        {
-            childUrl = "";
-        }
-
         String prefix = parentUrl;
 
         if ( childUrl.startsWith( parentUrl ) )
@@ -357,7 +352,8 @@
         {
             prefix = getRelativePath( parentUrl, childUrl );
         }
-/* [MSITE-62] This is to test the ../ relative paths, which I am inclined not to use
+/*
+        // [MSITE-62] This is to test the ../ relative paths, which I am inclined not to
use
         else
         {
             String[] parentSplit = splitUrl( parentUrl );

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=367102&r1=367101&r2=367102&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
Sun Jan  8 13:46:26 2006
@@ -17,6 +17,7 @@
  */
 
 import junit.framework.TestCase;
+import org.apache.maven.doxia.site.decoration.Banner;
 import org.apache.maven.doxia.site.decoration.Body;
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 import org.apache.maven.doxia.site.decoration.LinkItem;
@@ -448,6 +449,41 @@
         assembler.resolvePaths( model, "http://foo.apache.org" );
         assertEquals( "Check size", 1, model.getBody().getBreadcrumbs().size() );
         assertEquals( "Check item", createLinkItem( "Foo", "" ), model.getBody().getBreadcrumbs().get(
0 ) );
+    }
+
+    public void testBannerWithoutHref()
+    {
+        DecorationModel model = new DecorationModel();
+        model.setBody( new Body() );
+
+        Banner banner = createBanner( "Left", null, "/images/src.gif", "alt" );
+
+        model.setBannerLeft( banner );
+
+        assembler.resolvePaths( model, "http://foo.apache.org" );
+
+        assertEquals( "Check banner", createBanner( "Left", null, "images/src.gif", "alt"
), model.getBannerLeft() );
+    }
+
+    public void testLogoWithoutImage()
+    {
+        // This should actually be validated in the model, it doesn't really make sense
+        DecorationModel model = new DecorationModel();
+        model.setBody( new Body() );
+        model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", null ) );
+        assembler.resolvePaths( model, "http://foo.apache.org" );
+        assertEquals( "Check size", 1, model.getPoweredBy().size() );
+        assertEquals( "Check item", createLogo( "Foo", "http://foo.apache.org", null ), model.getPoweredBy().get(
0 ) );
+    }
+
+    private static Banner createBanner( String name, String href, String src, String alt
)
+    {
+        Banner banner = new Banner();
+        banner.setName( name );
+        banner.setHref( href );
+        banner.setSrc( src );
+        banner.setAlt( alt );
+        return banner;
     }
 
     private Logo createLogo( String name, String href, String img )



Mime
View raw message