update junit and hamcrest dependencies, use non-dreprecated junit Assert class, add better error failure messages when tests cannot connect to server or https as not being disabled.

This commit is contained in:
Keith Woodlock
2013-04-03 01:53:56 +01:00
parent c32ba579cd
commit 4f4fb982e5
6 changed files with 28 additions and 12 deletions
+2 -3
View File
@@ -159,9 +159,8 @@ dependencies {
[group: 'com.googlecode.flyway', name: 'flyway-maven-plugin', version: '2.1.1']
)
testCompile 'junit:junit:4.10',
'org.mockito:mockito-all:1.9.0',
'org.hamcrest:hamcrest-all:1.1',
testCompile 'junit:junit:4.11',
'org.mockito:mockito-all:1.9.5',
'com.jayway.restassured:rest-assured:1.7.2'
}
@@ -1,6 +1,6 @@
package org.mifosplatform.integrationtests;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
@@ -1,6 +1,6 @@
package org.mifosplatform.integrationtests;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashMap;
@@ -3,7 +3,7 @@ package org.mifosplatform.integrationtests.common;
import java.util.HashMap;
import java.util.Random;
import junit.framework.Assert;
import org.junit.Assert;
import com.google.gson.Gson;
import com.jayway.restassured.specification.RequestSpecification;
@@ -5,8 +5,6 @@ import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import junit.framework.Assert;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
@@ -34,7 +32,7 @@ public class LoanStatusChecker {
}
public static void verifyLoanAccountIsClosed(final HashMap loanStatusHashMap) {
Assert.assertTrue(getStatus(loanStatusHashMap, "closed"));
assertTrue(getStatus(loanStatusHashMap, "closed"));
}
public static HashMap getStatusOfLoan(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
@@ -2,6 +2,10 @@ package org.mifosplatform.integrationtests.common;
import static com.jayway.restassured.RestAssured.given;
import static com.jayway.restassured.path.json.JsonPath.from;
import static org.hamcrest.MatcherAssert.assertThat;
import org.apache.commons.lang.StringUtils;
import org.apache.http.conn.HttpHostConnectException;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.path.json.JsonPath;
@@ -14,9 +18,24 @@ public class Utils {
private static final String LOGIN_URL = "/mifosng-provider/api/v1/authentication?username=mifos&password=password&tenantIdentifier=default";
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
System.out.println("-----------------------------------LOGIN-----------------------------------------");
String json = RestAssured.post(LOGIN_URL).asString();
return JsonPath.with(json).get("base64EncodedAuthenticationKey");
try {
System.out.println("-----------------------------------LOGIN-----------------------------------------");
String json = RestAssured.post(LOGIN_URL).asString();
if (StringUtils.isBlank(json)) {
assertThat(
"Failed to login into mifosx platform: Please check it is running and you have changed its securityContext.xml from requires-channel=\"https\" to requires-channel=\"http\"",
false);
}
return JsonPath.with(json).get("base64EncodedAuthenticationKey");
} catch (Exception e) {
if (e instanceof HttpHostConnectException) {
HttpHostConnectException hh = (HttpHostConnectException) e;
assertThat("Failed to connect to mifosx platform: " + hh.getMessage(), false);
}
throw new RuntimeException(e);
}
}
public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,