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;
19:
20: import de.finix.contelligent.core.HTTPCallDataImpl;
21: import de.finix.contelligent.test.ContelligentTestCase;
22: import de.finix.contelligent.test.mock.ContelligentMockHttpServletRequest;
23: import de.finix.contelligent.test.mock.MockContelligentSession;
24:
25: public class CallDataTests extends ContelligentTestCase {
26:
27: public CallDataTests(String s) {
28: super (s);
29: }
30:
31: public void testGetParameterFromRequest() {
32: ContelligentMockHttpServletRequest request = new ContelligentMockHttpServletRequest();
33: request.setupAddParameter("param", "PARAM_VALUE");
34: HTTPCallData callData = new HTTPCallDataImpl(null,
35: "http://test", "http://test", false, false, request,
36: null, null, true);
37:
38: String paramValue = callData.getParameter("param");
39: assertNotNull("value for parameter 'param' is null", paramValue);
40: assertTrue("value of parameter 'param' don't match", paramValue
41: .equals("PARAM_VALUE"));
42: }
43:
44: public void testSessionAttribute() {
45: ContelligentMockHttpServletRequest request = new ContelligentMockHttpServletRequest();
46: MockContelligentSession session = new MockContelligentSession();
47: HTTPCallData callData = new HTTPCallDataImpl(session,
48: "http://test", "http://test", false, false, request,
49: null, null, true);
50: callData.setSessionAttribute("param", "PARAM_VALUE");
51:
52: Object attrValue = callData.getSessionAttribute("param");
53: assertNotNull("value for attribute 'param' is null", attrValue);
54: assertTrue("values of attribute 'param' don't match", attrValue
55: .equals("PARAM_VALUE"));
56: }
57:
58: public void testSecureTransfer() {
59: ContelligentMockHttpServletRequest request = new ContelligentMockHttpServletRequest();
60: MockContelligentSession session = new MockContelligentSession();
61: HTTPCallData callData = new HTTPCallDataImpl(session,
62: "http://test", "http://test", false, false, request,
63: null, null, true);
64:
65: assertTrue("secureTransfer is true for http", !callData
66: .secureTransfer());
67: callData = new HTTPCallDataImpl(session, "https://test",
68: "https://test", false, false, request, null, null, true);
69:
70: assertTrue("secureTransfer is false for https", !callData
71: .secureTransfer());
72: }
73: }
|