]> source.dussan.org Git - archiva.git/commitdiff
Making unit tests more resilient on windows.
authorJoakim Erdfelt <joakime@apache.org>
Thu, 26 Apr 2007 15:07:56 +0000 (15:07 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Thu, 26 Apr 2007 15:07:56 +0000 (15:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@532772 13f79535-47bb-0310-9956-ffa450edef68

archiva-base/archiva-xml-tools/src/test/examples/no-prolog-with-entities.xml-resolved [deleted file]
archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java
archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/LatinEntityResolutionReaderTest.java
archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLReaderTest.java
archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/XMLWriterTest.java

diff --git a/archiva-base/archiva-xml-tools/src/test/examples/no-prolog-with-entities.xml-resolved b/archiva-base/archiva-xml-tools/src/test/examples/no-prolog-with-entities.xml-resolved
deleted file mode 100644 (file)
index c6fd401..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<basic>
-  <names>
-    <name>Trygve Laugstøl</name>
-    <name>The ∞ Archiva</name>
-  </names>
-</basic>
\ No newline at end of file
index 25a9f6261c79f57901a09d250608a0c3957c7e6e..89dd0d3363787661a725a89e297bdc6247397e4a 100644 (file)
@@ -32,7 +32,11 @@ import junit.framework.TestCase;
 public abstract class AbstractArchivaXmlTestCase
     extends TestCase
 {
-
+    protected static final String OSLASH = "\u00f8";
+    protected static final String TRYGVIS = "Trygve Laugst" + OSLASH + "l";
+    protected static final String INFIN = "\u221e";
+    protected static final String INFINITE_ARCHIVA = "The " + INFIN + " Archiva";
+    
     protected File getExampleXml( String filename )
     {
         File examplesDir = new File( "src/test/examples" );
@@ -47,5 +51,4 @@ public abstract class AbstractArchivaXmlTestCase
         }
         return exampleFile;
     }
-
 }
index bd6e5acc7d4d847b774eba974363676b0fe821c1..7da0f60c105ae6908e5ac2c3a87e28f2edc8cc6e 100644 (file)
@@ -115,30 +115,85 @@ public class LatinEntityResolutionReaderTest
         }
     }
 
+    private void assertProperRead( StringBuffer expected, String sourcePath, int bufSize )
+    {
+        try
+        {
+            File inputFile = getExampleXml( sourcePath );
+
+            FileReader fileReader = new FileReader( inputFile );
+            LatinEntityResolutionReader testReader = new LatinEntityResolutionReader( fileReader );
+
+            String actualOutput = toStringFromReader( testReader, bufSize );
+
+            assertEquals( "Proper Read: ", expected.toString(), actualOutput );
+        }
+        catch ( IOException e )
+        {
+            fail( "IOException: " + e.getMessage() );
+        }
+    }
+
     public void testReaderNormalBufsize()
         throws IOException
     {
-        assertProperRead( "no-prolog-with-entities.xml", "no-prolog-with-entities.xml-resolved", 4096 );
+        StringBuffer expected = new StringBuffer();
+
+        expected.append( "<basic>\n" );
+        expected.append( "  <names>\n" );
+        expected.append( "    <name>" ).append( TRYGVIS ).append( "</name>\n" );
+        expected.append( "    <name>" ).append( INFINITE_ARCHIVA ).append( "</name>\n" );
+        expected.append( "  </names>\n" );
+        expected.append( "</basic>" );
+
+        assertProperRead( expected, "no-prolog-with-entities.xml", 4096 );
     }
 
     public void testReaderSmallBufsize()
         throws IOException
     {
-        assertProperRead( "no-prolog-with-entities.xml", "no-prolog-with-entities.xml-resolved", 1024 );
+        StringBuffer expected = new StringBuffer();
+
+        expected.append( "<basic>\n" );
+        expected.append( "  <names>\n" );
+        expected.append( "    <name>" ).append( TRYGVIS ).append( "</name>\n" );
+        expected.append( "    <name>" ).append( INFINITE_ARCHIVA ).append( "</name>\n" );
+        expected.append( "  </names>\n" );
+        expected.append( "</basic>" );
+
+        assertProperRead( expected, "no-prolog-with-entities.xml", 1024 );
     }
 
     public void testReaderRediculouslyTinyBufsize()
         throws IOException
     {
-        assertProperRead( "no-prolog-with-entities.xml", "no-prolog-with-entities.xml-resolved", 32 );
+        StringBuffer expected = new StringBuffer();
+
+        expected.append( "<basic>\n" );
+        expected.append( "  <names>\n" );
+        expected.append( "    <name>" ).append( TRYGVIS ).append( "</name>\n" );
+        expected.append( "    <name>" ).append( INFINITE_ARCHIVA ).append( "</name>\n" );
+        expected.append( "  </names>\n" );
+        expected.append( "</basic>" );
+
+        assertProperRead( expected, "no-prolog-with-entities.xml", 32 );
     }
 
     public void testReaderHugeBufsize()
         throws IOException
     {
-        assertProperRead( "no-prolog-with-entities.xml", "no-prolog-with-entities.xml-resolved", 409600 );
+        StringBuffer expected = new StringBuffer();
+
+        expected.append( "<basic>\n" );
+        expected.append( "  <names>\n" );
+        expected.append( "    <name>" ).append( TRYGVIS ).append( "</name>\n" );
+        expected.append( "    <name>" ).append( INFINITE_ARCHIVA ).append( "</name>\n" );
+        expected.append( "  </names>\n" );
+        expected.append( "</basic>" );
+
+        assertProperRead( expected, "no-prolog-with-entities.xml", 409600 );
     }
-    
+
     public void testNoLatinEntitiesHugeLine()
     {
         assertProperRead( "commons-codec-1.2.pom", "commons-codec-1.2.pom", 4096 );
index 7cf8853f7b9834a5c10e51b703c1ed8d856b9dc8..7686ed39c93e2474cca758003fb9e18d001df932 100644 (file)
@@ -35,11 +35,6 @@ 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() );
index f8dcde2abfa7b014689ae98926c37252af6b763e..a3d59d9b998ce838e4588f3d5e6b938c7f7ca58b 100644 (file)
@@ -44,8 +44,8 @@ public class XMLWriterTest
         Document doc = DocumentHelper.createDocument( basic );
 
         Element names = basic.addElement( "names" );
-        names.addElement( "name" ).setText( "Trygve Laugst\u00f8l" );
-        names.addElement( "name" ).setText( "The \u221e Archiva" );
+        names.addElement( "name" ).setText( TRYGVIS );
+        names.addElement( "name" ).setText( INFINITE_ARCHIVA );
 
         StringWriter actual = new StringWriter();
         XMLWriter.write( doc, actual );