Author: vsiveton
Date: Mon Feb 18 03:46:58 2008
New Revision: 628688
URL: http://svn.apache.org/viewvc?rev=628688&view=rev
Log:
MPIR-84: StringIndexOutOfBoundsException when ML archive dont finish with a /
o fixed and add a test case
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
Modified: maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml?rev=628688&r1=628687&r2=628688&view=diff
==============================================================================
--- maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml Mon Feb 18
03:46:58 2008
@@ -303,6 +303,11 @@
<version>1.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit-addons</groupId>
+ <artifactId>junit-addons</artifactId>
+ <version>1.4</version>
+ </dependency>
</dependencies>
<properties>
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java?rev=628688&r1=628687&r2=628688&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
Mon Feb 18 03:46:58 2008
@@ -77,7 +77,7 @@
// Private
// ----------------------------------------------------------------------
- private static class MailingListsRenderer
+ protected static class MailingListsRenderer
extends AbstractMavenReportRenderer
{
private Model model;
@@ -271,7 +271,13 @@
{
fromIndex = 0;
}
+
int from = uri.indexOf( "/", fromIndex );
+
+ if ( from == -1 )
+ {
+ return uri.substring( at + 2 );
+ }
return uri.substring( at + 2, from );
}
Modified:
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java?rev=628688&r1=628687&r2=628688&view=diff
==============================================================================
---
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
(original)
+++
maven/plugins/trunk/maven-project-info-reports-plugin/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
Mon Feb 18 03:46:58 2008
@@ -22,6 +22,10 @@
import java.net.URL;
import java.util.Locale;
+import
org.apache.maven.report.projectinfo.MailingListsReport.MailingListsRenderer;
+
+import junitx.util.PrivateAccessor;
+
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.TextBlock;
import com.meterware.httpunit.WebConversation;
@@ -94,5 +98,41 @@
{
Locale.setDefault( oldLocale );
}
+ }
+
+ /**
+ * @throws Exception if any
+ * @throws Throwable if any
+ */
+ public void testGetArchiveServer()
+ throws Exception, Throwable
+ {
+ String server =
"http://mail-archives.apache.org/mod_mbox/maven-announce/";
+ assertEquals( "mail-archives.apache.org", invokeGetArchiveServer(
server ) );
+
+ server = "http://mail-archives.apache.org/mod_mbox/maven-announce";
+ assertEquals( "mail-archives.apache.org", invokeGetArchiveServer(
server ) );
+
+ server = "http://www.mail-archive.com/[EMAIL PROTECTED]";
+ assertEquals( "www.mail-archive.com", invokeGetArchiveServer( server )
);
+
+ server = "http://www.nabble.com/Maven-Announcements-f15617.html";
+ assertEquals( "www.nabble.com", invokeGetArchiveServer( server ) );
+
+ server = "http://maven.announce.markmail.org/";
+ assertEquals( "maven.announce.markmail.org", invokeGetArchiveServer(
server ) );
+
+ server = "http://maven.announce.markmail.org";
+ assertEquals( "maven.announce.markmail.org", invokeGetArchiveServer(
server ) );
+ }
+
+ /**
+ * @throws Throwable if any
+ */
+ private static String invokeGetArchiveServer( String s )
+ throws Throwable
+ {
+ return (String)PrivateAccessor.invoke( MailingListsRenderer.class,
"getArchiveServer",
+ new Class[] { String.class }, new Object[] { s
} );
}
}