fix compilation

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1385187 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-09-15 21:37:35 +00:00
parent 762f11300b
commit 833d272ab4
18 changed files with 161 additions and 150 deletions

View File

@ -57,6 +57,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -66,10 +67,8 @@ import java.util.regex.Matcher;
/**
* LegacyToDefaultConverter
*
*
*/
@Service( "artifactConverter#legacy-to-default" )
@Service ("artifactConverter#legacy-to-default")
public class LegacyToDefaultConverter
implements ArtifactConverter
{
@ -186,7 +185,7 @@ public class LegacyToDefaultConverter
}
}
@SuppressWarnings( "unchecked" )
@SuppressWarnings ("unchecked")
private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, FileTransaction transaction )
throws ArtifactConversionException
{
@ -211,7 +210,7 @@ public class LegacyToDefaultConverter
}
// Even if the checksums for the POM are invalid we should still convert the POM
contents = FileUtils.readFileToString( file, null );
contents = FileUtils.readFileToString( file, Charset.forName( "UTF-8" ) );
}
catch ( IOException e )
{
@ -227,7 +226,7 @@ public class LegacyToDefaultConverter
boolean matching = false;
if ( !force && targetFile.exists() )
{
String targetContents = FileUtils.readFileToString( targetFile, null );
String targetContents = FileUtils.readFileToString( targetFile, Charset.forName( "UTF-8" ) );
matching = targetContents.equals( contents );
}
if ( force || !matching )
@ -328,7 +327,7 @@ public class LegacyToDefaultConverter
File checksumFile = new File( file.getParentFile(), fileName );
if ( checksumFile.exists() )
{
String checksum = FileUtils.readFileToString( checksumFile, null );
String checksum = FileUtils.readFileToString( checksumFile, Charset.forName( "UTF-8" ) );
try
{
digester.verify( file, checksum );
@ -466,7 +465,7 @@ public class LegacyToDefaultConverter
return result;
}
@SuppressWarnings( "unchecked" )
@SuppressWarnings ("unchecked")
private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact )
{
String groupIdKey;

View File

@ -21,8 +21,9 @@ package org.apache.archiva.converter.artifact;
import junit.framework.TestCase;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.commons.io.FileUtils;
import org.apache.archiva.common.utils.FileUtil;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
@ -40,21 +41,19 @@ import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
/**
* LegacyToDefaultConverterTest
*
*
*/
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
@RunWith (ArchivaSpringJUnit4ClassRunner.class)
@ContextConfiguration (locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" })
public class LegacyToDefaultConverterTest
extends TestCase
{
@ -84,7 +83,7 @@ public class LegacyToDefaultConverterTest
Map<String, ArtifactRepositoryLayout> layoutsMap = plexusSisuBridge.lookupMap( ArtifactRepositoryLayout.class );
System.out.println("hints " + layoutsMap.keySet().toString() );
System.out.println( "hints " + layoutsMap.keySet().toString() );
ArtifactRepositoryLayout layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "legacy" );
@ -700,7 +699,7 @@ public class LegacyToDefaultConverterTest
File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) );
// clear warning before test related to MRM-1638
artifactConverter.clearWarnings();
artifactConverter.clearWarnings();
artifactConverter.convert( artifact, targetRepository );
checkSuccess( artifactConverter );
@ -746,7 +745,7 @@ public class LegacyToDefaultConverterTest
Thread.sleep( SLEEP_MILLIS );
// clear warning before test related to MRM-1638
artifactConverter.clearWarnings();
artifactConverter.clearWarnings();
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
@ -985,9 +984,10 @@ public class LegacyToDefaultConverterTest
private static void compareFiles( File expectedPomFile, File pomFile )
throws IOException
{
String expectedContent =
normalizeString( org.apache.commons.io.FileUtils.readFileToString( expectedPomFile, null ) );
String targetContent = normalizeString( org.apache.commons.io.FileUtils.readFileToString( pomFile, null ) );
String expectedContent = normalizeString(
org.apache.commons.io.FileUtils.readFileToString( expectedPomFile, Charset.forName( "UTF-8" ) ) );
String targetContent =
normalizeString( org.apache.commons.io.FileUtils.readFileToString( pomFile, Charset.forName( "UTF-8" ) ) );
assertEquals( "Check file match between " + expectedPomFile + " and " + pomFile, expectedContent,
targetContent );
}

View File

@ -20,6 +20,7 @@ package org.apache.archiva.configuration;
*/
import java.io.File;
import java.nio.charset.Charset;
import java.util.List;
import javax.inject.Inject;
import org.apache.archiva.common.utils.FileUtil;
@ -76,7 +77,7 @@ public class ArchivaConfigurationMRM789Test
"target/test-classes/org/apache/archiva/configuration/default-archiva.xml" );
FileUtils.writeStringToFile( generatedTestDefaultArchivaConfigFile, existingTestDefaultArchivaConfigFile,
null );
Charset.forName("UTF-8") );
ArchivaConfiguration archivaConfiguration =
lookup( ArchivaConfiguration.class, "test-defaults-default-repo-location-exists" );

View File

@ -20,6 +20,7 @@ package org.apache.archiva.configuration;
*/
import java.io.File;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
@ -259,7 +260,7 @@ public class ArchivaConfigurationTest
assertFalse( userFile.exists() );
userFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( userFile, "<configuration/>", null );
FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") );
ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" );
@ -350,7 +351,7 @@ public class ArchivaConfigurationTest
assertFalse( userFile.exists() );
baseFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( baseFile, "<configuration/>", null );
FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName("UTF-8") );
ArchivaConfiguration archivaConfiguration =
(ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user-fallback" );
@ -385,10 +386,10 @@ public class ArchivaConfigurationTest
assertFalse( userFile.exists() );
baseFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( baseFile, "<configuration/>", null );
FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName("UTF-8") );
userFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( userFile, "<configuration/>", null );
FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") );
ArchivaConfiguration archivaConfiguration =
(ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" );
@ -404,10 +405,10 @@ public class ArchivaConfigurationTest
assertTrue( "Check file exists", baseFile.exists() );
assertEquals( "Check base file is unchanged", "<configuration/>",
FileUtils.readFileToString( baseFile, null ) );
FileUtils.readFileToString( baseFile, Charset.forName("UTF-8") ) );
assertTrue( "Check file exists", userFile.exists() );
assertFalse( "Check base file is changed",
"<configuration/>".equals( FileUtils.readFileToString( userFile, null ) ) );
"<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName("UTF-8") ) ) );
// check it
configuration = archivaConfiguration.getConfiguration();
@ -430,7 +431,7 @@ public class ArchivaConfigurationTest
FileUtils.copyFile( getTestFile( "src/test/conf/conf-user.xml" ), userFile );
baseFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( baseFile, "<configuration/>", null );
FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName("UTF-8") );
ArchivaConfiguration archivaConfiguration =
(ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" );
@ -446,10 +447,10 @@ public class ArchivaConfigurationTest
assertTrue( "Check file exists", baseFile.exists() );
assertEquals( "Check base file is unchanged", "<configuration/>",
FileUtils.readFileToString( baseFile, null ) );
FileUtils.readFileToString( baseFile, Charset.forName("UTF-8") ) );
assertTrue( "Check file exists", userFile.exists() );
assertFalse( "Check base file is changed",
"<configuration/>".equals( FileUtils.readFileToString( userFile, null ) ) );
"<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName("UTF-8") ) ) );
// check it
configuration = archivaConfiguration.getConfiguration();
@ -472,7 +473,7 @@ public class ArchivaConfigurationTest
FileUtils.copyFile( getTestFile( "src/test/conf/conf-base.xml" ), baseFile );
userFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( userFile, "<configuration/>", null );
FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") );
ArchivaConfiguration archivaConfiguration =
(ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" );
@ -639,7 +640,7 @@ public class ArchivaConfigurationTest
assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() );
assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() );
String actualXML = FileUtils.readFileToString( userFile, null );
String actualXML = FileUtils.readFileToString( userFile, Charset.forName("UTF-8") );
XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML );
XMLAssert.assertXpathNotExists( "//configuration/repositories", actualXML );
}
@ -694,7 +695,7 @@ public class ArchivaConfigurationTest
FileUtils.copyFile( getTestFile( "src/test/conf/escape-cron-expressions.xml" ), baseFile );
userFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( userFile, "<configuration/>", null );
FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName( "UTF-8" ) );
final ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-cron-expressions" );
@ -747,7 +748,7 @@ public class ArchivaConfigurationTest
FileUtils.copyFile( getTestFile( "src/test/conf/conf-single-list-elements.xml" ), baseFile );
userFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( userFile, "<configuration/>", null );
FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") );
ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-remove-central" );

View File

@ -20,6 +20,7 @@ package org.apache.archiva.consumers.core.repository;
*/
import java.io.File;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
@ -134,7 +135,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
// check if metadata file was updated
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, null );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.forName( "UTF-8" ) );
String expectedVersions =
"<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";
@ -269,7 +270,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
// check if metadata file was not updated (because nothing was removed)
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, null );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.forName( "UTF-8" ) );
String expectedVersions = "<expected><versions><version>2.0.3-SNAPSHOT</version>"
+ "<version>2.0.4-SNAPSHOT</version></versions></expected>";

View File

@ -19,7 +19,6 @@ package org.apache.archiva.consumers.core.repository;
* under the License.
*/
import java.io.File;
import org.apache.archiva.admin.model.RepositoryCommonValidator;
import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
@ -35,14 +34,19 @@ import org.apache.archiva.metadata.repository.TestRepositorySessionFactory;
import org.apache.commons.io.FileUtils;
import org.custommonkey.xmlunit.XMLAssert;
import org.junit.After;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
import java.io.File;
import java.nio.charset.Charset;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
*/
@ContextConfiguration(
@ContextConfiguration (
locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-purge-consumer-test.xml" } )
public class RepositoryPurgeConsumerTest
extends AbstractRepositoryPurgeTest
@ -319,7 +323,7 @@ public class RepositoryPurgeConsumerTest
// check if metadata file wasn't updated
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, null );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.forName( "UTF-8" ) );
String expectedVersions = "<expected><versions><version>2.3-SNAPSHOT</version></versions></expected>";
@ -364,7 +368,7 @@ public class RepositoryPurgeConsumerTest
// check if metadata file was updated
File artifactMetadataFile = new File( projectRoot + "/maven-metadata.xml" );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, null );
String metadataXml = FileUtils.readFileToString( artifactMetadataFile, Charset.forName( "UTF-8" ) );
String expectedVersions =
"<expected><versions><version>2.2</version>" + "<version>2.3</version></versions></expected>";

View File

@ -35,6 +35,7 @@ import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.maven.index.NexusIndexer;
@ -55,6 +56,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -62,17 +64,14 @@ import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.Locale;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import static org.junit.Assert.*;
/**
* AbstractProxyTestCase
*
*
*/
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
@RunWith ( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
public abstract class AbstractProxyTestCase
{
@Inject
@ -330,8 +329,10 @@ public abstract class AbstractProxyTestCase
actualFile.getCanonicalPath() );
assertEquals( "Check file path matches.", expectedFile.getAbsolutePath(), actualFile.getAbsolutePath() );
String expectedContents = org.apache.commons.io.FileUtils.readFileToString( sourceFile, null );
String actualContents = org.apache.commons.io.FileUtils.readFileToString( actualFile, null );
String expectedContents =
org.apache.commons.io.FileUtils.readFileToString( sourceFile, Charset.forName( "UTF-8" ) );
String actualContents =
org.apache.commons.io.FileUtils.readFileToString( actualFile, Charset.forName( "UTF-8" ) );
assertEquals( "Check file contents.", expectedContents, actualContents );
}
@ -340,7 +341,7 @@ public abstract class AbstractProxyTestCase
assertNull( "Found file: " + downloadedFile + "; but was expecting a failure", downloadedFile );
}
@SuppressWarnings( "unchecked" )
@SuppressWarnings ( "unchecked" )
protected void assertNoTempFiles( File expectedFile )
{
File workingDir = expectedFile.getParentFile();

View File

@ -52,6 +52,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import static org.junit.Assert.*;
@ -206,8 +208,8 @@ public class HttpProxyTransferTest
downloadedFile.getCanonicalPath() );
assertEquals( "Check file path matches.", expectedFile.getAbsolutePath(), downloadedFile.getAbsolutePath() );
String expectedContents = FileUtils.readFileToString( sourceFile, null );
String actualContents = FileUtils.readFileToString( downloadedFile, null );
String expectedContents = FileUtils.readFileToString( sourceFile, Charset.forName( "UTF-8" ) );
String actualContents = FileUtils.readFileToString( downloadedFile, Charset.forName( "UTF-8") );
assertEquals( "Check file contents.", expectedContents, actualContents );
assertNull( System.getProperty( "http.proxyHost" ) );

View File

@ -19,24 +19,23 @@ package org.apache.archiva.proxy;
* under the License.
*/
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.policies.CachedFailuresPolicy;
import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.junit.Test;
import java.io.File;
import java.nio.charset.Charset;
import static org.junit.Assert.*;
/**
* ManagedDefaultTransferTest
*
*
*/
public class ManagedDefaultTransferTest
extends AbstractProxyTestCase
@ -60,7 +59,7 @@ public class ManagedDefaultTransferTest
// Attempt the proxy fetch.
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
assertNull("File should not have been downloaded", downloadedFile);
assertNull( "File should not have been downloaded", downloadedFile );
}
@Test
@ -206,7 +205,7 @@ public class ManagedDefaultTransferTest
File expectedFile = new File( managedDefaultDir, path );
File remoteFile = new File( REPOPATH_PROXIED1, path );
// Set the managed File to be newer than local.
setManagedNewerThanRemote( expectedFile, remoteFile );
@ -226,7 +225,7 @@ public class ManagedDefaultTransferTest
assertNotModified( expectedFile, originalModificationTime );
assertNoTempFiles( expectedFile );
}
/**
* <p>
* Request a file, that exists locally, and remotely.
@ -252,10 +251,10 @@ public class ManagedDefaultTransferTest
File expectedFile = new File( managedDefaultDir, path );
File remoteFile = new File( REPOPATH_PROXIED1, path );
// Set the managed file to be newer than remote file.
setManagedOlderThanRemote( expectedFile, remoteFile );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertTrue( expectedFile.exists() );
@ -317,8 +316,8 @@ public class ManagedDefaultTransferTest
assertNotExistsInManagedDefaultRepo( expectedFile );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1 , false );
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2 , false );
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false );
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, false );
// Attempt the proxy fetch.
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
@ -329,8 +328,8 @@ public class ManagedDefaultTransferTest
assertNoTempFiles( expectedFile );
// TODO: is this check even needed if it passes above?
String actualContents = FileUtils.readFileToString( downloadedFile, null );
String badContents = FileUtils.readFileToString( proxied2File, null );
String actualContents = FileUtils.readFileToString( downloadedFile, Charset.forName( "UTF-8" ) );
String badContents = FileUtils.readFileToString( proxied2File, Charset.forName( "UTF-8" ) );
assertFalse( "Downloaded file contents should not be that of proxy 2",
StringUtils.equals( actualContents, badContents ) );
}
@ -400,7 +399,7 @@ public class ManagedDefaultTransferTest
saveRemoteRepositoryConfig( "badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default" );
wagonMock.get( path, new File( expectedFile.getAbsolutePath() + ".tmp" ) );
wagonMockControl.setMatcher(customWagonGetMatcher);
wagonMockControl.setMatcher( customWagonGetMatcher );
wagonMockControl.setThrowable( new ResourceDoesNotExistException( "transfer failed" ) );
wagonMockControl.replay();
@ -440,13 +439,13 @@ public class ManagedDefaultTransferTest
File tmpFile = new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" );
wagonMock.get( path, tmpFile );
wagonMockControl.setMatcher(customWagonGetMatcher);
wagonMockControl.setMatcher( customWagonGetMatcher );
wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Can't find resource." ) );
wagonMock.get( path, tmpFile );
wagonMockControl.setMatcher(customWagonGetMatcher);
wagonMockControl.setMatcher( customWagonGetMatcher );
wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Can't find resource." ) );
wagonMockControl.replay();
@ -472,13 +471,13 @@ public class ManagedDefaultTransferTest
File expectedFile = new File( managedDefaultDir, path );
File remoteFile = new File( REPOPATH_PROXIED_LEGACY, legacyPath );
// Set the managed file to be newer than remote.
setManagedNewerThanRemote( expectedFile, remoteFile );
long expectedTimestamp = expectedFile.lastModified();
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
assertTrue( expectedFile.exists() );
// Configure Connector (usually done within archiva.xml configuration)
@ -533,7 +532,7 @@ public class ManagedDefaultTransferTest
assertNotExistsInManagedDefaultRepo( expectedFile );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_LEGACY_PROXIED, false);
saveConnector( ID_DEFAULT_MANAGED, ID_LEGACY_PROXIED, false );
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
@ -556,7 +555,7 @@ public class ManagedDefaultTransferTest
assertNotExistsInManagedDefaultRepo( expectedFile );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_LEGACY_PROXIED, false );
saveConnector( ID_DEFAULT_MANAGED, ID_LEGACY_PROXIED, false );
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );

View File

@ -36,16 +36,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
/**
* A dummy wagon implementation
*/
@Service( "wagon#test" )
@Service ("wagon#test")
public class WagonDelegate
implements Wagon
{
@ -91,7 +90,7 @@ public class WagonDelegate
return delegate.resourceExists( resourceName );
}
@SuppressWarnings( "unchecked" )
@SuppressWarnings ("unchecked")
public List<String> getFileList( String destinationDirectory )
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
{
@ -164,7 +163,7 @@ public class WagonDelegate
delegate.connect( source, authenticationInfo, proxyInfoProvider );
}
@SuppressWarnings( "deprecation" )
@SuppressWarnings ("deprecation")
public void openConnection()
throws ConnectionException, AuthenticationException
{
@ -247,7 +246,8 @@ public class WagonDelegate
}
else
{
FileUtils.writeStringToFile( new File( destination.getAbsolutePath() ), contentToGet, null );
FileUtils.writeStringToFile( new File( destination.getAbsolutePath() ), contentToGet,
Charset.forName( "UTF-8" ) );
}
}
catch ( IOException e )

View File

@ -46,6 +46,7 @@ import javax.inject.Named;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -55,20 +56,18 @@ import static org.junit.Assert.*;
/**
* MetadataToolsTest
*
*
*/
@ContextConfiguration(
@ContextConfiguration (
locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-metadata-tools-test.xml" } )
public class MetadataToolsTest
extends AbstractRepositoryLayerTestCase
{
@Inject
@Named( value = "metadataTools#test" )
@Named ( value = "metadataTools#test" )
private MetadataTools tools;
@Inject
@Named( value = "archivaConfiguration#mock" )
@Named ( value = "archivaConfiguration#mock" )
protected MockConfiguration config;
@Test
@ -389,7 +388,7 @@ public class MetadataToolsTest
throws LayoutException, IOException, SAXException, ParserConfigurationException
{
File metadataFile = new File( repository.getRepoRoot(), tools.toPath( reference ) );
String actualMetadata = FileUtils.readFileToString( metadataFile, null );
String actualMetadata = FileUtils.readFileToString( metadataFile, Charset.forName( "UTF-8" ) );
DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
if ( !detailedDiff.similar() )
@ -404,7 +403,7 @@ public class MetadataToolsTest
throws LayoutException, IOException, SAXException, ParserConfigurationException
{
File metadataFile = new File( repository.getRepoRoot(), tools.toPath( reference ) );
String actualMetadata = FileUtils.readFileToString( metadataFile, null );
String actualMetadata = FileUtils.readFileToString( metadataFile, Charset.forName( "UTF-8" ) );
DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadata, actualMetadata ) );
if ( !detailedDiff.similar() )

View File

@ -20,22 +20,21 @@ package org.apache.archiva.repository.metadata;
*/
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.archiva.model.ArchivaRepositoryMetadata;
import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
import org.custommonkey.xmlunit.XMLAssert;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.File;
import java.io.StringWriter;
import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
import java.nio.charset.Charset;
/**
* RepositoryMetadataWriterTest
*
*
* RepositoryMetadataWriterTest
*/
@RunWith( ArchivaBlockJUnit4ClassRunner.class )
@RunWith ( ArchivaBlockJUnit4ClassRunner.class )
public class RepositoryMetadataWriterTest
extends TestCase
{
@ -46,7 +45,7 @@ public class RepositoryMetadataWriterTest
{
File defaultRepoDir = new File( "src/test/repositories/default-repository" );
File expectedFile = new File( defaultRepoDir, "org/apache/maven/shared/maven-downloader/maven-metadata.xml" );
String expectedContent = FileUtils.readFileToString( expectedFile, null );
String expectedContent = FileUtils.readFileToString( expectedFile, Charset.forName( "UTF-8" ) );
ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();

View File

@ -39,6 +39,7 @@ import org.junit.After;
import org.junit.Before;
import java.io.File;
import java.nio.charset.Charset;
/**
* AbstractRepositoryServletProxiedTestCase
@ -211,7 +212,7 @@ public abstract class AbstractRepositoryServletProxiedTestCase
destFile.delete();
}
destFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( destFile, contents, null );
FileUtils.writeStringToFile( destFile, contents, Charset.forName( "UTF-8" ) );
return destFile;
}

View File

@ -31,6 +31,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.archiva.webdav.util.MavenIndexerCleaner;
import org.apache.commons.io.FileUtils;
import org.junit.After;
@ -45,15 +46,13 @@ import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import java.nio.charset.Charset;
/**
* AbstractRepositoryServletTestCase
*
*
*/
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/repository-servlet-simple.xml" } )
@RunWith ( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration ( locations = { "classpath*:/repository-servlet-simple.xml" } )
public abstract class AbstractRepositoryServletTestCase
extends TestCase
{
@ -183,7 +182,7 @@ public abstract class AbstractRepositoryServletTestCase
assertTrue( "File <" + actualFile.getAbsolutePath() + "> should be a file (not a dir/link/device/etc).",
actualFile.isFile() );
String actualContents = FileUtils.readFileToString( actualFile, null );
String actualContents = FileUtils.readFileToString( actualFile, Charset.forName( "UTF-8" ) );
assertEquals( "File Contents of <" + actualFile.getAbsolutePath() + ">", expectedContents, actualContents );
}
@ -296,7 +295,7 @@ public abstract class AbstractRepositoryServletTestCase
{
File destFile = new File( repoRootManaged, path );
destFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( destFile, contents, null );
FileUtils.writeStringToFile( destFile, contents, Charset.forName( "UTF-8" ) );
return destFile;
}
}

View File

@ -26,11 +26,10 @@ import org.apache.commons.io.FileUtils;
import org.junit.Test;
import java.io.File;
import java.nio.charset.Charset;
/**
* RepositoryServletTest
*
*
* RepositoryServletTest
*/
public class RepositoryServletNoProxyMetadataTest
extends AbstractRepositoryServletTestCase
@ -45,7 +44,7 @@ public class RepositoryServletNoProxyMetadataTest
File checksumFile = new File( repoRootInternal, commonsLangMetadata );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
@ -64,7 +63,7 @@ public class RepositoryServletNoProxyMetadataTest
File checksumFile = new File( repoRootInternal, commonsLangMetadata );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
@ -83,7 +82,7 @@ public class RepositoryServletNoProxyMetadataTest
File checksumFile = new File( repoRootInternal, commonsLangMetadata );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
@ -96,15 +95,17 @@ public class RepositoryServletNoProxyMetadataTest
public void testGetSnapshotVersionMetadataDefaultLayout()
throws Exception
{
String assemblyPluginMetadata = "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
String assemblyPluginMetadata =
"org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";
File checksumFile = new File( repoRootInternal, assemblyPluginMetadata );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
WebRequest request =
new GetMethodWebRequest( "http://machine.com/repository/internal/" + assemblyPluginMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
assertResponseOK( response );

View File

@ -28,6 +28,7 @@ import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.nio.charset.Charset;
import java.util.ArrayList;
/**
@ -56,7 +57,7 @@ public class RepositoryServletNoProxyTest
File checksumFile = new File( repoRootInternal, commonsLangSha1 );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 );
WebResponse response = getServletUnitClient().getResponse( request );
@ -73,7 +74,7 @@ public class RepositoryServletNoProxyTest
File checksumFile = new File( repoRootInternal, commonsLangSha1 );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 );
WebResponse response = getServletUnitClient().getResponse( request );
@ -91,7 +92,7 @@ public class RepositoryServletNoProxyTest
File checksumFile = new File( repoRootInternal, commonsLangSha1 );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar.sha1" );
@ -111,7 +112,7 @@ public class RepositoryServletNoProxyTest
File metadataFile = new File( repoRootInternal, commonsLangMetadata );
metadataFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
@ -130,7 +131,7 @@ public class RepositoryServletNoProxyTest
File metadataFile = new File( repoRootInternal, commonsLangMetadata );
metadataFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
@ -149,7 +150,7 @@ public class RepositoryServletNoProxyTest
File metadataFile = new File( repoRootInternal, commonsLangMetadata );
metadataFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
@ -168,7 +169,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
WebResponse response = getServletUnitClient().getResponse( request );
@ -187,7 +188,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar" );
@ -207,7 +208,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
WebResponse response = getServletUnitClient().getResponse( request );
@ -226,7 +227,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" );
@ -246,7 +247,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
WebResponse response = getServletUnitClient().getResponse( request );
@ -265,7 +266,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar" );
@ -288,7 +289,7 @@ public class RepositoryServletNoProxyTest
File checksumFile = new File( repoRootInternal, dualExtensionPath );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, expectedContents, null );
FileUtils.writeStringToFile( checksumFile, expectedContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + dualExtensionPath );
WebResponse response = getServletUnitClient().getResponse( request );
@ -307,7 +308,7 @@ public class RepositoryServletNoProxyTest
File checksumFile = new File( repoRootInternal, dualExtensionPath );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, expectedContents, null );
FileUtils.writeStringToFile( checksumFile, expectedContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/internal/" + "org.project/distributions/example-presentation-3.2.zip" );
@ -326,7 +327,7 @@ public class RepositoryServletNoProxyTest
File checksumFile = new File( repoRootLegacy, "commons-lang/jars/commons-lang-2.1.jar.sha1" );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 );
WebResponse response = getServletUnitClient().getResponse( request );
@ -343,7 +344,7 @@ public class RepositoryServletNoProxyTest
File checksumFile = new File( repoRootLegacy, commonsLangSha1 );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null );
FileUtils.writeStringToFile( checksumFile, "dummy-checksum", Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangSha1 );
WebResponse response = getServletUnitClient().getResponse( request );
@ -363,7 +364,7 @@ public class RepositoryServletNoProxyTest
File metadataFile = new File( repoRootLegacy, commonsLangMetadata );
metadataFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
@ -383,7 +384,7 @@ public class RepositoryServletNoProxyTest
File metadataFile = new File( repoRootLegacy, commonsLangMetadata );
metadataFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
@ -402,7 +403,7 @@ public class RepositoryServletNoProxyTest
File metadataFile = new File( repoRootLegacy, commonsLangMetadata );
metadataFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
WebResponse response = getServletUnitClient().getResponse( request );
@ -421,7 +422,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootLegacy, "commons-lang/jars/commons-lang-2.1.jar" );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = getServletUnitClient().getResponse( request );
@ -440,7 +441,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootLegacy, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = getServletUnitClient().getResponse( request );
@ -459,7 +460,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootLegacy, "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = getServletUnitClient().getResponse( request );
@ -478,7 +479,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootLegacy, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = getServletUnitClient().getResponse( request );
@ -498,7 +499,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootLegacy, "commons-lang/jars/" + filename );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = getServletUnitClient().getResponse( request );
@ -517,7 +518,7 @@ public class RepositoryServletNoProxyTest
File artifactFile = new File( repoRootLegacy, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
WebResponse response = getServletUnitClient().getResponse( request );
@ -539,7 +540,7 @@ public class RepositoryServletNoProxyTest
File checksumFile = new File( repoRootLegacy, "org.project/distributions/example-presentation-3.2.xml.zip" );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, expectedContents, null );
FileUtils.writeStringToFile( checksumFile, expectedContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath );
WebResponse response = getServletUnitClient().getResponse( request );
@ -558,7 +559,7 @@ public class RepositoryServletNoProxyTest
File checksumFile = new File( repoRootLegacy, dualExtensionPath );
checksumFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFile, expectedContents, null );
FileUtils.writeStringToFile( checksumFile, expectedContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath );
WebResponse response = getServletUnitClient().getResponse( request );

View File

@ -37,6 +37,7 @@ import org.junit.Test;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@ -148,7 +149,7 @@ public class RepositoryServletRepositoryGroupTest
File dummyInternalResourceFile = new File( repoRootFirst, resourceName );
dummyInternalResourceFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( dummyInternalResourceFile, "first", null );
FileUtils.writeStringToFile( dummyInternalResourceFile, "first", Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
@ -169,7 +170,7 @@ public class RepositoryServletRepositoryGroupTest
File dummyReleasesResourceFile = new File( repoRootLast, resourceName );
dummyReleasesResourceFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( dummyReleasesResourceFile, "last", null );
FileUtils.writeStringToFile( dummyReleasesResourceFile, "last", Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName );
@ -242,7 +243,7 @@ public class RepositoryServletRepositoryGroupTest
+ "<metadata>\n<groupId>dummy</groupId>\n<artifactId>dummy-merged-metadata-resource</artifactId>\n"
+ "<versioning>\n<latest>1.0</latest>\n<release>1.0</release>\n<versions>\n<version>1.0</version>\n"
+ "<version>2.5</version>\n</versions>\n<lastUpdated>20080708095554</lastUpdated>\n</versioning>\n</metadata>",
null );
Charset.forName( "UTF-8" ) );
//second metadata file
resourceName = "dummy/dummy-merged-metadata-resource/maven-metadata.xml";
@ -252,7 +253,7 @@ public class RepositoryServletRepositoryGroupTest
+ "<metadata><groupId>dummy</groupId><artifactId>dummy-merged-metadata-resource</artifactId>"
+ "<versioning><latest>2.0</latest><release>2.0</release><versions><version>1.0</version>"
+ "<version>1.5</version><version>2.0</version></versions><lastUpdated>20080709095554</lastUpdated>"
+ "</versioning></metadata>", null );
+ "</versioning></metadata>", Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/"
@ -273,11 +274,11 @@ public class RepositoryServletRepositoryGroupTest
//check if the checksum files were generated
File checksumFileSha1 = new File( repoRootFirst, resourceName + ".sha1" );
checksumFileSha1.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFileSha1, "3290853214d3687134", null );
FileUtils.writeStringToFile( checksumFileSha1, "3290853214d3687134", Charset.forName( "UTF-8" ) );
File checksumFileMd5 = new File( repoRootFirst, resourceName + ".md5" );
checksumFileMd5.getParentFile().mkdirs();
FileUtils.writeStringToFile( checksumFileMd5, "98745897234eda12836423", null );
FileUtils.writeStringToFile( checksumFileMd5, "98745897234eda12836423", Charset.forName( "UTF-8" ) );
// request the sha1 checksum of the metadata
request = new GetMethodWebRequest( "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/"
@ -307,13 +308,13 @@ public class RepositoryServletRepositoryGroupTest
File dummyInternalResourceFile = new File( repoRootFirst, resourceName );
dummyInternalResourceFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( dummyInternalResourceFile, "first", null );
FileUtils.writeStringToFile( dummyInternalResourceFile, "first", Charset.forName( "UTF-8" ) );
resourceName = "dummy/dummy-artifact/2.0/dummy-artifact-2.0.txt";
File dummyReleasesResourceFile = new File( repoRootLast, resourceName );
dummyReleasesResourceFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( dummyReleasesResourceFile, "last", null );
FileUtils.writeStringToFile( dummyReleasesResourceFile, "last", Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest(
"http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/dummy-artifact/" );

View File

@ -60,6 +60,8 @@ import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
/**
@ -407,7 +409,7 @@ public class RepositoryServletSecurityTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
InvocationContext ic = sc.newInvocation( request );
@ -463,7 +465,7 @@ public class RepositoryServletSecurityTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
InvocationContext ic = sc.newInvocation( request );
@ -501,7 +503,7 @@ public class RepositoryServletSecurityTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
InvocationContext ic = sc.newInvocation( request );
@ -552,7 +554,7 @@ public class RepositoryServletSecurityTest
File artifactFile = new File( repoRootInternal, commonsLangJar );
artifactFile.getParentFile().mkdirs();
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, null );
FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.forName( "UTF-8" ) );
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
InvocationContext ic = sc.newInvocation( request );