o Stabilized tests

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@721713 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2008-11-29 20:38:27 +00:00
parent 0c085889ae
commit 1927fa4ddf
2 changed files with 25 additions and 15 deletions

View File

@ -210,7 +210,7 @@ public class DefaultWagonManagerTest
wagonManager.getArtifact( artifact, repo, false ); wagonManager.getArtifact( artifact, repo, false );
assertTrue( artifact.getFile().exists() ); assertTrue( artifact.getFile().exists() );
assertEquals( "expected", FileUtils.fileRead( artifact.getFile() ) ); assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify(); control.verify();
} }
@ -220,6 +220,7 @@ public class DefaultWagonManagerTest
{ {
Artifact artifact = createTestPomArtifact( "target/test-data/get-remote-pom" ); Artifact artifact = createTestPomArtifact( "target/test-data/get-remote-pom" );
artifact.getFile().createNewFile(); artifact.getFile().createNewFile();
artifact.getFile().setLastModified( System.currentTimeMillis() - 60 * 1000 );
ArtifactRepository repo = createStringRepo(); ArtifactRepository repo = createStringRepo();
@ -235,7 +236,7 @@ public class DefaultWagonManagerTest
wagonManager.getArtifact( artifact, repo, true ); wagonManager.getArtifact( artifact, repo, true );
assertTrue( artifact.getFile().exists() ); assertTrue( artifact.getFile().exists() );
assertEquals( "expected", FileUtils.fileRead( artifact.getFile() ) ); assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify(); control.verify();
} }
@ -300,7 +301,7 @@ public class DefaultWagonManagerTest
wagonManager.getArtifact( artifact, repo, false ); wagonManager.getArtifact( artifact, repo, false );
assertTrue( artifact.getFile().exists() ); assertTrue( artifact.getFile().exists() );
assertEquals( "expected", FileUtils.fileRead( artifact.getFile() ) ); assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify(); control.verify();
} }
@ -310,6 +311,7 @@ public class DefaultWagonManagerTest
{ {
Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "jar" ); Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "jar" );
artifact.getFile().createNewFile(); artifact.getFile().createNewFile();
artifact.getFile().setLastModified( System.currentTimeMillis() - 60 * 1000 );
ArtifactRepository repo = createStringRepo(); ArtifactRepository repo = createStringRepo();
@ -325,7 +327,7 @@ public class DefaultWagonManagerTest
wagonManager.getArtifact( artifact, repo, true ); wagonManager.getArtifact( artifact, repo, true );
assertTrue( artifact.getFile().exists() ); assertTrue( artifact.getFile().exists() );
assertEquals( "expected", FileUtils.fileRead( artifact.getFile() ) ); assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify(); control.verify();
} }
@ -355,7 +357,7 @@ public class DefaultWagonManagerTest
wagonManager.getArtifact( artifact, repo, false ); wagonManager.getArtifact( artifact, repo, false );
assertTrue( artifact.getFile().exists() ); assertTrue( artifact.getFile().exists() );
assertEquals( "expected", FileUtils.fileRead( artifact.getFile() ) ); assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify(); control.verify();
} }
@ -365,6 +367,7 @@ public class DefaultWagonManagerTest
{ {
Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "1.0-SNAPSHOT", "jar" ); Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "1.0-SNAPSHOT", "jar" );
artifact.getFile().createNewFile(); artifact.getFile().createNewFile();
artifact.getFile().setLastModified( System.currentTimeMillis() - 60 * 1000 );
ArtifactRepository repo = createStringRepo(); ArtifactRepository repo = createStringRepo();
@ -383,7 +386,7 @@ public class DefaultWagonManagerTest
wagonManager.getArtifact( artifact, repo, false ); wagonManager.getArtifact( artifact, repo, false );
assertTrue( artifact.getFile().exists() ); assertTrue( artifact.getFile().exists() );
assertEquals( "", FileUtils.fileRead( artifact.getFile() ) ); assertEquals( "", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify(); control.verify();
} }
@ -393,6 +396,7 @@ public class DefaultWagonManagerTest
{ {
Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "1.0-SNAPSHOT", "jar" ); Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "1.0-SNAPSHOT", "jar" );
artifact.getFile().createNewFile(); artifact.getFile().createNewFile();
artifact.getFile().setLastModified( System.currentTimeMillis() - 60 * 1000 );
ArtifactRepository repo = createStringRepo(); ArtifactRepository repo = createStringRepo();
@ -413,7 +417,7 @@ public class DefaultWagonManagerTest
wagonManager.getArtifact( artifact, repo, false ); wagonManager.getArtifact( artifact, repo, false );
assertTrue( artifact.getFile().exists() ); assertTrue( artifact.getFile().exists() );
assertEquals( "expected", FileUtils.fileRead( artifact.getFile() ) ); assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify(); control.verify();
} }
@ -423,6 +427,7 @@ public class DefaultWagonManagerTest
{ {
Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "1.0-SNAPSHOT", "jar" ); Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "1.0-SNAPSHOT", "jar" );
artifact.getFile().createNewFile(); artifact.getFile().createNewFile();
artifact.getFile().setLastModified( System.currentTimeMillis() - 60 * 1000 );
ArtifactRepository repo = createStringRepo(); ArtifactRepository repo = createStringRepo();
@ -440,7 +445,7 @@ public class DefaultWagonManagerTest
wagonManager.getArtifact( artifact, repo, true ); wagonManager.getArtifact( artifact, repo, true );
assertTrue( artifact.getFile().exists() ); assertTrue( artifact.getFile().exists() );
assertEquals( "expected", FileUtils.fileRead( artifact.getFile() ) ); assertEquals( "expected", FileUtils.fileRead( artifact.getFile(), "UTF-8" ) );
control.verify(); control.verify();
} }

View File

@ -19,8 +19,9 @@ package org.apache.maven.artifact.manager;
* under the License. * under the License.
*/ */
import java.io.File; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -33,9 +34,6 @@ import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.resource.Resource; import org.apache.maven.wagon.resource.Resource;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringInputStream;
import org.codehaus.plexus.util.StringOutputStream;
public class StringWagon public class StringWagon
extends StreamWagon extends StreamWagon
@ -71,7 +69,14 @@ public class StringWagon
resource.setContentLength( content.length() ); resource.setContentLength( content.length() );
resource.setLastModified( System.currentTimeMillis() ); resource.setLastModified( System.currentTimeMillis() );
inputData.setInputStream( new StringInputStream( content ) ); try
{
inputData.setInputStream( new ByteArrayInputStream( content.getBytes( "UTF-8" ) ) );
}
catch ( UnsupportedEncodingException e )
{
throw new Error( "broken JVM", e );
}
} }
else else
{ {
@ -83,7 +88,7 @@ public class StringWagon
public void fillOutputData( OutputData outputData ) public void fillOutputData( OutputData outputData )
throws TransferFailedException throws TransferFailedException
{ {
outputData.setOutputStream( new StringOutputStream() ); outputData.setOutputStream( new ByteArrayOutputStream() );
} }
@Override @Override