package org.jboss.test.webservice.handlerflow;
import junit.framework.Test;
import org.jboss.test.webservice.WebserviceTestBase;
import javax.naming.InitialContext;
import java.util.Arrays;
import java.util.List;
public class HandlerFlowTestCase extends WebserviceTestBase
{
public HandlerFlowTestCase(String name)
{
super(name);
}
public static Test suite() throws Exception
{
return getDeploySetup(HandlerFlowTestCase.class, "ws4ee-handlerflow.jar, ws4ee-handlerflow.war");
}
public void testHandlerFlow() throws Exception
{
InitialContext iniCtx = getClientContext();
HelloHome home = (HelloHome)iniCtx.lookup("ejb/HelloEjb");
HelloRemote ejb = home.create();
List protocol = Arrays.asList(ejb.sayHello("Hello"));
String[] exp = {
"ClientHandler1 init",
"ClientHandler2 init",
"ClientHandler1 handleRequest",
"ClientHandler2 handleRequest",
"ServerHandler1 init",
"ServerHandler2 init",
"ServerHandler1 handleRequest",
"ServerHandler2 handleRequest",
"jse: 'Hello' to you too!",
"ServerHandler2 handleResponse",
"ServerHandler1 handleResponse",
"ClientHandler2 handleResponse",
"ClientHandler1 handleResponse",
"ejb: 'Hello' to you too!"
};
assertEquals("Wrong number of entries: " + protocol, exp.length, protocol.size());
for (int i = 0; i < protocol.size(); i++)
{
String msg = (String)protocol.get(i);
boolean equals = msg.startsWith(exp[i]);
assertTrue("Wrong entry: " + msg + " in " + protocol, equals);
}
}
}