maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r1058092 - /maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
Date Wed, 12 Jan 2011 11:48:19 GMT
Author: ltheussl
Date: Wed Jan 12 11:48:18 2011
New Revision: 1058092

URL: http://svn.apache.org/viewvc?rev=1058092&view=rev
Log:
add a special test for breadcrumbs

Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java

Modified: maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java?rev=1058092&r1=1058091&r2=1058092&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
Wed Jan 12 11:48:18 2011
@@ -22,6 +22,8 @@ package org.apache.maven.doxia.site.deco
 import java.io.IOException;
 import java.io.Reader;
 
+import java.util.List;
+
 import junit.framework.TestCase;
 
 import org.apache.maven.doxia.site.decoration.Banner;
@@ -603,6 +605,74 @@ public class DecorationModelInheritenceA
         assertEquals( "Check item", createLinkItem( "Foo", "" ), model.getBody().getBreadcrumbs().get(
0 ) );
     }
 
+    public void testBreadcrumbs()
+    {
+        String parentHref = "http://parent.com/index.html";
+
+        final DecorationModel parent = new DecorationModel();
+        parent.setBody( new Body() );
+        parent.getBody().addBreadcrumb( createLinkItem( "Parent", parentHref ) );
+
+        DecorationModel child = new DecorationModel();
+        assembler.assembleModelInheritance( "childName", child, parent,
+                "http://parent.com/child", "http://parent.com" );
+        assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref
);
+
+
+        // same with trailing slash
+        child = new DecorationModel();
+        assembler.assembleModelInheritance( "childName", child, parent,
+                "http://parent.com/child/", "http://parent.com/" );
+        assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref
);
+
+        // now mixed
+        child = new DecorationModel();
+        assembler.assembleModelInheritance( "childName", child, parent,
+                "http://parent.com/child/", "http://parent.com" );
+        assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref
);
+
+        // and other way round
+        child = new DecorationModel();
+        assembler.assembleModelInheritance( "childName", child, parent,
+                "http://parent.com/child", "http://parent.com/" );
+        assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref
);
+
+
+        // now with child breadcrumb
+        child = new DecorationModel();
+        child.setBody( new Body() );
+        child.getBody().addBreadcrumb( createLinkItem( "Child", "" ) );
+        assembler.assembleModelInheritance( "childName", child, parent,
+                "http://parent.com/child/", "http://parent.com/" );
+        assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "Child", parentHref );
+
+
+        // now with file url
+        parentHref = "file://parent.com/index.html";
+        ( (LinkItem) parent.getBody().getBreadcrumbs().get( 0 ) ).setHref( parentHref );
+        child = new DecorationModel();
+        assembler.assembleModelInheritance( "childName", child, parent,
+                "file://parent.com/child/", "file://parent.com/" );
+        assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref
);
+
+
+        // now with scp url
+        parentHref = "scp://parent.com/index.html";
+        ( (LinkItem) parent.getBody().getBreadcrumbs().get( 0 ) ).setHref( parentHref );
+        child = new DecorationModel();
+        assembler.assembleModelInheritance( "childName", child, parent,
+                "scp://parent.com/child/", "scp://parent.com/" );
+        assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref
);
+    }
+
+    private static void assertBreadcrumbsCorrect( final List breadcrumbs, final String childName,
+            final String parentHref )
+    {
+        assertEquals( "Check size", 2, breadcrumbs.size() );
+        assertEquals( "Check parent item", createLinkItem( "Parent", parentHref ), breadcrumbs.get(
0 ) );
+        assertEquals( "Check child item", createLinkItem( childName, "" ), breadcrumbs.get(
1 ) );
+    }
+
     public void testBannerWithoutHref()
     {
         DecorationModel model = new DecorationModel();



Mime
View raw message