Put debug logs for unit tests
Some cleanup git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@477398 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0a639cb33b
commit
48fed834de
@ -24,29 +24,40 @@ import java.util.Map;
|
||||
|
||||
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:carlos@apache.org">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/" );
|
||||
lc.doExecute();
|
||||
@ -76,7 +87,8 @@ public class LinkCheckTest
|
||||
assertEquals( "Excluded links", 2, ftc.getSuccessful() );
|
||||
|
||||
// index-all.html should get parsed, but is currently having problems.
|
||||
//check(map, "index-all.html", 1);
|
||||
// There are 805 distinct links in this page
|
||||
check( map, "index-all.html", 805 );
|
||||
|
||||
}
|
||||
|
||||
@ -87,10 +99,6 @@ public class LinkCheckTest
|
||||
ftc = (FileToCheck) map.get( name );
|
||||
assertNotNull( name, ftc );
|
||||
|
||||
/*if (ftc.getResults().size() != linkCount) {
|
||||
|
||||
}*/
|
||||
|
||||
assertEquals( name + ".getLinks().size()", linkCount, ftc.getResults().size() );
|
||||
}
|
||||
|
||||
|
||||
@ -21,29 +21,46 @@ import java.io.File;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author <a href="bwalding@apache.org">Ben Walding</a>
|
||||
* @author <a href="aheritier@apache.org">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,8 +75,7 @@ public class HTTPLinkValidatorTest
|
||||
}
|
||||
}
|
||||
|
||||
protected LinkValidationResult checkLink( String link )
|
||||
throws Exception
|
||||
protected LinkValidationResult checkLink( String link ) throws Exception
|
||||
{
|
||||
|
||||
LinkValidationItem lvi = new LinkValidationItem( new File( "." ), link );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user