From 23099bcb581738f3c9cb13745ae2837eafd77ec6 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Fri, 28 Jun 2019 17:15:21 +0200 Subject: [PATCH] Fixing test errors after refactoring --- .../src/test/java/RepositoryProviderMock.java | 20 ++++ .../src/test/resources/log4j2-test.xml | 103 ++++++++++++++++++ .../repository/content/FilesystemStorage.java | 3 + .../ManagedDefaultRepositoryContent.java | 7 +- .../maven2/MavenRepositoryProviderTest.java | 2 +- 5 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/log4j2-test.xml diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java index f871fbb89..ea7b0f653 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java @@ -21,10 +21,13 @@ package $package; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.archiva.configuration.RepositoryGroupConfiguration; import org.apache.archiva.repository.BasicManagedRepository; import org.apache.archiva.repository.BasicRemoteRepository; import org.apache.archiva.repository.EditableManagedRepository; import org.apache.archiva.repository.EditableRemoteRepository; +import org.apache.archiva.repository.RepositoryGroup; +import org.apache.archiva.repository.EditableRepositoryGroup; import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.PasswordCredentials; import org.apache.archiva.repository.ReleaseScheme; @@ -233,4 +236,21 @@ public class RepositoryProviderMock implements RepositoryProvider public void raise(org.apache.archiva.repository.RepositoryEvent event) { } + + @Override + public RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup) throws RepositoryException { + return null; + } + + @Override + public RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration) throws RepositoryException { + return null; + } + + @Override + public void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration) throws RepositoryException { + + } + + } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/log4j2-test.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/log4j2-test.xml new file mode 100644 index 000000000..295370038 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/log4j2-test.xml @@ -0,0 +1,103 @@ + + + + + + + + ${sys:appserver.base}/logs + + + + + + + + + + %d [%t] %-5p %c %x - %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilesystemStorage.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilesystemStorage.java index 65b5610be..f24b31137 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilesystemStorage.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilesystemStorage.java @@ -49,6 +49,9 @@ public class FilesystemStorage implements RepositoryStorage { private final FileLockManager fileLockManager; public FilesystemStorage(Path basePath, FileLockManager fileLockManager) throws IOException { + if (!Files.exists(basePath)) { + Files.createDirectories(basePath); + } this.basePath = basePath.normalize().toRealPath(); this.fileLockManager = fileLockManager; } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java index f0d81e246..403bb9fb4 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java @@ -96,11 +96,12 @@ public class ManagedDefaultRepositoryContent super(artifactMappingProviders==null ? Collections.singletonList( new DefaultArtifactMappingProvider() ) : artifactMappingProviders); setFileTypes( fileTypes ); setRepository( repository ); + final Path repositoryDir = getRepoDir(); try { - storage = new FilesystemStorage(getRepoDir(), lockManager); + storage = new FilesystemStorage(repositoryDir, lockManager); } catch (IOException e) { - log.error("Could not initialize the filesystem storage to repository: {}", getRepoDir()); - throw new RuntimeException("Fatal error. Could not initialize the filesystem storage for "+getRepoDir()); + log.error("Could not initialize the filesystem storage to repository {}: {}", repositoryDir, e.getMessage(), e); + throw new RuntimeException("Fatal error. Could not initialize the filesystem storage for "+repositoryDir+": "+e.getMessage()); } } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java index 0a04dad2f..39396d6d5 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java @@ -356,7 +356,7 @@ public class MavenRepositoryProviderTest assertEquals("0 0 03 ? * MON", grp.getSchedulingDefinition()); IndexCreationFeature indexCreationFeature = grp.getFeature( IndexCreationFeature.class ).get(); try { - assertEquals(new URI("file://.index-abc"), indexCreationFeature.getIndexPath()); + assertEquals(new URI(".index-abc"), indexCreationFeature.getIndexPath()); } catch (URISyntaxException e) { e.printStackTrace(); } -- 2.39.5