You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by bw...@apache.org on 2003/03/10 15:15:33 UTC

cvs commit: jakarta-turbine-maven/src/plugins-build/xdoc/src/test/org/apache/maven NavBeanTest.java

bwalding    2003/03/10 06:15:31

  Modified:    src/plugins-build/xdoc/src/test/org/apache/maven
                        NavBeanTest.java
  Log:
  o MAVEN-320: Cleaned up tests to make them more understandable and useful
  
  Revision  Changes    Path
  1.2       +38 -41    jakarta-turbine-maven/src/plugins-build/xdoc/src/test/org/apache/maven/NavBeanTest.java
  
  Index: NavBeanTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/xdoc/src/test/org/apache/maven/NavBeanTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NavBeanTest.java	16 Feb 2003 23:03:37 -0000	1.1
  +++ NavBeanTest.java	10 Mar 2003 14:15:30 -0000	1.2
  @@ -55,7 +55,7 @@
    *
    * ====================================================================
    */
  - 
  +
   import java.io.File;
   import java.io.FileInputStream;
   
  @@ -73,8 +73,14 @@
   {
   
       private File testResources;
  -    public void setUp() {
  +    NavBean nb;
  +
  +    public void setUp() throws Exception
  +    {
           testResources = new File(System.getProperty("basedir") + "/src/test-resources");
  +        nb = new NavBean();
  +        nb.setDocument(getTestDocument());
  +
       }
   
       class Test
  @@ -87,54 +93,45 @@
               this.collapsed = collapsed;
           }
       }
  -    
  -    private Test[] testAlpha =
  -        {
  -            new Test("/alpha/index.html", false),
  -            new Test("/alpha/one/index.html", false),
  -            new Test("/alpha/two/index.html", false),
  -            new Test("/beta/index.html", true)};
  -
  -    private Test[] testBeta =
  -        {
  -            new Test("/alpha/index.html", false),
  -            new Test("/alpha/one/index.html", false),
  -            new Test("/alpha/two/index.html", false),
  -            new Test("/beta/index.html", false),
  -            new Test("/beta/one/index.html", true),
  -            new Test("/beta/two/index.html", true)};
  -
  -    public void testAlpha() throws Exception
  -    {
  -        testGroup("/alpha/index.html", testAlpha);
  -    }
  -
  -    public void testBeta() throws Exception
  -    {
  -        testGroup("/beta/index.html", testBeta);
  -    }
   
  + 
       protected Document getTestDocument() throws Exception
       {
           SAXReader reader = new SAXReader();
           return reader.read(new FileInputStream(new File(testResources, "navigation.xml")));
       }
   
  -    public void testGroup(String location, Test[] tests) throws Exception
  +    public void testAll() throws Exception
       {
  -        NavBean nb = new NavBean();
  -        nb.setDocument(getTestDocument());
  -        nb.setLocation(location);
  +        test("/alpha/index.html", "/alpha/index.html", false);
  +        test("/alpha/one/index.html", "/alpha/index.html", false);
  +        test("/alpha/two/index.html", "/alpha/index.html", false);
  +        test("/beta/index.html", "/alpha/index.html", true);
  +
  +        test("/alpha/index.html", "/beta/index.html", false);
  +        test("/alpha/one/index.html", "/beta/index.html", false);
  +        test("/alpha/two/index.html", "/beta/index.html", false);
  +        test("/beta/index.html", "/beta/index.html", false);
  +        test("/beta/one/index.html", "/beta/index.html", true);
  +        test("/beta/two/index.html", "/beta/index.html", true);
  +
  +        test("/alpha/index.html", "beta/index.html", false);
  +        test("/alpha/one/index.html", "beta/index.html", false);
  +        test("/alpha/two/index.html", "beta/index.html", false);
  +        test("/beta/index.html", "beta/index.html", false);
  +        test("/beta/one/index.html", "beta/index.html", true);
  +        test("/beta/two/index.html", "beta/index.html", true);
  +    }
   
  -        for (int i = 0; i < tests.length; i++)
  -        {
  -            Test test = tests[i];
  -            Node node = nb.getFirstNodeByHREF(test.href);
  -            assertNotNull(node);
  -            assertEquals(test.href + ".isCollapsed()", test.collapsed, nb.isCollapsed(node));
  -        }
  +    public void test(String href, String location, boolean expected)
  +    {
  +        nb.setLocation(location);
   
  +        Node node = nb.getFirstNodeByHREF(href);
  +        assertNotNull(node);
  +        
  +        String s = "At location " + location + ", looking to generate link to " + href + ", expecting collapse = " + expected;
  +        assertEquals(s, expected, nb.isCollapsed(node));
       }
   
   }
  -