aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2019-08-29 19:04:00 +0200
committerMartin Stockhammer <martin_s@apache.org>2019-08-29 19:04:00 +0200
commit32c4ada25968a30fceab5da885c893debbe24cf7 (patch)
treef23640de81bcfe78df8e1f453ecc8eeb947e7f77
parentb782b9854f5427a11e9566307c47fa4f247a19dd (diff)
downloadarchiva-32c4ada25968a30fceab5da885c893debbe24cf7.tar.gz
archiva-32c4ada25968a30fceab5da885c893debbe24cf7.zip
Using test loop for browse service test
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java53
1 files changed, 45 insertions, 8 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java
index 7497642ea..aaa601e3f 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/MergeRepositoriesServiceTest.java
@@ -46,6 +46,9 @@ public class MergeRepositoriesServiceTest
private Path repoStage = getAppserverBase().resolve("data/repositories").resolve( "test-repository-stage" );
+ private int maxChecks = 10;
+ private int checkWaitMs = 500;
+
@Test
public void getMergeConflictedArtifacts()
throws Exception
@@ -56,12 +59,28 @@ public class MergeRepositoriesServiceTest
waitForScanToComplete( TEST_REPOSITORY_STAGE );
- List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts( TEST_REPOSITORY_STAGE,
- TEST_REPOSITORY );
-
- log.info( "conflicts: {}", artifactMetadatas );
+ int checks = maxChecks;
+ Throwable ex = null;
+ while(checks-->0) {
+ try {
+ log.info("Test Try " + checks);
+ List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts( TEST_REPOSITORY_STAGE,
+ TEST_REPOSITORY );
+ log.info("conflicts: {}", artifactMetadatas);
+
+ assertThat(artifactMetadatas).isNotNull().isNotEmpty().hasSize(8);
+ return;
+ } catch (Throwable e) {
+ ex = e;
+ }
+ Thread.currentThread().sleep(checkWaitMs);
+ }
+ if (ex!=null && ex instanceof AssertionError) {
+ throw (AssertionError)ex;
+ } else {
+ throw new Exception(ex);
+ }
- assertThat( artifactMetadatas ).isNotNull().isNotEmpty().hasSize( 8 );
}
@Test
@@ -81,10 +100,28 @@ public class MergeRepositoriesServiceTest
MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
- service.mergeRepositories( TEST_REPOSITORY_STAGE, TEST_REPOSITORY, true );
+ int checks = maxChecks;
+ Throwable ex = null;
+ while(checks-->0) {
+ try {
+ log.info("Test Try " + checks);
+ service.mergeRepositories(TEST_REPOSITORY_STAGE, TEST_REPOSITORY, true);
+
+ assertTrue(Files.exists(repo.resolve(mergedArtifactPath)));
+ assertTrue(Files.exists(repo.resolve(mergedArtifactPomPath)));
+ return;
+ } catch (Throwable e) {
+ log.info("Exception {}, {}", e.getMessage(), e.getClass());
+ ex = e;
+ }
+ Thread.currentThread().sleep(checkWaitMs);
+ }
+ if (ex!=null && ex instanceof AssertionError) {
+ throw (AssertionError)ex;
+ } else if (ex!=null) {
+ throw new Exception(ex);
+ }
- assertTrue( Files.exists(repo.resolve(mergedArtifactPath)) );
- assertTrue( Files.exists(repo.resolve(mergedArtifactPomPath)) );
}
@After