Fixed issue unmarshalling primitive types and assertion errors in test framework

This commit is contained in:
rpidikiti
2011-08-09 14:56:37 -07:00
parent 8347fa3a37
commit fb87385c1b
2 changed files with 15 additions and 4 deletions

View File

@@ -211,9 +211,20 @@ public class APIInvoker {
*/
public static Object deserialize(String response, Class inputClassName) throws APIException {
try {
System.out.println("response: " + response + " , class name:" + inputClassName);
Object responseObject = mapper.readValue(response, inputClassName);
return responseObject;
if(inputClassName.isAssignableFrom(String.class)){
return response;
} else if (inputClassName.isAssignableFrom(Integer.class)){
return new Integer(response);
} else if (inputClassName.isAssignableFrom(Boolean.class)){
return new Boolean(response);
} else if (inputClassName.isAssignableFrom(Long.class)){
return new Long(response);
} else if (inputClassName.isAssignableFrom(Double.class)){
return new Double(response);
} else{
Object responseObject = mapper.readValue(response, inputClassName);
return responseObject;
}
} catch (IOException ioe) {
String[] args = new String[]{response, inputClassName.toString()};
throw new APIException(APIExceptionCodes.ERROR_CONVERTING_JSON_TO_JAVA, args, "Error in coversting response json value to java object : " + ioe.getMessage(), ioe);

View File

@@ -264,7 +264,7 @@ public class APITestRunner {
boolean asserted = false;
if(testCase.getAssertions() != null) {
for(Assertion assertion : testCase.getAssertions()){
if(assertion.getExpectedOutput().equalsIgnoreCase("Exception")){
if(assertion.getCondition().equals("==") && assertion.getExpectedOutput().equalsIgnoreCase("Exception")){
testStatus.logStatus(testCase, testCasePath, true);
asserted = true;
}