diff --git a/linkcheck/project.xml b/linkcheck/project.xml index 37af1ba5..71fb28b2 100644 --- a/linkcheck/project.xml +++ b/linkcheck/project.xml @@ -24,24 +24,16 @@ - commons-betwixt - 1.0-beta-1 + commons-util + SNAPSHOT root.maven - commons-collections - 2.1 - - root.maven - - - - - commons-digester - 1.3 + commons-lang + SNAPSHOT root.maven diff --git a/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.betwixt b/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.betwixt deleted file mode 100644 index bb4d9e7a..00000000 --- a/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.betwixt +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.java b/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.java index cae7cf7c..e63551c7 100644 --- a/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.java +++ b/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.java @@ -150,8 +150,6 @@ public class FileToCheck { break; } - //FIXME: needs expanding and caching for remote links - links.add(lcr); } } catch (Exception e) { @@ -219,7 +217,29 @@ public class FileToCheck { String fileName = f.getAbsolutePath(); if (fileName.startsWith(baseName)) fileName = fileName.substring(baseName.length() + 1); + + fileName = fileName.replace('\\', '/'); return fileName; } + public String toXML() { + StringBuffer buf = new StringBuffer(); + + buf.append(" \n"); + buf.append(" " + getName() + "\n"); + buf.append(" " + getSuccessful() + "\n"); + buf.append(" " + getUnsuccessful() + "\n"); + + Iterator iter = getResults().iterator(); + while (iter.hasNext()) { + LinkCheckResult result = (LinkCheckResult) iter.next(); + buf.append(result.toXML()); + } + + + buf.append(" \n"); + + return buf.toString(); + } + } diff --git a/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheck.betwixt b/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheck.betwixt deleted file mode 100644 index 9123b71e..00000000 --- a/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheck.betwixt +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheck.java b/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheck.java index f82ea462..22965dc3 100644 --- a/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheck.java +++ b/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheck.java @@ -66,7 +66,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.apache.commons.betwixt.io.BeanWriter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.maven.linkcheck.validation.FileLinkValidator; @@ -80,7 +79,7 @@ import org.apache.maven.linkcheck.validation.MailtoLinkValidator; * output that represents the list of changes. * * @author Ben Walding - * @version $Id: LinkCheck.java,v 1.1 2003/01/30 10:58:08 bwalding Exp $ + * @version $Id: LinkCheck.java,v 1.2 2003/01/30 15:34:26 bwalding Exp $ */ public class LinkCheck { /** Log */ @@ -131,8 +130,7 @@ public class LinkCheck { * support ISO-8859-1 encoding */ List filesToCheck = null; //of FileToCheck - public void doExecute() - throws Exception { + public void doExecute() throws Exception { if (output == null) { throw new NullPointerException("output must be set"); } @@ -156,9 +154,8 @@ public class LinkCheck { createDocument(files); lvm.saveCache(cache); } - + public List getFiles() { - LOG.info("About to write " + filesToCheck.size() + " file entries"); return filesToCheck; } @@ -206,23 +203,19 @@ public class LinkCheck { new OutputStreamWriter( new FileOutputStream(output), getOutputEncoding())); - StringBuffer buffer = new StringBuffer(); - buffer - .append("\n"); - - BeanWriter bw = new BeanWriter(out); - bw.writeXmlDeclaration(buffer.toString()); - bw.setWriteIDs(false); - bw.enablePrettyPrint(); - bw.write(this); + StringBuffer buffer = new StringBuffer(); + buffer + .append("\n"); + + out.write(buffer.toString()); + + out.write(toXML()); out.close(); } - - /** * Returns the outputEncoding. * @return String @@ -239,7 +232,6 @@ public class LinkCheck { this.outputEncoding = outputEncoding; } - LinkValidatorManager lvm = null; public LinkValidatorManager getLinkValidatorManager() { if (lvm == null) { @@ -285,4 +277,19 @@ public class LinkCheck { this.exclude = exclude; } + public String toXML() { + StringBuffer buf = new StringBuffer(); + + buf.append("\n"); + + //buf.append(" \n"); + for (Iterator iter = getFiles().iterator(); iter.hasNext();) { + FileToCheck ftc = (FileToCheck) iter.next(); + buf.append(ftc.toXML()); + } + //buf.append(" \n"); + buf.append("\n"); + return buf.toString(); + } + } \ No newline at end of file diff --git a/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheckResult.betwixt b/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheckResult.betwixt deleted file mode 100644 index b07048b8..00000000 --- a/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheckResult.betwixt +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheckResult.java b/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheckResult.java index b2d073e8..400ead28 100644 --- a/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheckResult.java +++ b/linkcheck/src/main/org/apache/maven/linkcheck/LinkCheckResult.java @@ -1,5 +1,7 @@ package org.apache.maven.linkcheck; +import org.apache.commons.util.XmlUtils; + /* ==================================================================== * The Apache Software License, Version 1.1 * @@ -55,8 +57,7 @@ package org.apache.maven.linkcheck; * * ==================================================================== */ - - + /** * @author Ben Walding * @@ -81,7 +82,6 @@ public class LinkCheckResult { this.status = status; } - /** * Returns the target. * @return String @@ -90,7 +90,6 @@ public class LinkCheckResult { return target; } - /** * Sets the target. * @param target The target to set @@ -99,4 +98,14 @@ public class LinkCheckResult { this.target = target; } + public String toXML() { + StringBuffer buf = new StringBuffer(); + + buf.append(" \n"); + buf.append(" " + XmlUtils.escapeXml(getTarget()) + "\n"); + buf.append(" " + getStatus() + "\n"); + buf.append(" \n"); + return buf.toString(); + } + } diff --git a/linkcheck/src/main/org/apache/maven/linkcheck/linkcheck.xml b/linkcheck/src/main/org/apache/maven/linkcheck/linkcheck.xml deleted file mode 100644 index 2dd9a342..00000000 --- a/linkcheck/src/main/org/apache/maven/linkcheck/linkcheck.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/linkcheck/src/plugin-resources/linkcheck.jsl b/linkcheck/src/plugin-resources/linkcheck.jsl index 13fc9bfc..12230d6e 100644 --- a/linkcheck/src/plugin-resources/linkcheck.jsl +++ b/linkcheck/src/plugin-resources/linkcheck.jsl @@ -21,12 +21,11 @@ URL - - + - ${file.attribute('name').value} + ${name} @@ -34,8 +33,8 @@ - - + + ${status} - ${target}
@@ -43,7 +42,7 @@
-
+ diff --git a/linkcheck/src/test/org/apache/maven/linkcheck/LinkCheckTest.java b/linkcheck/src/test/org/apache/maven/linkcheck/LinkCheckTest.java index 5a24fa55..1e72f7b1 100644 --- a/linkcheck/src/test/org/apache/maven/linkcheck/LinkCheckTest.java +++ b/linkcheck/src/test/org/apache/maven/linkcheck/LinkCheckTest.java @@ -56,7 +56,12 @@ package org.apache.maven.linkcheck; * ==================================================================== */ import java.io.File; +import java.util.HashMap; import java.util.Iterator; +import java.util.Map; + +import org.apache.maven.linkcheck.validation.FileLinkValidator; +import org.apache.maven.linkcheck.validation.LinkValidatorManager; import junit.framework.TestCase; @@ -71,8 +76,7 @@ public class LinkCheckTest extends TestCase { baseDir = System.getProperty("basedir"); } - public void testScan() - throws Exception { + public void testScan() throws Exception { File f = new File(baseDir + "/src/test-resources"); LinkCheck lc = new LinkCheck(); lc.setBasedir(f); @@ -80,16 +84,40 @@ public class LinkCheckTest extends TestCase { lc.setOutputEncoding("ISO8859-1"); lc.setCache(baseDir + "/target/linkcheck-cache.xml"); lc.doExecute(); - - - Iterator iter = lc.getFiles().iterator(); + + Iterator iter = lc.getFiles().iterator(); + Map map = new HashMap(); while (iter.hasNext()) { FileToCheck ftc = (FileToCheck) iter.next(); - System.out.println(ftc.getName()); + map.put(ftc.getName(), ftc); } - - //Iterator iter = Collections.EMPTY_LIST.iterator(); + + assertEquals("files.size()", 6, lc.getFiles().size()); + + check(map, "nolink.html", 0); + check(map, "test-resources/nolink.html", 0); + check(map, "test-resources/test1/test1.html", 1); + check(map, "test-resources/test1/test2.html", 0); + check(map, "test1/test1.html", 1); + check(map, "testA.html", 2); } + private void check(Map map, String name, int linkCount) { + FileToCheck ftc; + + ftc = (FileToCheck) map.get(name); + assertNotNull(name, ftc); + + /*if (ftc.getResults().size() != linkCount) { + + }*/ + + assertEquals( + name + ".getLinks().size()", + linkCount, + ftc.getResults().size()); + } + + }