]> source.dussan.org Git - archiva.git/commitdiff
wait end of first scan before deleting repo should prevent test failure
authorOlivier Lamy <olamy@apache.org>
Sat, 11 Feb 2012 08:07:37 +0000 (08:07 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 11 Feb 2012 08:07:37 +0000 (08:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1243016 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java

index 58e9159beb1e61cf909f082974b3e5f516fa5659..b4530af8ae1d7bc3b9fb64b6027f3598b3fc587e 100644 (file)
@@ -50,6 +50,15 @@ public class ManagedRepositoriesServiceTest
         service.addManagedRepository( repo );
         assertNotNull( service.getManagedRepository( repo.getId() ) );
 
+        RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader );
+
+        int timeout = 20000;
+        while ( timeout > 0 && repositoriesService.alreadyScanning( repo.getId() ) )
+        {
+            Thread.sleep( 500 );
+            timeout -= 500;
+        }
+
         service.deleteManagedRepository( repo.getId(), true );
         assertNull( service.getManagedRepository( repo.getId() ) );
     }
@@ -67,6 +76,16 @@ public class ManagedRepositoriesServiceTest
             assertNull( service.getManagedRepository( repo.getId() ) );
         }
         service.addManagedRepository( repo );
+
+        RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader );
+
+        int timeout = 20000;
+        while ( timeout > 0 && repositoriesService.alreadyScanning( repo.getId() ) )
+        {
+            Thread.sleep( 500 );
+            timeout -= 500;
+        }
+
         repo = service.getManagedRepository( repo.getId() );
         assertNotNull( repo );
         assertEquals( "test", repo.getName() );
@@ -79,6 +98,13 @@ public class ManagedRepositoriesServiceTest
         assertNotNull( repo );
         assertEquals( "toto", repo.getName() );
 
+        timeout = 20000;
+        while ( timeout > 0 && repositoriesService.alreadyScanning( repo.getId() ) )
+        {
+            Thread.sleep( 500 );
+            timeout -= 500;
+        }
+
         service.deleteManagedRepository( repo.getId(), true );
         assertNull( service.getManagedRepository( repo.getId() ) );