1
2 package inklings.jgatms.command;
3
4 import java.util.List;
5 import java.util.Iterator;
6
7 import org.apache.commons.chain.Command;
8 import org.apache.commons.chain.Context;
9 import org.apache.commons.chain.impl.ContextBase;
10
11 import inklings.jgatms.context.JgatmsContext;
12 import inklings.jgatms.CommandKeys;
13 import inklings.jgatms.ContextKeys;
14 import inklings.jgatms.bean.Question;
15 import inklings.jgatms.bean.Response;
16
17 /***
18 * Tests the <code>GetResponses</code> JGATMS command.
19 */
20 public class GetResponsesTest extends BaseTestCase {
21
22 /***
23 * Verifies that all responses can be retrieved.
24 */
25 public void testGetResponses() throws Exception {
26 JgatmsContext context = new JgatmsContext();
27 Command command = catalog.getCommand(CommandKeys.GET_RESPONSES);
28 assertNotNull(CommandKeys.GET_RESPONSES + " not found.", command);
29
30 command.execute(context);
31 String dispatch = context.getDispatch();
32 assertTrue("Unsuccessful command execution.",
33 dispatch.equals(ContextKeys.SUCCESS_DISPATCH));
34
35 List responses = (List) context.get(ContextKeys.RESPONSE_LIST_KEY);
36 assertNotNull(ContextKeys.RESPONSE_LIST_KEY + " not found.", responses);
37
38 Iterator i = responses.iterator();
39 while (i.hasNext()) {
40 System.out.println("======================================");
41 Response response = (Response) i.next();
42
43 System.out.println("Response: " + response.getResponse());
44 System.out.println("Response id: " + response.getResponseId());
45 }
46
47 }
48 }
This page was automatically generated by Maven