Author: vsiveton
Date: Mon Jan 28 15:51:22 2008
New Revision: 616109
URL: http://svn.apache.org/viewvc?rev=616109&view=rev
Log:
o added more parameters: excludedPages, excludedHttpStatusErrors,
excludedHttpStatusWarnings
o added pattern for excludedLinks
o added test cases
o improved logging and bumped to commons-logging:1.1
o improved readingness of some toString()
Added:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/HTTPLinkValidationResult.java
(with props)
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/resources/
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/resources/log4j.properties
(with props)
maven/sandbox/trunk/doxia/doxia-linkcheck/src/test/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManagerTest.java
(with props)
Modified:
maven/sandbox/trunk/doxia/doxia-linkcheck/pom.xml
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/LinkCheck.java
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidationResult.java
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManager.java
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java
Modified: maven/sandbox/trunk/doxia/doxia-linkcheck/pom.xml
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-linkcheck/pom.xml?rev=616109&r1=616108&r2=616109&view=diff
==============================================================================
--- maven/sandbox/trunk/doxia/doxia-linkcheck/pom.xml (original)
+++ maven/sandbox/trunk/doxia/doxia-linkcheck/pom.xml Mon Jan 28 15:51:22 2008
@@ -41,7 +41,7 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
+ <version>1.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Modified:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/LinkCheck.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/LinkCheck.java?rev=616109&r1=616108&r2=616109&view=diff
==============================================================================
---
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/LinkCheck.java
(original)
+++
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/LinkCheck.java
Mon Jan 28 15:51:22 2008
@@ -23,10 +23,12 @@
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
+import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.maven.doxia.linkcheck.model.LinkcheckFile;
@@ -34,6 +36,7 @@
import org.apache.maven.doxia.linkcheck.model.LinkcheckModel;
import org.apache.maven.doxia.linkcheck.model.io.xpp3.LinkcheckModelXpp3Writer;
import org.apache.maven.doxia.linkcheck.validation.FileLinkValidator;
+import org.apache.maven.doxia.linkcheck.validation.HTTPLinkValidationResult;
import org.apache.maven.doxia.linkcheck.validation.LinkValidationItem;
import org.apache.maven.doxia.linkcheck.validation.LinkValidationResult;
import org.apache.maven.doxia.linkcheck.validation.LinkValidatorManager;
@@ -41,6 +44,7 @@
import org.apache.maven.doxia.linkcheck.validation.OfflineHTTPLinkValidator;
import org.apache.maven.doxia.linkcheck.validation.OnlineHTTPLinkValidator;
import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
/**
* The main bean to be called whenever a set of documents should have their
links checked.
@@ -68,9 +72,29 @@
/** Linkcheck Cache. */
private File linkCheckCache;
- /** excluded links. */
+ /**
+ * To exclude some links. Could contains a link, i.e.
<code>http://maven.apache.org</code>,
+ * or pattern links i.e.
<code>http://maven.apache.org/**/*.html</code>
+ */
private String[] excludedLinks = null;
+ /** To exclude some pages. */
+ private String[] excludedPages = null;
+
+ /**
+ * Excluded http errors only in on line mode.
+ *
+ * @see [EMAIL PROTECTED] HttpStatus} for all defined values.
+ */
+ private int[] excludedHttpStatusErrors = null;
+
+ /**
+ * Excluded http warnings only in on line mode.
+ *
+ * @see [EMAIL PROTECTED] HttpStatus} for all defined values.
+ */
+ private int[] excludedHttpStatusWarnings = null;
+
/** Online mode. */
private boolean online;
@@ -96,9 +120,10 @@
private LinkcheckModel model = new LinkcheckModel();
/**
- * The current report level. Defaults to LinkCheckResult.WARNING.
+ * The current report level. Defaults to
<code>LinkcheckFileResult#WARNING_LEVEL</code>.
*
* @return int
+ * @see LinkcheckFileResult#WARNING_LEVEL
*/
public int getReportLevel()
{
@@ -177,6 +202,8 @@
/**
* Returns the excluded links.
+ * Could contains a link, i.e.
<code>http://maven.apache.org/</code>,
+ * or pattern links i.e.
<code>http://maven.apache.org/**/*.html</code>
*
* @return String[]
*/
@@ -187,6 +214,8 @@
/**
* Sets the excluded links, a String[] with excluded locations.
+ * Could contains a link, i.e.
<code>http://maven.apache.org/</code>,
+ * or pattern links i.e.
<code>http://maven.apache.org/**/*.html</code>
*
* @param excl The excludes to set
*/
@@ -196,6 +225,70 @@
}
/**
+ * Returns the excluded pages.
+ *
+ * @return String[]
+ */
+ public String[] getExcludedPages()
+ {
+ return this.excludedPages;
+ }
+
+ /**
+ * Sets the excluded pages, a String[] with excluded locations.
+ *
+ * @param excl The excludes to set
+ */
+ public void setExcludedPages( String[] excl )
+ {
+ this.excludedPages = excl;
+ }
+
+ /**
+ * Returns the excluded HTTP errors, i.e. <code>404</code>.
+ *
+ * @return int[]
+ * @see [EMAIL PROTECTED] HttpStatus} for all possible values.
+ */
+ public int[] getExcludedHttpStatusErrors()
+ {
+ return this.excludedHttpStatusErrors;
+ }
+
+ /**
+ * Sets the excluded HTTP errors, i.e. <code>404</code>, a int[] with
excluded errors.
+ *
+ * @param excl The excludes to set
+ * @see [EMAIL PROTECTED] HttpStatus} for all possible values.
+ */
+ public void setExcludedHttpStatusErrors( int[] excl )
+ {
+ this.excludedHttpStatusErrors = excl;
+ }
+
+ /**
+ * Returns the excluded HTTP warnings, i.e. <code>301</code>.
+ *
+ * @return int[]
+ * @see [EMAIL PROTECTED] HttpStatus} for all possible values.
+ */
+ public int[] getExcludedHttpStatusWarnings()
+ {
+ return this.excludedHttpStatusWarnings;
+ }
+
+ /**
+ * Sets the excluded HTTP warnings, i.e. <code>301</code>, a int[] with
excluded errors.
+ *
+ * @param excl The excludes to set
+ * @see [EMAIL PROTECTED] HttpStatus} for all possible values.
+ */
+ public void setExcludedHttpStatusWarnings( int[] excl )
+ {
+ this.excludedHttpStatusWarnings = excl;
+ }
+
+ /**
* Sets the LinkValidatorManager.
*
* @param validator the LinkValidatorManager to set
@@ -229,9 +322,9 @@
{
this.lvm = new LinkValidatorManager();
- if ( this.excludedLinks != null )
+ if ( getExcludedLinks() != null )
{
- this.lvm.setExcludes( excludedLinks );
+ this.lvm.setExcludedLinks( getExcludedLinks() );
}
this.lvm.addLinkValidator( new FileLinkValidator() );
@@ -374,6 +467,26 @@
LOG.debug( " File - " + file );
}
+ if ( getExcludedPages() != null )
+ {
+ String diff = StringUtils.difference(
getBasedir().getAbsolutePath(), file.getAbsolutePath() );
+ if ( diff.startsWith( File.separator ) )
+ {
+ diff = diff.substring( 1 );
+ }
+
+ if ( Arrays.binarySearch( getExcludedPages(), diff )
>= 0 )
+ {
+
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( " Ignored analysis of " + file );
+ }
+
+ continue;
+ }
+ }
+
String fileRelativePath = file.getAbsolutePath();
if ( fileRelativePath.startsWith(
this.basedir.getAbsolutePath() ) )
{
@@ -476,17 +589,59 @@
break;
case LinkcheckFileResult.ERROR_LEVEL:
- linkcheckFile.setUnsuccessful(
linkcheckFile.getUnsuccessful() + 1 );
+ boolean ignoredError = false;
+ if ( result instanceof HTTPLinkValidationResult)
+ {
+ HTTPLinkValidationResult httpResult =
(HTTPLinkValidationResult)result;
- lcr.setStatus( LinkcheckFileResult.ERROR );
+
+ if ( httpResult.getHttpStatusCode() > 0 &&
getExcludedHttpStatusErrors() != null
+ && StringUtils.indexOfAny( String.valueOf(
httpResult.getHttpStatusCode() ),
+ toStringArray(
getExcludedHttpStatusErrors() ) ) >= 0 )
+ {
+ ignoredError = true;
+ }
+ }
+
+ if (ignoredError)
+ {
+ linkcheckFile.setSuccessful(
linkcheckFile.getSuccessful() + 1 );
+ }
+ else
+ {
+ linkcheckFile.setUnsuccessful(
linkcheckFile.getUnsuccessful() + 1 );
+ }
+
+ lcr.setStatus( ignoredError ? LinkcheckFileResult.VALID :
LinkcheckFileResult.ERROR );
linkcheckFile.addResult( lcr );
break;
case LinkcheckFileResult.WARNING_LEVEL:
- linkcheckFile.setUnsuccessful(
linkcheckFile.getUnsuccessful() + 1 );
+ boolean ignoredWarning = false;
+ if ( result instanceof HTTPLinkValidationResult)
+ {
+ HTTPLinkValidationResult httpResult =
(HTTPLinkValidationResult)result;
+
+ if ( httpResult.getHttpStatusCode() > 0 &&
getExcludedHttpStatusWarnings() != null
+ && StringUtils.indexOfAny( String.valueOf(
httpResult.getHttpStatusCode() ),
+ toStringArray(
getExcludedHttpStatusWarnings() ) ) >= 0 )
+ {
+ ignoredWarning = true;
+ System.out.println("IGNORED
"+httpResult.getHttpStatusCode());
+ }
+ }
+
+ if (ignoredWarning)
+ {
+ linkcheckFile.setSuccessful(
linkcheckFile.getSuccessful() + 1 );
+ }
+ else
+ {
+ linkcheckFile.setUnsuccessful(
linkcheckFile.getUnsuccessful() + 1 );
+ }
- lcr.setStatus( LinkcheckFileResult.WARNING );
+ lcr.setStatus( ignoredWarning ? LinkcheckFileResult.VALID
: LinkcheckFileResult.WARNING );
linkcheckFile.addResult( lcr );
@@ -603,6 +758,21 @@
}
dir = null;
+ }
+
+ private static String[] toStringArray( int[] array )
+ {
+ if ( array == null )
+ {
+ throw new IllegalArgumentException( "array could not be null" );
+ }
+
+ String[] result = new String[array.length];
+ for ( int i = 0; i < array.length; i++ )
+ {
+ result[i] = String.valueOf( array[i] );
+ }
+ return result;
}
/** Custom FilenameFilter used to search html files */
Added:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/HTTPLinkValidationResult.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/HTTPLinkValidationResult.java?rev=616109&view=auto
==============================================================================
---
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/HTTPLinkValidationResult.java
(added)
+++
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/HTTPLinkValidationResult.java
Mon Jan 28 15:51:22 2008
@@ -0,0 +1,93 @@
+package org.apache.maven.doxia.linkcheck.validation;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * This class is used to return HTTP status responses from the validation
handlers.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class HTTPLinkValidationResult
+ extends LinkValidationResult
+{
+ /** serialVersionUID. */
+ static final long serialVersionUID = 3541710617127916373L;
+
+ /** The httpStatusCode. */
+ private final int httpStatusCode;
+
+ /**
+ * Constructor: initializes status, persistent and errorMessage.
+ * Using this constructor, the HTTP status code is by default
<code>-1</code>.
+ *
+ * @param stat The status.
+ * @param persistent The persistent.
+ * @param message The errorMessage.
+ */
+ public HTTPLinkValidationResult( int stat, boolean persistent, String
message )
+ {
+ super( stat, persistent, message );
+
+ this.httpStatusCode = -1;
+ }
+
+ /**
+ * Constructor: initializes status, persistent, httpStatusCode and
errorMessage.
+ *
+ * @param stat The status.
+ * @param persistent The persistent.
+ * @param httpStatusCode The httpStatusCode returned.
+ * @param message The errorMessage.
+ */
+ public HTTPLinkValidationResult( int stat, boolean persistent, int
httpStatusCode, String message )
+ {
+ super( stat, persistent, message );
+
+ this.httpStatusCode = httpStatusCode;
+ }
+
+ /** [EMAIL PROTECTED] */
+ public String getErrorMessage()
+ {
+ return this.httpStatusCode + " " + super.getErrorMessage();
+ }
+
+ /**
+ * Returns the httpStatusCode.
+ *
+ * @return int
+ */
+ public int getHttpStatusCode()
+ {
+ return this.httpStatusCode;
+ }
+
+ /** [EMAIL PROTECTED] */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer( super.toString() );
+
+ sb.append( '\n' );
+ sb.append( "httpStatusCode=" ).append( this.httpStatusCode );
+
+ return sb.toString();
+ }
+}
Propchange:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/HTTPLinkValidationResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/HTTPLinkValidationResult.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidationResult.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidationResult.java?rev=616109&r1=616108&r2=616109&view=diff
==============================================================================
---
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidationResult.java
(original)
+++
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidationResult.java
Mon Jan 28 15:51:22 2008
@@ -22,10 +22,8 @@
import java.io.Serializable;
/**
- * <p>
* This class is used to return status responses from the validation handlers.
A persistent result means that it can be
* stored in the persistent cache and used across runs.
- * </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ben Walding</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Arnaud Heritier</a>
@@ -97,7 +95,12 @@
/** [EMAIL PROTECTED] */
public String toString()
{
- return this.persistent + "/" + this.status + "/" + this.errorMessage;
- }
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( "persistent=" ).append( this.persistent ).append( '\n' );
+ sb.append( "status=" ).append( this.status ).append( '\n' );
+ sb.append( "errorMessage=" ).append( this.errorMessage );
+ return sb.toString();
+ }
}
Modified:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManager.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManager.java?rev=616109&r1=616108&r2=616109&view=diff
==============================================================================
---
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManager.java
(original)
+++
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManager.java
Mon Jan 28 15:51:22 2008
@@ -22,6 +22,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.maven.doxia.linkcheck.model.LinkcheckFileResult;
+import org.codehaus.plexus.util.SelectorUtils;
+import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.FileInputStream;
@@ -56,7 +58,7 @@
private List validators = new LinkedList();
/** excludes. */
- private String[] excludes = new String[0];
+ private String[] excludedLinks = new String[0];
/** cache. */
private Map cache = new HashMap();
@@ -72,23 +74,27 @@
}
/**
- * Returns the excludes.
+ * Returns the excludedLinks.
+ * Could contains a link, i.e.
<code>http://maven.apache.org/</code>,
+ * or pattern links i.e.
<code>http://maven.apache.org/**/*.html</code>
*
* @return String[]
*/
- public String[] getExcludes()
+ public String[] getExcludedLinks()
{
- return this.excludes;
+ return this.excludedLinks;
}
/**
- * Sets the excludes.
+ * Sets the excludedLinks.
+ * Could contains a link, i.e.
<code>http://maven.apache.org/</code>,
+ * or pattern links i.e.
<code>http://maven.apache.org/**/*.html</code>
*
* @param excl The excludes to set.
*/
- public void setExcludes( String[] excl )
+ public void setExcludedLinks( String[] excl )
{
- this.excludes = excl;
+ this.excludedLinks = excl;
}
/**
@@ -116,9 +122,9 @@
return cachedResult;
}
- for ( int i = 0; i < this.excludes.length; i++ )
+ for ( int i = 0; i < this.excludedLinks.length; i++ )
{
- if ( this.excludes[i] != null && lvi.getLink().startsWith(
this.excludes[i] ) )
+ if ( this.excludedLinks[i] != null && matchPattern( lvi.getLink(),
this.excludedLinks[i] ) )
{
if ( LOG.isDebugEnabled() )
{
@@ -364,5 +370,26 @@
public void setCachedResult( Object resourceKey, LinkValidationResult lvr )
{
this.cache.put( resourceKey, lvr );
+ }
+
+ protected static boolean matchPattern( String link, String pattern )
+ {
+ if ( pattern.indexOf( '*' ) == -1 )
+ {
+ if ( pattern.endsWith( "/" ) )
+ {
+ return link.indexOf( pattern.substring( 0,
pattern.lastIndexOf( '/' ) ) ) != -1;
+ }
+
+ return link.indexOf( pattern ) != -1;
+ }
+
+ String diff = StringUtils.difference( link, pattern );
+ if ( diff.startsWith( "/" ) )
+ {
+ return SelectorUtils.match( pattern, link + "/" );
+ }
+
+ return SelectorUtils.match( pattern, link );
}
}
Modified:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java?rev=616109&r1=616108&r2=616109&view=diff
==============================================================================
---
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java
(original)
+++
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/java/org/apache/maven/doxia/linkcheck/validation/OnlineHTTPLinkValidator.java
Mon Jan 28 15:51:22 2008
@@ -142,8 +142,12 @@
{
if ( getBaseURL() == null )
{
- LOG.warn( "Cannot check link [" + link + "] in page [" +
lvi.getSource()
+ if ( LOG.isWarnEnabled() )
+ {
+
+ LOG.warn( "Cannot check link [" + link + "] in page ["
+ lvi.getSource()
+ "], as no base URL has been set!" );
+ }
return new LinkValidationResult(
LinkcheckFileResult.WARNING_LEVEL, false,
"No base URL specified" );
}
@@ -161,11 +165,7 @@
{
if ( LOG.isDebugEnabled() )
{
- LOG.error( "Received: [" + t + "] for [" + link + "] in
page [" + lvi.getSource() + "]", t );
- }
- else
- {
- LOG.error( "Received: [" + t + "] for [" + link + "] in
page [" + lvi.getSource() + "]" );
+ LOG.debug( "Received: [" + t + "] for [" + link + "] in
page [" + lvi.getSource() + "]", t );
}
return new LinkValidationResult(
LinkcheckFileResult.ERROR_LEVEL, false, t.getClass().getName() + " : "
@@ -179,8 +179,7 @@
if ( hm.getStatusCode() == HttpStatus.SC_OK )
{
- return new LinkValidationResult(
LinkcheckFileResult.VALID_LEVEL, true, hm.getStatusCode() + " "
- + hm.getStatusText() );
+ return new HTTPLinkValidationResult(
LinkcheckFileResult.VALID_LEVEL, true, hm.getStatusCode(), hm.getStatusText() );
}
// If there's a redirection ... add a warning
@@ -188,25 +187,29 @@
|| hm.getStatusCode() ==
HttpStatus.SC_MOVED_TEMPORARILY
|| hm.getStatusCode() ==
HttpStatus.SC_TEMPORARY_REDIRECT )
{
- LOG.warn( "Received: [" + hm.getStatusCode() + "] for [" +
link + "] in page ["
- + lvi.getSource() + "]" );
+ if ( LOG.isWarnEnabled() )
+ {
+ LOG.warn( "Received: [" + hm.getStatusCode() + "] for [" +
link + "] in page [" + lvi.getSource()
+ + "]" );
+ }
- return new LinkValidationResult(
LinkcheckFileResult.WARNING_LEVEL, true, hm.getStatusCode() + " "
- + hm.getStatusText() );
+ return new HTTPLinkValidationResult(
LinkcheckFileResult.WARNING_LEVEL, true, hm.getStatusCode(), hm.getStatusText()
);
}
- LOG.error( "Received: [" + hm.getStatusCode() + "] for [" + link +
"] in page ["
- + lvi.getSource() + "]" );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Received: [" + hm.getStatusCode() + "] for [" +
link + "] in page [" + lvi.getSource()
+ + "]" );
+ }
- return new LinkValidationResult( LinkcheckFileResult.ERROR_LEVEL,
false, hm.getStatusCode() + " "
- + hm.getStatusText() );
+ return new HTTPLinkValidationResult(
LinkcheckFileResult.ERROR_LEVEL, false, hm.getStatusCode(), hm.getStatusText()
);
}
catch ( Throwable t )
{
if ( LOG.isDebugEnabled() )
{
- LOG.error( "Received: [" + t + "] for [" + link + "] in page
[" + lvi.getSource() + "]", t );
+ LOG.debug( "Received: [" + t + "] for [" + link + "] in page
[" + lvi.getSource() + "]", t );
}
else
{
Added:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/resources/log4j.properties
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/resources/log4j.properties?rev=616109&view=auto
==============================================================================
---
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/resources/log4j.properties
(added)
+++
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/resources/log4j.properties
Mon Jan 28 15:51:22 2008
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+log4j.rootCategory=INFO, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%c{1}:%L] %d{ISO8601} -
%m%n
+
+log4j.logger.org.apache.commons.httpclient=ERROR
Propchange:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/main/resources/log4j.properties
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/test/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManagerTest.java
URL:
http://svn.apache.org/viewvc/maven/sandbox/trunk/doxia/doxia-linkcheck/src/test/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManagerTest.java?rev=616109&view=auto
==============================================================================
---
maven/sandbox/trunk/doxia/doxia-linkcheck/src/test/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManagerTest.java
(added)
+++
maven/sandbox/trunk/doxia/doxia-linkcheck/src/test/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManagerTest.java
Mon Jan 28 15:51:22 2008
@@ -0,0 +1,67 @@
+package org.apache.maven.doxia.linkcheck.validation;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a>
+ * @version $Id$
+ */
+public class LinkValidatorManagerTest
+ extends TestCase
+{
+
+ public void testMatchPattern() throws Exception
+ {
+ String link = "http://maven.apache.org";
+ String pattern = "http://maven.apache.org";
+ assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
+
+ link = "http://maven.apache.org/";
+ pattern = "http://maven.apache.org";
+ assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
+
+ link = "http://maven.apache.org";
+ pattern = "http://maven.apache.org/";
+ assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
+
+ link = "http://maven.apache.org/test.html";
+ pattern = "http://maven.apache.org/";
+ assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
+
+ link = "http://maven.apache.org";
+ pattern = "http://maven.apache.org/*";
+ assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
+ assertTrue( LinkValidatorManager.matchPattern( link + "/", pattern ) );
+
+ link = "http://maven.apache.org/test/test.html";
+ pattern = "http://maven.apache.org/**/*";
+ assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
+
+ link = "http://maven.apache.org/test/test.html";
+ pattern = "http://maven.apache.org/*.html";
+ assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
+
+ link = "http://maven.apache.org/test/test.html";
+ pattern = "http://maven.apache.org/**/*.jsp";
+ assertFalse( LinkValidatorManager.matchPattern( link, pattern ) );
+ }
+}
Propchange:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/test/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/sandbox/trunk/doxia/doxia-linkcheck/src/test/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManagerTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"