in wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java [1599:1650]
private String writeTestFile( File parent, String child, String compressionType )
throws IOException
{
File file = new File( parent, child );
file.getParentFile().mkdirs();
file.deleteOnExit();
OutputStream out = new FileOutputStream( file );
try
{
out.write( child.getBytes() );
}
finally
{
out.close();
}
String ext = "";
if ( "gzip".equals( compressionType ) )
{
ext = ".gz";
}
if ( "deflate".equals( compressionType ) )
{
ext = ".deflate";
}
file = new File( parent, child + ext );
file.deleteOnExit();
String content;
out = new FileOutputStream( file );
if ( "gzip".equals( compressionType ) )
{
out = new GZIPOutputStream( out );
}
if ( "deflate".equals( compressionType ) )
{
out = new DeflaterOutputStream( out );
}
try
{
// write out different data than non-compressed file, so we can
// assert the compressed version was returned
content = file.getAbsolutePath();
out.write( content.getBytes() );
}
finally
{
out.close();
}
return content;
}