01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.action;
19:
20: import de.finix.contelligent.HTTPCallData;
21: import de.finix.contelligent.core.HTTPCallDataImpl;
22: import de.finix.contelligent.test.ContelligentTestCase;
23: import de.finix.contelligent.test.mock.ContelligentMockHttpServletRequest;
24: import de.finix.contelligent.test.mock.MockContelligentSession;
25:
26: public class ActionResultTests extends ContelligentTestCase {
27:
28: public ActionResultTests(String s) {
29: super (s);
30: }
31:
32: public void testRequestValue() throws Exception {
33: ActionResult result = new ActionResult();
34: result.setStorageKey("/test/value");
35: result.setStorageScope(StoredObject.SCOPE_REQUEST_STRING);
36:
37: ContelligentMockHttpServletRequest request = new ContelligentMockHttpServletRequest();
38: MockContelligentSession session = new MockContelligentSession();
39: HTTPCallData callData = new HTTPCallDataImpl(session,
40: "http://test", "http://test", false, false, request,
41: null, null, true);
42:
43: result.setObject("PARAM_VALUE", callData);
44: assertTrue(result.getObject(callData).equals("PARAM_VALUE"));
45: }
46:
47: public void testSessionValue() throws Exception {
48: ActionResult result = new ActionResult();
49: result.setStorageKey("/test/value");
50: result.setStorageScope(StoredObject.SCOPE_SESSION_STRING);
51:
52: ContelligentMockHttpServletRequest request = new ContelligentMockHttpServletRequest();
53: MockContelligentSession session = new MockContelligentSession();
54: HTTPCallData callData = new HTTPCallDataImpl(session,
55: "http://test", "http://test", false, false, request,
56: null, null, true);
57:
58: result.setObject("PARAM_VALUE", callData);
59: assertTrue(result.getObject(callData).equals("PARAM_VALUE"));
60: }
61:
62: public void testParameterRead() throws Exception {
63: ActionResult result = new ActionResult();
64: result.setStorageKey("/test/value");
65: result.setStorageScope(StoredObject.SCOPE_SESSION_STRING);
66:
67: ContelligentMockHttpServletRequest request = new ContelligentMockHttpServletRequest();
68: MockContelligentSession session = new MockContelligentSession();
69: HTTPCallData callData = new HTTPCallDataImpl(session,
70: "http://test", "http://test", false, false, request,
71: null, null, true);
72:
73: result.setObject("PARAM_VALUE", callData);
74: assertTrue(result.getObject(callData).equals("PARAM_VALUE"));
75:
76: ActionParameter parameter = new ActionParameter();
77: parameter.setStorageKey("/test/value");
78: parameter.setStorageScope(StoredObject.SCOPE_SESSION_STRING);
79:
80: assertTrue(parameter.getObject(callData).equals("PARAM_VALUE"));
81: }
82: }
|