-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f71f5b
commit 113668f
Showing
5 changed files
with
52 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ | |
import org.apache.maven.model.Model; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.codehaus.plexus.i18n.I18N; | ||
import org.codehaus.plexus.util.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
|
@@ -169,8 +168,9 @@ public void renderBody() | |
|
||
if ( mailingList.getArchive() != null && mailingList.getArchive().length() > 0 ) | ||
{ | ||
textRow.add( createLinkPatternedText( getArchiveServer( mailingList.getArchive() ), | ||
mailingList.getArchive() ) ); | ||
textRow.add( createLinkPatternedText( | ||
ProjectInfoReportUtils.getArchiveServer( mailingList.getArchive() ), | ||
mailingList.getArchive() ) ); | ||
} | ||
else | ||
{ | ||
|
@@ -183,7 +183,8 @@ public void renderBody() | |
Iterator<String> it = mailingList.getOtherArchives().iterator(); | ||
String otherArchive = it.next(); | ||
|
||
textRow.add( createLinkPatternedText( getArchiveServer( otherArchive ), otherArchive ) ); | ||
textRow.add( createLinkPatternedText( | ||
ProjectInfoReportUtils.getArchiveServer( otherArchive ), otherArchive ) ); | ||
|
||
tableRow( textRow.toArray( new String[textRow.size()] ) ); | ||
|
||
|
@@ -210,7 +211,8 @@ public void renderBody() | |
// Archive | ||
textRow.add( " " ); | ||
|
||
textRow.add( createLinkPatternedText( getArchiveServer( otherArchive ), otherArchive ) ); | ||
textRow.add( createLinkPatternedText( | ||
ProjectInfoReportUtils.getArchiveServer( otherArchive ), otherArchive ) ); | ||
|
||
tableRow( textRow.toArray( new String[textRow.size()] ) ); | ||
} | ||
|
@@ -250,41 +252,5 @@ private String createEmailLinkPatternedText( String text, String href, String de | |
return createLinkPatternedText( text, | ||
href.toLowerCase( Locale.ENGLISH ).startsWith( "mailto:" ) ? href : "mailto:" + href ); | ||
} | ||
|
||
/** | ||
* Convenience method to return the name of a web-based mailing list archive server. <br> | ||
* For instance, if the archive uri is <code>http://www.mail-archive.com/[email protected]</code>, this | ||
* method return <code>www.mail-archive.com</code> | ||
* | ||
* @param uri | ||
* @return the server name of a web-based mailing list archive server | ||
*/ | ||
private static String getArchiveServer( String uri ) | ||
{ | ||
if ( StringUtils.isEmpty( uri ) ) | ||
{ | ||
return "???UNKNOWN???"; | ||
} | ||
|
||
int at = uri.indexOf( "//" ); | ||
int fromIndex; | ||
if ( at >= 0 ) | ||
{ | ||
fromIndex = uri.lastIndexOf( '/', at - 1 ) >= 0 ? 0 : at + 2; | ||
} | ||
else | ||
{ | ||
fromIndex = 0; | ||
} | ||
|
||
int from = uri.indexOf( '/', fromIndex ); | ||
|
||
if ( from == -1 ) | ||
{ | ||
return uri.substring( at + 2 ); | ||
} | ||
|
||
return uri.substring( at + 2, from ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
import java.io.InputStream; | ||
import java.net.Authenticator; | ||
import java.net.PasswordAuthentication; | ||
import java.net.URI; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
import java.security.KeyManagementException; | ||
|
@@ -276,6 +277,23 @@ public static boolean isArtifactUrlValid( String url ) | |
return URL_VALIDATOR.isValid( url ); | ||
} | ||
|
||
/** | ||
* Convenience method to return the name of a web-based mailing list archive server. | ||
* For instance, if the archive URI is <code>http://www.mail-archive.com/[email protected]</code>, this | ||
* method returns <code>www.mail-archive.com</code> | ||
* | ||
* @param uri the URI parse | ||
* @return the server host of a web-based mailing list archive server | ||
*/ | ||
public static String getArchiveServer( String uri ) | ||
{ | ||
if ( uri == null ) | ||
{ | ||
return "???UNKNOWN???"; | ||
} | ||
return URI.create( uri ).getHost(); | ||
} | ||
|
||
/** | ||
* @param url not null | ||
* @param project not null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,6 @@ | |
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; | ||
|
@@ -108,39 +104,4 @@ public void testFrenchReport() | |
Locale.setDefault( oldLocale ); | ||
} | ||
} | ||
|
||
/** | ||
* @throws Throwable if any | ||
*/ | ||
public void testGetArchiveServer() | ||
throws 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 } ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,8 @@ | |
import org.mortbay.jetty.security.SslSocketConnector; | ||
import org.mortbay.jetty.webapp.WebAppContext; | ||
|
||
import static org.apache.maven.report.projectinfo.ProjectInfoReportUtils.getArchiveServer; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Vincent Siveton</a> | ||
* @version $Id$ | ||
|
@@ -191,6 +193,31 @@ public void testGetInputStreamURL() | |
// TODO need to test with a proxy | ||
} | ||
|
||
public void testGetArchiveServer() | ||
{ | ||
assertEquals( "???UNKNOWN???", getArchiveServer( null ) ); | ||
|
||
assertNull( getArchiveServer( "" ) ); | ||
|
||
assertEquals( "mail-archives.apache.org", | ||
getArchiveServer( "http://mail-archives.apache.org/mod_mbox/maven-announce/" ) ); | ||
|
||
assertEquals( "mail-archives.apache.org", | ||
getArchiveServer( "https://mail-archives.apache.org/mod_mbox/maven-announce/" ) ); | ||
|
||
assertEquals( "mail-archives.apache.org", | ||
getArchiveServer( "http://mail-archives.apache.org/mod_mbox/maven-announce" ) ); | ||
|
||
assertEquals( "www.mail-archive.com", | ||
getArchiveServer( "http://www.mail-archive.com/[email protected]" ) ); | ||
|
||
assertEquals( "www.nabble.com", getArchiveServer( "http://www.nabble.com/Maven-Announcements-f15617.html" ) ); | ||
|
||
assertEquals( "maven.announce.markmail.org", getArchiveServer( "http://maven.announce.markmail.org/" ) ); | ||
|
||
assertEquals( "maven.announce.markmail.org", getArchiveServer( "http://maven.announce.markmail.org" ) ); | ||
} | ||
|
||
private void startJetty( boolean isSSL, boolean withAuth ) | ||
throws Exception | ||
{ | ||
|