From e92550d80f0b4eed196433a61a2a9cda5d8c418a Mon Sep 17 00:00:00 2001 From: James William Dumay Date: Mon, 24 Nov 2008 03:16:29 +0000 Subject: [PATCH] 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 --- .../org/apache/maven/archiva/web/startup/Banner.java | 11 ++++++++--- .../apache/maven/archiva/web/startup/BannerTest.java | 8 +++++--- 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() -- 2.39.5