mirror of https://github.com/apache/archiva.git
Making unit tests more resilient on windows.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@532772 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
14e5ac5eb3
commit
423f26e756
|
@ -1,6 +0,0 @@
|
|||
<basic>
|
||||
<names>
|
||||
<name>Trygve Laugstøl</name>
|
||||
<name>The ∞ Archiva</name>
|
||||
</names>
|
||||
</basic>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue