server.setHandler( handlers );
addConnectors( server );
server.start();
StreamingWagon wagon = (StreamingWagon) getWagon();
Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
if ( addSecurityHandler )
{
wagon.connect( testRepository, authInfo );
}
else
{
wagon.connect( testRepository );
}
try
{
for ( int i = 0; i < putNumber; i++ )
{
File sourceFile = new File( localRepositoryPath, "test-secured-put-resource" );
sourceFile.delete();
assertFalse( sourceFile.exists() );
File tempFile = File.createTempFile( "wagon", "tmp" );
tempFile.deleteOnExit();
String content = "put top secret";
FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
FileInputStream fileInputStream = new FileInputStream( tempFile );
try
{
wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
}
finally
{
fileInputStream.close();
tempFile.delete();
}
assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
}
}
finally
{
wagon.disconnect();
server.stop();
}
assertEquals( putNumber, putHandler.putCallNumber );
if ( addSecurityHandler )
{