aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2021-01-27 22:17:34 +0100
committerMartin Stockhammer <martin_s@apache.org>2021-01-27 22:17:34 +0100
commit8fa8083ef91f7a53ea7257b880326550b122e062 (patch)
tree30ffb00c2d172d11888bc333f4cdae2c2e2e11d2
parentb32d75a85b4f5805d6d251ea2237f838087aa2bf (diff)
downloadarchiva-8fa8083ef91f7a53ea7257b880326550b122e062.tar.gz
archiva-8fa8083ef91f7a53ea7257b880326550b122e062.zip
Making application context dirty after each test class run
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java14
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java7
-rw-r--r--archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ArchivaSpringJUnit4ClassRunner.java16
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java3
-rw-r--r--archiva-modules/metadata/metadata-store-provider/oak-jcr/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java3
5 files changed, 23 insertions, 20 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
index 0ff779ffe..e0197f19c 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/AbstractArtifactConsumerTest.java
@@ -33,6 +33,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
@@ -55,15 +56,12 @@ public abstract class AbstractArtifactConsumerTest
@Inject
ArchivaConfiguration archivaConfiguration;
- ArchivaRepositoryRegistry repositoryRegistry;
-
-
@Before
public void setUp()
throws Exception
{
FileType fileType =
- (FileType) archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
+ archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 );
assertEquals( FileTypes.ARTIFACTS, fileType.getId() );
fileType.addPattern( "**/*.xml" );
archivaConfiguration.getConfiguration().getArchivaRuntimeConfiguration().addChecksumType("MD5");
@@ -71,14 +69,6 @@ public abstract class AbstractArtifactConsumerTest
archivaConfiguration.getConfiguration().getArchivaRuntimeConfiguration().addChecksumType("SHA256");
repoLocation = Paths.get( "target/test-" + getName() + "/test-repo" );
-
- repositoryRegistry = applicationContext.getBean( "repositoryRegistry", ArchivaRepositoryRegistry.class );
- assertNotNull( repositoryRegistry );
- }
-
- @After
- public void destroy() {
- repositoryRegistry.destroy();
}
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
index 2f906a586..f1791b7d0 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
@@ -42,6 +42,7 @@ import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
@@ -109,8 +110,6 @@ public abstract class AbstractRepositoryPurgeTest
protected MetadataRepository metadataRepository;
- protected ArchivaRepositoryRegistry repositoryRegistry;
-
@Inject
protected ApplicationContext applicationContext;
@@ -130,8 +129,6 @@ public abstract class AbstractRepositoryPurgeTest
repositorySession = sessionControl.createMock( RepositorySession.class );
metadataRepository = mock( MetadataRepository.class );
sessionFactory = sessionFactoryControl.createMock( RepositorySessionFactory.class );
- repositoryRegistry = applicationContext.getBean( "repositoryRegistry", ArchivaRepositoryRegistry.class );
- assertNotNull( repositoryRegistry );
EasyMock.expect( repositorySession.getRepository() ).andStubReturn( metadataRepository );
EasyMock.expect( sessionFactory.createSession( ) ).andStubReturn( repositorySession );
@@ -143,8 +140,6 @@ public abstract class AbstractRepositoryPurgeTest
{
config = null;
repo = null;
- repositoryRegistry.destroy();
-
}
diff --git a/archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ArchivaSpringJUnit4ClassRunner.java b/archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ArchivaSpringJUnit4ClassRunner.java
index 81a915898..8e48cd1b3 100644
--- a/archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ArchivaSpringJUnit4ClassRunner.java
+++ b/archiva-modules/archiva-base/archiva-test-utils/src/main/java/org/apache/archiva/test/utils/ArchivaSpringJUnit4ClassRunner.java
@@ -18,6 +18,8 @@ package org.apache.archiva.test.utils;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+import org.springframework.test.context.TestContextManager;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.IOException;
@@ -57,4 +59,18 @@ public class ArchivaSpringJUnit4ClassRunner
}
+ @Override
+ protected Statement withAfterClasses( final Statement statement )
+ {
+ final TestContextManager cm = getTestContextManager( );
+ return new Statement( )
+ {
+ @Override
+ public void evaluate( ) throws Throwable
+ {
+ statement.evaluate();
+ cm.getTestContext( ).markApplicationContextDirty( null );
+ }
+ };
+ }
}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
index 65b6b3e1d..b29f7da34 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
@@ -31,6 +31,7 @@ import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.text.SimpleDateFormat;
import java.time.ZoneId;
@@ -41,7 +42,7 @@ import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith( ArchivaSpringJUnit4ClassRunner.class )
+@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml"} )
public abstract class AbstractMetadataRepositoryTest
extends TestCase
diff --git a/archiva-modules/metadata/metadata-store-provider/oak-jcr/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java b/archiva-modules/metadata/metadata-store-provider/oak-jcr/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
index c10103a16..35166df41 100644
--- a/archiva-modules/metadata/metadata-store-provider/oak-jcr/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
+++ b/archiva-modules/metadata/metadata-store-provider/oak-jcr/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
@@ -43,6 +43,7 @@ import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.jcr.ImportUUIDBehavior;
import javax.jcr.Node;
@@ -62,7 +63,7 @@ import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
-@RunWith( ArchivaSpringJUnit4ClassRunner.class )
+@RunWith( SpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
public class JcrRepositoryStatisticsGatheringTest
extends TestCase