summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-09-15 21:37:35 +0000
committerOlivier Lamy <olamy@apache.org>2012-09-15 21:37:35 +0000
commit833d272ab4200f032d456a72e1e316ed64acd304 (patch)
tree856228fd6f03802d17058e8c607c643f4a1fd330 /archiva-modules/archiva-base
parent762f11300b0ed3eda5863b28d3201bf72471415d (diff)
downloadarchiva-833d272ab4200f032d456a72e1e316ed64acd304.tar.gz
archiva-833d272ab4200f032d456a72e1e316ed64acd304.zip
fix compilation
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1385187 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r--archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverter.java15
-rw-r--r--archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverterTest.java24
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java3
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java27
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java5
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java14
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java17
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java6
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java45
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/WagonDelegate.java12
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java13
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java13
12 files changed, 100 insertions, 94 deletions
diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverter.java b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverter.java
index 827c80ece..c777b32a1 100644
--- a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverter.java
+++ b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverter.java
@@ -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;
diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverterTest.java b/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverterTest.java
index 386283012..f6544f655 100644
--- a/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverterTest.java
+++ b/archiva-modules/archiva-base/archiva-artifact-converter/src/test/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverterTest.java
@@ -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 );
}
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java
index d94d9d4bd..2a2b6da65 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java
+++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationMRM789Test.java
@@ -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" );
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
index cc2addad3..1f45d600f 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
+++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
@@ -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" );
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
index 8f7f6d00d..6ff8b5108 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
@@ -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>";
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
index 47e2b9080..b99b46a7c 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
@@ -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>";
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java
index a6d210dab..c0762767f 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java
@@ -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();
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java
index 9c50d5c0c..37673bd72 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java
@@ -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" ) );
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java
index 6e00a3460..84bce0d07 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java
@@ -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 );
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/WagonDelegate.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/WagonDelegate.java
index cbe81dbd0..60b64c541 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/WagonDelegate.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/WagonDelegate.java
@@ -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 )
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java
index 09f178132..5ffd916eb 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java
@@ -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() )
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java
index ea099bde0..65b267b7f 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriterTest.java
@@ -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();