I am trying to assert list of User defined objects which are returning by mule flow like below testcase.
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.client.LocalMuleClient;
import org.mule.tck.junit4.FunctionalTestCase;
import org.mule.transport.http.ReleasingInputStream;
public class UnitedTest extends FunctionalTestCase{
@Override
protected String getConfigFile() {
return "src/main/app/united.xml";
}
@Test
public void sampletest() throws Exception {
LocalMuleClient client = muleContext.getClient();
MuleMessage response = client.send("http://localhost:8083/united/CLE", "", null, 1000000);
Assert.assertNotNull(response) ;
System.out.println(response.getPayload());
Object obj = response.getPayload();
ArrayList<Object> payloadObj = (ArrayList<Object>) obj;
Object resObj = (Object) payloadObj.get(0);
if(resObj instanceof Flight){
Flight flght = (Flight)resObj;
Assert.assertNotNull(flght);
}
}
}
I am getting classCastException.
java.lang.ClassCastException: org.mule.transport.http.ReleasingInputStream cannot be cast to java.util.ArrayList
at UnitedTest.sampletest(UnitedTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:46)
at org.junit.internal.runners.statements.FailOnTimeout$1.run(FailOnTimeout.java:28)
Any suggestions how to assert size of arraylist and each object members?