You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/02/08 10:29:33 UTC

svn commit: r1443901 - in /syncope/trunk/core/src/test/java/org/apache/syncope/core/rest: AbstractTest.java PolicyTestITCase.java ReportTestITCase.java

Author: ilgrosso
Date: Fri Feb  8 09:29:32 2013
New Revision: 1443901

URL: http://svn.apache.org/r1443901
Log:
Trying again to make more robust report tests

Modified:
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1443901&r1=1443900&r2=1443901&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Fri Feb  8 09:29:32 2013
@@ -294,7 +294,7 @@ public abstract class AbstractTest {
     }
 
     private <T> T getObjectSpring(final Response response, final Class<T> type) {
-        return restTemplate.getForEntity(response.getLocation(), type).getBody();
+        return restTemplate.getForObject(response.getLocation(), type);
     }
 
     public void setEnabledCXF(final boolean enabledCXF) {

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java?rev=1443901&r1=1443900&r2=1443901&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/PolicyTestITCase.java Fri Feb  8 09:29:32 2013
@@ -24,9 +24,7 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.fail;
 
 import java.util.List;
-
 import javax.ws.rs.core.Response;
-
 import org.apache.syncope.common.to.AccountPolicyTO;
 import org.apache.syncope.common.to.PasswordPolicyTO;
 import org.apache.syncope.common.to.SyncPolicyTO;
@@ -80,7 +78,6 @@ public class PolicyTestITCase extends Ab
         PasswordPolicyTO policy = new PasswordPolicyTO(true);
         policy.setSpecification(new PasswordPolicySpec());
         policy.setDescription("global password policy");
-        System.out.println(policy.getType());
 
         try {
             createPolicy(policyService, PolicyType.PASSWORD, policy);

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java?rev=1443901&r1=1443900&r2=1443901&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ReportTestITCase.java Fri Feb  8 09:29:32 2013
@@ -35,6 +35,7 @@ import org.apache.syncope.common.service
 import org.apache.syncope.common.to.ReportExecTO;
 import org.apache.syncope.common.to.ReportTO;
 import org.apache.syncope.common.types.ReportExecExportFormat;
+import org.apache.syncope.common.types.ReportExecStatus;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
@@ -164,7 +165,7 @@ public class ReportTestITCase extends Ab
 
         Object entity = response.getEntity();
         assertTrue(entity instanceof InputStream);
-        assertFalse(IOUtils.toString((InputStream) entity, "UTF-8").isEmpty());
+        assertFalse(IOUtils.toString((InputStream) entity, SyncopeConstants.DEFAULT_ENCODING).isEmpty());
     }
 
     @Test
@@ -172,11 +173,10 @@ public class ReportTestITCase extends Ab
         ReportTO reportTO = reportService.read(1L);
         reportTO.setId(0);
         reportTO.setName("executeAndExport" + getUUIDString());
+        reportTO.getExecutions().clear();
         reportTO = createReport(reportTO);
         assertNotNull(reportTO);
 
-        int preExecs = reportTO.getExecutions().size();
-
         ReportExecTO execution = reportService.execute(reportTO.getId());
         assertNotNull(execution);
 
@@ -196,14 +196,10 @@ public class ReportTestITCase extends Ab
             assertNotNull(reportTO.getExecutions());
 
             i++;
-        } while (preExecs == reportTO.getExecutions().size() && i < maxit);
-        if (i == maxit) {
-            throw new RuntimeException("Timeout when executing report " + reportTO.getId());
-        }
-
-        assertEquals(preExecs + 1, reportTO.getExecutions().size());
+        } while (!ReportExecStatus.SUCCESS.name().equals(reportTO.getExecutions().get(0).getStatus()) && i < maxit);
+        assertEquals(ReportExecStatus.SUCCESS.name(), reportTO.getExecutions().get(0).getStatus());
 
-        long execId = reportTO.getExecutions().get(preExecs).getId();
+        long execId = reportTO.getExecutions().get(0).getId();
 
         checkExport(execId, ReportExecExportFormat.XML);
         checkExport(execId, ReportExecExportFormat.HTML);