From 14e5ac5eb3e357dbfa2436765c78ce377238799c Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 26 Apr 2007 14:57:16 +0000 Subject: [PATCH] Fixes for tests under windows. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@532767 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/maven/archiva/xml/XMLReader.java | 2 +- .../apache/maven/archiva/xml/LatinEntitiesTest.java | 6 +++--- .../org/apache/maven/archiva/xml/XMLReaderTest.java | 11 ++++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLReader.java b/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLReader.java index 6985ef06a..900b7e7c9 100644 --- a/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLReader.java +++ b/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLReader.java @@ -102,7 +102,7 @@ public class XMLReader try { InputStream in = url.openStream(); - InputStreamReader inReader = new InputStreamReader( in ); + InputStreamReader inReader = new InputStreamReader( in, "UTF-8" ); LatinEntityResolutionReader latinReader = new LatinEntityResolutionReader( inReader ); this.document = reader.read( latinReader ); } diff --git a/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/LatinEntitiesTest.java b/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/LatinEntitiesTest.java index c2424f368..396d4b952 100644 --- a/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/LatinEntitiesTest.java +++ b/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/LatinEntitiesTest.java @@ -33,9 +33,9 @@ public class LatinEntitiesTest public void testResolveEntity() { // Good Entities. - assertEquals( "©", LatinEntities.resolveEntity( "©" ) ); - assertEquals( "∞", LatinEntities.resolveEntity( "∞" ) ); - assertEquals( "ø", LatinEntities.resolveEntity( "ø" ) ); + assertEquals( "\u00a9", LatinEntities.resolveEntity( "©" ) ); + assertEquals( "\u221e", LatinEntities.resolveEntity( "∞" ) ); + assertEquals( "\u00f8", LatinEntities.resolveEntity( "ø" ) ); // Bad Entities. assertEquals( "", LatinEntities.resolveEntity( "" ) ); diff --git a/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLReaderTest.java b/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLReaderTest.java index b02daeca3..7cf8853f7 100644 --- a/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLReaderTest.java +++ b/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLReaderTest.java @@ -35,6 +35,11 @@ import java.util.List; public class XMLReaderTest extends AbstractArchivaXmlTestCase { + private static final String OSLASH = "\u00f8"; + private static final String TRYGVIS = "Trygve Laugst" + OSLASH + "l"; + private static final String INFIN = "\u221e"; + private static final String INFINITE_ARCHIVA = "The " + INFIN + " Archiva"; + private void assertElementTexts( List elementList, String[] expectedTexts ) { assertEquals( "Element List Size", expectedTexts.length, elementList.size() ); @@ -70,7 +75,7 @@ public class XMLReaderTest XMLReader reader = new XMLReader( "basic", xmlFile ); List names = reader.getElementList( "//basic/names/name" ); - assertElementTexts( names, new String[] { "Trygve Laugstøl", "The ∞ Archiva" } ); + assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } ); } public void testNoPrologUtf8Read() @@ -80,7 +85,7 @@ public class XMLReaderTest XMLReader reader = new XMLReader( "basic", xmlFile ); List names = reader.getElementList( "//basic/names/name" ); - assertElementTexts( names, new String[] { "Trygve Laugstøl", "The ∞ Archiva" } ); + assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } ); } public void testPrologUtf8Read() @@ -90,7 +95,7 @@ public class XMLReaderTest XMLReader reader = new XMLReader( "basic", xmlFile ); List names = reader.getElementList( "//basic/names/name" ); - assertElementTexts( names, new String[] { "Trygve Laugstøl", "The ∞ Archiva" } ); + assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } ); } }