aheritier 2004/05/09 13:58:49
Modified: xdoc/src/main/org/apache/maven DependencyDescriberBean.java
DescribedDependency.java NavBean.java
xdoc/src/test/org/apache/maven NavBeanTest.java
Log:
Fix checkstyle errors
Revision Changes Path
1.4 +111 -87
maven-plugins/xdoc/src/main/org/apache/maven/DependencyDescriberBean.java
Index: DependencyDescriberBean.java
===================================================================
RCS file:
/home/cvs/maven-plugins/xdoc/src/main/org/apache/maven/DependencyDescriberBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DependencyDescriberBean.java 2 Mar 2004 15:36:14 -0000 1.3
+++ DependencyDescriberBean.java 9 May 2004 20:58:49 -0000 1.4
@@ -16,111 +16,135 @@
* limitations under the License.
* ====================================================================
*/
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.maven.project.Dependency;
+import org.apache.maven.project.Project;
import java.io.File;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.maven.project.Dependency;
-import org.apache.maven.project.Project;
/**
- * @author <a href="[EMAIL PROTECTED]">Michal Maczka</a>
+ * Retreive descriptions for project's dependencies.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Michal Maczka</a>
* @version $Id$
*/
public class DependencyDescriberBean
{
- /** for debug output */
- private Log log = LogFactory.getLog(DependencyDescriberBean.class);
-
- /** */
- private List dependencies = new ArrayList();
- private Project project;
-
- /**
- * @return
- */
- public List getDependencies()
+ //~ Instance fields ------------------------------------------------
+
+ /** dependencies list */
+ private List dependencies = new ArrayList();
+
+ /** for debug output */
+ private Log log = LogFactory.getLog(DependencyDescriberBean.class);
+
+ /** project reference */
+ private Project project;
+
+ //~ Methods --------------------------------------------------------
+
+ /**
+ * The list of described dependencies.
+ *
+ * @return list of described dependencies
+ *
+ * @see DescribedDependency
+ */
+ public List getDependencies()
+ {
+ return dependencies;
+ }
+
+ /**
+ * Project provides context/session related information. e.g where
+ * maven repo local is
+ *
+ * @param projectValue project to scan
+ */
+ public void build(Project projectValue)
+ {
+ this.project = projectValue;
+
+ for (Iterator iter = project.getDependencies().iterator();
+ iter.hasNext();)
{
- return dependencies;
+ Dependency dependency = (Dependency) iter.next();
+ DescribedDependency describedDependency =
+ new DescribedDependency(dependency);
+ dependencies.add(describedDependency);
+
+ Project resolvedProject = resolveProject(dependency);
+
+ if (resolvedProject != null)
+ {
+ log.debug("POM URL:" + resolvedProject.getUrl());
+ describedDependency.setUrl(resolvedProject.getUrl());
+ describedDependency.setDescription(
+ resolvedProject.getDescription());
+ }
}
- /**
- * Project provides context/session related information.
- * e.g where maven repo local is
- * @param project
- */
- public void build(Project project)
+ Collections.sort(dependencies);
+ }
+
+ /**
+ * Returns the project for a given dependency.
+ *
+ * @param dependency The dependency for which the project is
+ * searched.
+ *
+ * @return The project associated to this dependency.
+ */
+ private Project resolveProject(Dependency dependency)
+ {
+ File projectFile = null;
+
+ if ("pom".equals(dependency.getType()))
{
- this.project = project;
- for (Iterator iter = project.getDependencies().iterator();
- iter.hasNext();
- )
- {
- Dependency dependency = (Dependency) iter.next();
- DescribedDependency describedDependency =
- new DescribedDependency(dependency);
- dependencies.add(describedDependency);
- Project resolvedProject = resolveProject(dependency);
- if (resolvedProject != null)
- {
- log.debug("POM URL:" + resolvedProject.getUrl());
- describedDependency.setUrl(resolvedProject.getUrl());
- describedDependency.setDescription(
- resolvedProject.getDescription());
- }
- }
- Collections.sort(dependencies);
+ projectFile =
+ new File(
+ project.getContext().getMavenRepoLocal(),
+ dependency.getArtifact());
+ }
+ else
+ {
+ projectFile =
+ new File(
+ project.getContext().getMavenRepoLocal(),
+ dependency.getArtifactDirectory() + "/poms/"
+ + dependency.getArtifactId() + "-"
+ + dependency.getVersion() + ".pom");
+ }
+
+ try
+ {
+ if (projectFile.exists() && projectFile.canRead())
+ {
+ return MavenUtils.getProject(
+ projectFile,
+ null,
+ false);
+ }
+ else
+ {
+ log.debug("Failed to read POM:" + projectFile);
+
+ return null;
+ }
}
- /**
- * @param dependency
- * @return
- * @throws Exception
- */
- private Project resolveProject(Dependency dependency)
+ catch (Exception e)
{
+ log.debug("Failed to read POM:" + projectFile);
- File projectFile = null;
- if ("pom".equals(dependency.getType()))
- {
- projectFile =
- new File(
- project.getContext().getMavenRepoLocal(),
- dependency.getArtifact());
- }
- else
- {
- projectFile =
- new File(
- project.getContext().getMavenRepoLocal(),
- dependency.getArtifactDirectory()
- + "/poms/"
- + dependency.getArtifactId()
- + "-"
- + dependency.getVersion()
- + ".pom");
- }
- try
- {
- if (projectFile.exists() && projectFile.canRead())
- {
-
- return MavenUtils.getProject(projectFile, null, false);
- }
- else
- {
- log.debug("Failed to read POM:" + projectFile);
- return null;
- }
- }
- catch (Exception e)
- {
- log.debug("Failed to read POM:" + projectFile);
- return null;
- }
+ return null;
}
+ }
}
1.3 +208 -143
maven-plugins/xdoc/src/main/org/apache/maven/DescribedDependency.java
Index: DescribedDependency.java
===================================================================
RCS file:
/home/cvs/maven-plugins/xdoc/src/main/org/apache/maven/DescribedDependency.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DescribedDependency.java 2 Mar 2004 15:36:14 -0000 1.2
+++ DescribedDependency.java 9 May 2004 20:58:49 -0000 1.3
@@ -16,157 +16,222 @@
* limitations under the License.
* ====================================================================
*/
-
import org.apache.maven.project.Dependency;
+
/**
- *
- * @author <a href="[EMAIL PROTECTED]">Michal Maczka</a>
+ * Dependency wrapper. Adds an url to download and a description.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Michal Maczka</a>
* @version $Id$
*/
public class DescribedDependency implements Comparable
{
- private Dependency dependency;
-
- private String description = null;
-
- private String url = null;
-
- public DescribedDependency(Dependency dependency)
- {
- this.dependency = dependency;
- }
-
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(Object obj)
- {
- DescribedDependency other = (DescribedDependency) obj;
- return this.getId().compareTo(other.getId());
- }
- /**
- * @return
- */
- public String getArtifact()
- {
- return dependency.getArtifact();
- }
-
- /**
- * @return
- */
- public String getArtifactDirectory()
- {
- return dependency.getArtifactDirectory();
- }
-
- /**
- * @return
- */
- public String getArtifactId()
- {
- return dependency.getArtifactId();
- }
-
- /**
- * @return
- */
- public String getExtension()
- {
- return dependency.getExtension();
- }
-
- /**
- * @return
- */
- public String getGroupId()
- {
- return dependency.getGroupId();
- }
+ //~ Instance fields ----------------------------------------------------------
- /**
- * @return
- */
- public String getId()
- {
- return dependency.getId();
- }
-
- /**
- * @return
- */
- public String getJar()
- {
- return dependency.getJar();
- }
-
- /**
- * @return
- */
- public String getName()
- {
- return dependency.getName();
- }
-
- /**
- * @return
- */
- public String getType()
- {
- return dependency.getType();
- }
-
- /**
- *
- * @param url
- */
- public void setUrl(String url)
- {
- this.url = url;
- }
-
- /**
- * @return
- */
- public String getUrl()
- {
- String retValue = null;
- if (dependency.getUrl() != null && dependency.getUrl().length()>0)
- {
- retValue = dependency.getUrl();
- }
- else
- {
-
- return retValue = url;
- }
- return retValue;
- }
-
- /**
- * @return
- */
- public String getVersion()
- {
- return dependency.getVersion();
- }
+ /** Original dependency. */
+ private Dependency dependency;
- /**
- /**
- * @return
- */
- public String getDescription()
- {
- return description;
- }
+ /** Dependency description. */
+ private String description = null;
- /**
- * @param description
- */
- public void setDescription(String description)
- {
- this.description = description;
- }
+ /** Dependency Url. */
+ private String url = null;
+
+ //~ Constructors -------------------------------------------------------------
+
+ /**
+ * Creates a new DescribedDependency object.
+ *
+ * @param dependencyToWrap Original dependency.
+ */
+ public DescribedDependency(Dependency dependencyToWrap)
+ {
+ this.dependency = dependencyToWrap;
+ }
+
+ //~ Methods ------------------------------------------------------------------
+
+ /**
+ * Dependency's artifact property getter.
+ *
+ * @return dependency's artifact.
+ *
+ * @see Dependency#getArtifact()
+ */
+ public String getArtifact()
+ {
+ return dependency.getArtifact();
+ }
+
+ /**
+ * Dependency's artifactDirectory property getter.
+ *
+ * @return dependency's artifactDirectory.
+ *
+ * @see Dependency#getArtifactDirectory()
+ */
+ public String getArtifactDirectory()
+ {
+ return dependency.getArtifactDirectory();
+ }
+
+ /**
+ * Dependency's artifactId property getter.
+ *
+ * @return dependency's artifactId.
+ *
+ * @see Dependency#getArtifactId()
+ */
+ public String getArtifactId()
+ {
+ return dependency.getArtifactId();
+ }
+
+ /**
+ * Property setter.
+ *
+ * @param newDescription new description for the dependency.
+ *
+ */
+ public void setDescription(String newDescription)
+ {
+ this.description = newDescription;
+ }
+
+ /**
+ * Property getter.
+ *
+ * @return the dependency's description.
+ *
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * Dependency's extension property getter.
+ *
+ * @return dependency's extension.
+ *
+ * @see Dependency#getExtension()
+ */
+ public String getExtension()
+ {
+ return dependency.getExtension();
+ }
+
+ /**
+ * Dependency's groupId property getter.
+ *
+ * @return dependency's groupId.
+ *
+ * @see Dependency#getGroupId()
+ */
+ public String getGroupId()
+ {
+ return dependency.getGroupId();
+ }
+
+ /**
+ * Dependency's id property getter.
+ *
+ * @return dependency's id.
+ *
+ * @see Dependency#getId()
+ */
+ public String getId()
+ {
+ return dependency.getId();
+ }
+
+ /**
+ * Dependency's jar property getter.
+ *
+ * @return dependency's jar.
+ *
+ * @see Dependency#getJar()
+ */
+ public String getJar()
+ {
+ return dependency.getJar();
+ }
+
+ /**
+ * Dependency's name property getter.
+ *
+ * @return dependency's name.
+ *
+ * @see Dependency#getName()
+ */
+ public String getName()
+ {
+ return dependency.getName();
+ }
+
+ /**
+ * Dependency's type property getter.
+ *
+ * @return dependency's type.
+ *
+ * @see Dependency#getType()
+ */
+ public String getType()
+ {
+ return dependency.getType();
+ }
+
+ /**
+ * Property setter.
+ *
+ * @param newUrl the new dependency's url.
+ */
+ public void setUrl(String newUrl)
+ {
+ this.url = newUrl;
+ }
+
+ /**
+ * Property getter.
+ *
+ * @return the dependency's url.
+ */
+ public String getUrl()
+ {
+ String retValue = null;
+
+ if ((dependency.getUrl() != null) && (dependency.getUrl().length() > 0))
+ {
+ retValue = dependency.getUrl();
+ }
+ else
+ {
+ return retValue = url;
+ }
+
+ return retValue;
+ }
+
+ /**
+ * Dependency's version property getter.
+ *
+ * @return dependency's version.
+ *
+ * @see Dependency#getVersion()
+ */
+ public String getVersion()
+ {
+ return dependency.getVersion();
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object obj)
+ {
+ DescribedDependency other = (DescribedDependency) obj;
+ return this.getId().compareTo(other.getId());
+ }
}
1.8 +162 -98 maven-plugins/xdoc/src/main/org/apache/maven/NavBean.java
Index: NavBean.java
===================================================================
RCS file: /home/cvs/maven-plugins/xdoc/src/main/org/apache/maven/NavBean.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- NavBean.java 2 Mar 2004 15:36:14 -0000 1.7
+++ NavBean.java 9 May 2004 20:58:49 -0000 1.8
@@ -16,141 +16,205 @@
* limitations under the License.
* ====================================================================
*/
-
-import java.util.List;
-
import org.dom4j.Attribute;
import org.dom4j.Node;
+
import org.dom4j.tree.DefaultElement;
+import java.util.List;
+
+
/**
- * @author <a href="[EMAIL PROTECTED]">Ben Walding</a>
+ * Navigation Bean.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Ben Walding</a>
* @version $Id$
*/
public class NavBean
{
- private String location;
- private Node document;
+ //~ Instance fields ----------------------------------------------------------
+
+ /** The current document. */
+ private Node document;
- public void setDocument(Object o)
+ /** The current location. */
+ private String location;
+
+ //~ Methods ------------------------------------------------------------------
+
+ /**
+ * Determines if the given node is collapsed. If a parent of this node is
+ * collapsed, this will give spurious results.
+ *
+ * @param o the node to test
+ *
+ * @return boolean
+ */
+ public boolean isCollapsed(Object o)
+ {
+ //If we don't know where we are, collapse it - something outside of our
knowledge
+ if (location == null)
{
- document = (Node) o;
+ return true;
}
- private static String getAttribute(DefaultElement elem, String attribute,
String defaultValue)
+ if (!(o instanceof DefaultElement))
{
- Attribute attr = elem.attribute(attribute);
- if (attr == null)
- {
- return defaultValue;
- }
+ System.out.println(o.getClass().getName());
- return attr.getStringValue();
+ return false;
}
- private static boolean getCollapseAttribute(DefaultElement elem)
+ DefaultElement elem = (DefaultElement) o;
+
+ boolean collapsed = getCollapseAttribute(elem);
+
+ if (!collapsed)
{
- return Boolean.valueOf(getAttribute(elem, "collapse",
"false")).booleanValue();
+ return false;
}
- private static String getHREFAttribute(DefaultElement elem)
+
+ if (isSelected(o))
{
- return getAttribute(elem, "href", null);
+ return false;
}
-
- /**
- * Determines if the given node is collapsed. If a parent of this node is
- * collapsed, this will give spurious results.
- * @param o
- * @return boolean
- */
- public boolean isCollapsed(Object o)
- {
- //If we don't know where we are, collapse it - something outside of our
knowledge
- if (location == null)
- {
- return true;
- }
-
- if (!(o instanceof DefaultElement))
- {
- System.out.println(o.getClass().getName());
- return false;
- }
- DefaultElement elem = (DefaultElement) o;
- boolean collapsed = getCollapseAttribute(elem);
- if (!collapsed)
- {
- return false;
- }
+ //System.out.println(elem.asXML());
+ String xpath;
- if (isSelected(o))
- {
- return false;
- }
+ if (location.startsWith("/") || location.startsWith("."))
+ {
+ xpath = ".//[EMAIL PROTECTED]'" + location + "']";
+ }
+ else
+ {
+ xpath = ".//[EMAIL PROTECTED]'/" + location + "']";
+ }
- //System.out.println(elem.asXML());
- String xpath;
- if (location.startsWith("/") || location.startsWith(".")) {
- xpath = ".//[EMAIL PROTECTED]'" + location + "']";
+ List l = elem.selectNodes(xpath);
- } else {
- xpath = ".//[EMAIL PROTECTED]'/" + location + "']";
+ if (l.size() != 0)
+ {
+ return false;
+ }
- }
+ return true;
+ }
-
- List l = elem.selectNodes(xpath);
+ /**
+ * Setter.
+ *
+ * @param o The new document.
+ */
+ public void setDocument(Object o)
+ {
+ document = (Node) o;
+ }
- if (l.size() != 0)
- {
- return false;
- }
+ /**
+ * Find the first <code>item</code> with a given href
+ *
+ * @param href the href to find.
+ *
+ * @return DefaultElement
+ */
+ public DefaultElement getFirstNodeByHREF(String href)
+ {
+ String xpath = "//[EMAIL PROTECTED]'" + href + "']";
- return true;
- }
+ return (DefaultElement) document.selectSingleNode(xpath);
+ }
- /**
- * Determines if a given <code>item</code> node is the selected node
- * @param o
- * @return boolean
- */
- public boolean isSelected(Object o)
+ /**
+ * Sets the location.
+ *
+ * @param newLocation The location to set
+ */
+ public void setLocation(String newLocation)
+ {
+ if (!newLocation.startsWith("/"))
{
- if (location == null)
- {
- return false;
- }
+ newLocation = "/" + newLocation;
+ }
- DefaultElement elem = (DefaultElement) o;
- if (location.equals(getHREFAttribute(elem)))
- {
- return true;
- }
+ this.location = newLocation;
+ }
- return false;
+ /**
+ * Determines if a given <code>item</code> node is the selected node
+ *
+ * @param o the item to test
+ *
+ * @return true if the item is currently selected.
+ */
+ public boolean isSelected(Object o)
+ {
+ if (location == null)
+ {
+ return false;
}
- /**
- * Sets the location.
- * @param location The location to set
- */
- public void setLocation(String location)
+ DefaultElement elem = (DefaultElement) o;
+
+ if (location.equals(getHREFAttribute(elem)))
{
- if (!location.startsWith("/"))
- location = "/" + location;
-
- this.location = location;
+ return true;
}
- /**
- * Find the first <code>item</code> with a given href
- * @param href
- * @return DefaultElement
- */
- public DefaultElement getFirstNodeByHREF(String href)
+ return false;
+ }
+
+ /**
+ * Return the attribute's value for an element.
+ *
+ * @param elem The element to read
+ * @param attribute The attribute's name to get.
+ * @param defaultValue A default value to return.
+ *
+ * @return The attribute's value for the given element.
+ */
+ private static String getAttribute(
+ DefaultElement elem,
+ String attribute,
+ String defaultValue)
+ {
+ Attribute attr = elem.attribute(attribute);
+
+ if (attr == null)
{
- String xpath = "//[EMAIL PROTECTED]'" + href + "']";
- return (DefaultElement) document.selectSingleNode(xpath);
+ return defaultValue;
}
+
+ return attr.getStringValue();
+ }
+
+ /**
+ * Test if the element is collapsed.
+ *
+ * @param elem The element to test
+ *
+ * @return true if the element has a collapse attribute with the value true.
+ */
+ private static boolean getCollapseAttribute(DefaultElement elem)
+ {
+ return Boolean.valueOf(getAttribute(
+ elem,
+ "collapse",
+ "false")).booleanValue();
+ }
+
+ /**
+ * Return href attribute.
+ *
+ * @param elem element.
+ *
+ * @return href value.
+ */
+ private static String getHREFAttribute(DefaultElement elem)
+ {
+ return getAttribute(
+ elem,
+ "href",
+ null);
+ }
}
1.6 +179 -62 maven-plugins/xdoc/src/test/org/apache/maven/NavBeanTest.java
Index: NavBeanTest.java
===================================================================
RCS file: /home/cvs/maven-plugins/xdoc/src/test/org/apache/maven/NavBeanTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NavBeanTest.java 2 Mar 2004 15:36:15 -0000 1.5
+++ NavBeanTest.java 9 May 2004 20:58:49 -0000 1.6
@@ -16,81 +16,198 @@
* limitations under the License.
* ====================================================================
*/
-
-import java.io.File;
-import java.io.FileInputStream;
-
import junit.framework.TestCase;
import org.dom4j.Document;
import org.dom4j.Node;
+
import org.dom4j.io.SAXReader;
+import java.io.File;
+import java.io.FileInputStream;
+
+
/**
- * @author <a href="[EMAIL PROTECTED]">Ben Walding</a>
+ * NavBean Tests class.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Ben Walding</a>
* @version $Id$
*/
public class NavBeanTest extends TestCase
{
+ //~ Instance fields ----------------------------------------------------------
- private File testResources;
- NavBean nb;
+ /** Test resources file. */
+ private File testResources;
- public void setUp() throws Exception
- {
- testResources = new File(System.getProperty("basedir") +
"/src/test-resources");
- nb = new NavBean();
- nb.setDocument(getTestDocument());
- }
+ /** NavBean instance to test */
+ private NavBean nb;
- class Test
+ //~ Methods ------------------------------------------------------------------
+
+ /**
+ * Tests settings.
+ *
+ * @throws Exception If a problem occurs
+ */
+ public void setUp()
+ throws Exception
+ {
+ testResources =
+ new File(System.getProperty("basedir") + "/src/test-resources");
+ nb = new NavBean();
+ nb.setDocument(getTestDocument());
+ }
+
+ /**
+ * Test.
+ *
+ * @param href href
+ * @param location location
+ * @param expected Result expected
+ */
+ public void testCollapsed(
+ 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));
+ }
+
+ /**
+ * tests suite.
+ *
+ * @throws Exception DOCUMENT ME!
+ */
+ public void testCollapsed()
+ throws Exception
+ {
+ testCollapsed(
+ "/alpha/index.html",
+ "/alpha/index.html",
+ false);
+ testCollapsed(
+ "/alpha/one/index.html",
+ "/alpha/index.html",
+ false);
+ testCollapsed(
+ "/alpha/two/index.html",
+ "/alpha/index.html",
+ false);
+ testCollapsed(
+ "/beta/index.html",
+ "/alpha/index.html",
+ true);
+
+ testCollapsed(
+ "/alpha/index.html",
+ "/beta/index.html",
+ false);
+ testCollapsed(
+ "/alpha/one/index.html",
+ "/beta/index.html",
+ false);
+ testCollapsed(
+ "/alpha/two/index.html",
+ "/beta/index.html",
+ false);
+ testCollapsed(
+ "/beta/index.html",
+ "/beta/index.html",
+ false);
+ testCollapsed(
+ "/beta/one/index.html",
+ "/beta/index.html",
+ true);
+ testCollapsed(
+ "/beta/two/index.html",
+ "/beta/index.html",
+ true);
+
+ testCollapsed(
+ "/alpha/index.html",
+ "beta/index.html",
+ false);
+ testCollapsed(
+ "/alpha/one/index.html",
+ "beta/index.html",
+ false);
+ testCollapsed(
+ "/alpha/two/index.html",
+ "beta/index.html",
+ false);
+ testCollapsed(
+ "/beta/index.html",
+ "beta/index.html",
+ false);
+ testCollapsed(
+ "/beta/one/index.html",
+ "beta/index.html",
+ true);
+ testCollapsed(
+ "/beta/two/index.html",
+ "beta/index.html",
+ true);
+ }
+
+ /**
+ * Get the navigation.xml to test.
+ *
+ * @return XML Document
+ *
+ * @throws Exception If a problem occurs.
+ */
+ protected Document getTestDocument()
+ throws Exception
+ {
+ SAXReader reader = new SAXReader();
+
+ return reader.read(
+ new FileInputStream(new File(
+ testResources,
+ "navigation.xml")));
+ }
+
+ //~ Inner Classes ------------------------------------------------------------
+
+ /**
+ * Test
+ */
+ class Test
+ {
+ //~ Instance fields --------------------------------------------------------
+
+ /** Href. */
+ private String href;
+
+ /** Collapsed. */
+ private boolean collapsed;
+
+ //~ Constructors -----------------------------------------------------------
+
+ /**
+ * Creates a new Test object.
+ *
+ * @param newHref HREF.
+ * @param newCollapsed Status.
+ */
+ public Test(
+ String newHref,
+ boolean newCollapsed)
{
- String href;
- boolean collapsed;
- public Test(String href, boolean collapsed)
- {
- this.href = href;
- this.collapsed = collapsed;
- }
- }
-
-
- protected Document getTestDocument() throws Exception
- {
- SAXReader reader = new SAXReader();
- return reader.read(new FileInputStream(new File(testResources,
"navigation.xml")));
- }
-
- public void testCollapsed() throws Exception
- {
- testCollapsed("/alpha/index.html", "/alpha/index.html", false);
- testCollapsed("/alpha/one/index.html", "/alpha/index.html", false);
- testCollapsed("/alpha/two/index.html", "/alpha/index.html", false);
- testCollapsed("/beta/index.html", "/alpha/index.html", true);
-
- testCollapsed("/alpha/index.html", "/beta/index.html", false);
- testCollapsed("/alpha/one/index.html", "/beta/index.html", false);
- testCollapsed("/alpha/two/index.html", "/beta/index.html", false);
- testCollapsed("/beta/index.html", "/beta/index.html", false);
- testCollapsed("/beta/one/index.html", "/beta/index.html", true);
- testCollapsed("/beta/two/index.html", "/beta/index.html", true);
-
- testCollapsed("/alpha/index.html", "beta/index.html", false);
- testCollapsed("/alpha/one/index.html", "beta/index.html", false);
- testCollapsed("/alpha/two/index.html", "beta/index.html", false);
- testCollapsed("/beta/index.html", "beta/index.html", false);
- testCollapsed("/beta/one/index.html", "beta/index.html", true);
- testCollapsed("/beta/two/index.html", "beta/index.html", true);
- }
-
- public void testCollapsed(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));
+ this.href = newHref;
+ this.collapsed = newCollapsed;
}
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]