Author: cschneider Date: Thu Jan 31 16:41:51 2013 New Revision: 1441052 URL: http://svn.apache.org/viewvc?rev=1441052&view=rev Log: SYNCOPE-231 Fix for rerun issue on user deletion
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1441052&r1=1441051&r2=1441052&view=diff ============================================================================== --- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original) +++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Thu Jan 31 16:41:51 2013 @@ -27,6 +27,8 @@ import static org.junit.Assert.assertTru import java.util.Collections; import java.util.List; import java.util.Set; + +import javax.ws.rs.NotFoundException; import javax.ws.rs.core.Response; import org.apache.syncope.common.search.AttributableCond; import org.apache.syncope.common.search.AttributeCond; @@ -224,6 +226,8 @@ public class TaskTestITCase extends Abst @Test public void sync() { + removeTestUsers(); + // ----------------------------- // Create a new user ... it should be updated applying sync policy // ----------------------------- @@ -318,12 +322,7 @@ public class TaskTestITCase extends Abst assertNotNull(userTO); assertEquals("active", userTO.getStatus()); } finally { - // remove initial and synchronized users to make test re-runnable - for (int i = 0; i < 10; i++) { - String cUserName = "test" + i; - UserTO cUserTO = userService.read(cUserName); - userService.delete(cUserTO.getId()); - } + removeTestUsers(); } } @@ -727,6 +726,8 @@ public class TaskTestITCase extends Abst @Test public void issueSYNCOPE272() { + removeTestUsers(); + // create user with testdb resource UserTO userTO = UserTestITCase.getUniqueSampleTO("syncope...@syncope.apache.org"); userTO.addResource("resource-testdb"); @@ -772,11 +773,21 @@ public class TaskTestITCase extends Abst assertNotNull(userTO); assertNotNull(userTO.getAttributeMap().get("firstname").getValues().get(0)); } finally { - // remove initial and synchronized users to make test re-runnable - for (int i = 0; i < 10; i++) { - String cUserName = "test" + i; + removeTestUsers(); + } + } + + /** + * remove initial and synchronized users to make test re-runnable + */ + public void removeTestUsers() { + for (int i = 0; i < 10; i++) { + String cUserName = "test" + i; + try { UserTO cUserTO = userService.read(cUserName); userService.delete(cUserTO.getId()); + } catch (Exception e) { + // Ignore } } }