aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames William Dumay <jdumay@apache.org>2008-11-24 03:16:29 +0000
committerJames William Dumay <jdumay@apache.org>2008-11-24 03:16:29 +0000
commite92550d80f0b4eed196433a61a2a9cda5d8c418a (patch)
tree0227781c998309d8a4fc458242aa907604f89683
parentba4bf4402d46713eb4b36b61e053db6c3a6494bc (diff)
downloadarchiva-e92550d80f0b4eed196433a61a2a9cda5d8c418a.tar.gz
archiva-e92550d80f0b4eed196433a61a2a9cda5d8c418a.zip
MRM-1020 - Fix the crazy alpaca on Windows. Submitted by Martin Cooper
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@720105 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/Banner.java11
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/startup/BannerTest.java8
2 files changed, 13 insertions, 6 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/Banner.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/Banner.java
index 6430960a8..87bd73a06 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/Banner.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/Banner.java
@@ -32,8 +32,13 @@ import org.slf4j.LoggerFactory;
*/
public class Banner
{
+ private static final String eol = System.getProperty("line.separator");
+
public static String encode( String raw )
{
+ // Canonicalize line ends to make them easier to process
+ raw = raw.replace("\r\n", "\n").replace("\r", "\n");
+
StringBuffer encoded = new StringBuffer();
int rawlen = raw.length();
@@ -124,7 +129,7 @@ public class Banner
}
else if ( nc == 'n' )
{
- decoded.append( '\n' );
+ decoded.append( eol );
i++;
}
else if ( Character.isDigit( nc ) )
@@ -206,7 +211,7 @@ public class Banner
public static String getBanner( String version )
{
String encodedBanner = "$26 $34_$n$15 /$._$7 /$34 $.$n$14 /`/@),$4 | Ba" +
- " orunys bs nyy bs gur nycnpn'f |$n$14 | (~' __| gbvyvat njnl ba " +
+ " orunys bs nyy bs gur nycnpnf |$n$14 | (~' __| gbvyvat njnl ba " +
"gur Ncnpur Nepuvin |$n$6 _,--.$3_/ |$4 $.$5 cebwrpg grnz, V jbhyq y" +
"vxr gb$3 |$n$4 ,' ,$5 ($3 |$5 $.$5 jrypbzr lbh gb Nepuvin$6 |$" +
"n$4 | ($6 $. /$6 | $32# |$n$5 $. )$._/ ,_/$7 |$36 |$n$5 / /$3 " +
@@ -219,6 +224,6 @@ public class Banner
public static void display()
{
String banner = getBanner( ArchivaVersion.determineVersion() );
- LoggerFactory.getLogger( Banner.class ).info( StringUtils.repeat( "_", 25 ) + "\n" + banner );
+ LoggerFactory.getLogger( Banner.class ).info( StringUtils.repeat( "_", 25 ) + eol + banner );
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/startup/BannerTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/startup/BannerTest.java
index 2c5b5fc77..8db84ea35 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/startup/BannerTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/startup/BannerTest.java
@@ -36,6 +36,8 @@ import junit.framework.TestCase;
public class BannerTest
extends TestCase
{
+ private static final String eol = System.getProperty("line.separator");
+
private void assertEncodeDecode( String encoded, String decoded )
{
assertEquals( "Encoding: ", encoded, Banner.encode( decoded ) );
@@ -45,7 +47,7 @@ public class BannerTest
public void testEncodeDecode()
{
assertEncodeDecode( "[$10 ]", "[ ]" );
- assertEncodeDecode( "$$$5_$n$5_", "$_____\n_____" );
+ assertEncodeDecode( "$$$5_$n$5_", "$_____"+eol+"_____" );
assertEncodeDecode( "$${Refgjuvyr}", "${Erstwhile}" );
}
@@ -54,8 +56,8 @@ public class BannerTest
assertEquals( "[ 1.0 ]", Banner.injectVersion( "[#####]", "1.0" ) );
assertEquals( ".\\ 1.0-SNAPSHOT \\._____", Banner.injectVersion( ".\\################\\._____",
"1.0-SNAPSHOT" ) );
- assertEquals( "Archiva:\n ( 1.0-alpha-1 )", Banner
- .injectVersion( "Archiva:\n (##############)", "1.0-alpha-1" ) );
+ assertEquals( "Archiva:\"+eol+\" ( 1.0-alpha-1 )", Banner
+ .injectVersion( "Archiva:\"+eol+\" (##############)", "1.0-alpha-1" ) );
}
public void testGetBanner()