Author: aheritier
Date: Mon Nov 20 15:23:42 2006
New Revision: 477398
URL: http://svn.apache.org/viewvc?view=rev&rev=477398
Log:
Put debug logs for unit tests
Some cleanup
Modified:
maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/LinkCheckTest.java
maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java
Modified:
maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/LinkCheckTest.java
URL:
http://svn.apache.org/viewvc/maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/LinkCheckTest.java?view=diff&rev=477398&r1=477397&r2=477398
==============================================================================
---
maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/LinkCheckTest.java
(original)
+++
maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/LinkCheckTest.java
Mon Nov 20 15:23:42 2006
@@ -24,31 +24,42 @@
import junit.framework.TestCase;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
/**
* @author Ben Walding
* @author <a href="mailto:[EMAIL PROTECTED]">Carlos Sanchez</a>
*/
-public class LinkCheckTest
- extends TestCase
+public class LinkCheckTest extends TestCase
{
String baseDir;
- public void setUp()
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
{
+ super.setUp();
baseDir = System.getProperty( "basedir" );
+ // Setup log4J (We are in a forked JVM for tests)
+ BasicConfigurator.configure();
+ Logger.getLogger( "org.apache.maven.plugin.linkcheck" ).setLevel(
Level.DEBUG );
}
- 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 );
lc.setOutput( new File( baseDir + "/target/linkcheck.xml" ) );
lc.setOutputEncoding( "ISO8859-1" );
- lc.setCache( baseDir + "/target/linkcheck-cache.xml" );
+ lc.setCache( System.getProperty( "maven.linkcheck.cache" ) );
lc.setExclude( "http://cvs.apache.org/viewcvs.cgi/maven-pluginszz/,"
- + "http://cvs.apache.org/viewcvs.cgi/mavenzz/" );
+ + "http://cvs.apache.org/viewcvs.cgi/mavenzz/" );
lc.doExecute();
Iterator iter = lc.getFiles().iterator();
@@ -75,8 +86,9 @@
FileToCheck ftc = (FileToCheck) map.get( fileName );
assertEquals( "Excluded links", 2, ftc.getSuccessful() );
- //index-all.html should get parsed, but is currently having problems.
- //check(map, "index-all.html", 1);
+ // index-all.html should get parsed, but is currently having problems.
+ // There are 805 distinct links in this page
+ check( map, "index-all.html", 805 );
}
@@ -86,10 +98,6 @@
ftc = (FileToCheck) map.get( name );
assertNotNull( name, ftc );
-
- /*if (ftc.getResults().size() != linkCount) {
-
- }*/
assertEquals( name + ".getLinks().size()", linkCount,
ftc.getResults().size() );
}
Modified:
maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java
URL:
http://svn.apache.org/viewvc/maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java?view=diff&rev=477398&r1=477397&r2=477398
==============================================================================
---
maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java
(original)
+++
maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java
Mon Nov 20 15:23:42 2006
@@ -21,29 +21,46 @@
import junit.framework.TestCase;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
/**
* @author <a href="[EMAIL PROTECTED]">Ben Walding</a>
* @author <a href="[EMAIL PROTECTED]">Arnaud Heritier</a>
* @version $Id$
*/
-public class HTTPLinkValidatorTest
- extends TestCase
+public class HTTPLinkValidatorTest extends TestCase
{
private LinkValidator hlv;
private boolean mavenOnline = Boolean.getBoolean( "maven.mode.online" );
- public void testValidateLink()
- throws Exception
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ // Setup log4J (We are in a forked JVM for tests)
+ BasicConfigurator.configure();
+ Logger.getLogger( "org.apache.maven.plugin.linkcheck" ).setLevel(
Level.DEBUG );
+ }
+
+ public void testValidateLink() throws Exception
{
- System.err.println( "maven.mode.online : " + mavenOnline );
if ( mavenOnline )
{
- hlv = new OnlineHTTPLinkValidator( System.getProperty(
"maven.linkcheck.method" ), System.getProperty( "maven.linkcheck.proxy.host" ),
System
- .getProperty( "maven.linkcheck.proxy.port" ),
System.getProperty( "maven.linkcheck.proxy.username" ),
- System.getProperty(
"maven.linkcheck.proxy.password" ), System
- .getProperty(
"maven.linkcheck.proxy.ntlm.host" ), System
- .getProperty(
"maven.linkcheck.proxy.ntlm.domain" ) );
+ hlv =
+ new OnlineHTTPLinkValidator( System.getProperty(
"maven.linkcheck.method" ),
+ System.getProperty(
"maven.linkcheck.proxy.host" ),
+ System.getProperty(
"maven.linkcheck.proxy.port" ),
+ System.getProperty(
"maven.linkcheck.proxy.username" ),
+ System.getProperty(
"maven.linkcheck.proxy.password" ),
+ System.getProperty(
"maven.linkcheck.proxy.ntlm.host" ),
+ System.getProperty(
"maven.linkcheck.proxy.ntlm.domain" ) );
assertEquals( LinkValidationResult.VALID, checkLink(
"http://www.apache.org" ).getStatus() );
assertEquals( LinkValidationResult.ERROR, checkLink(
"http://www.example.com>);" ).getStatus() );
@@ -58,12 +75,11 @@
}
}
- protected LinkValidationResult checkLink( String link )
- throws Exception
+ protected LinkValidationResult checkLink( String link ) throws Exception
{
LinkValidationItem lvi = new LinkValidationItem( new File( "." ), link
);
return hlv.validateLink( lvi );
}
-}
\ No newline at end of file
+}