01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.web;
16:
17: import static org.testng.Assert.assertEquals;
18:
19: import org.strecks.constants.InfrastructureKeys;
20: import org.testng.annotations.Test;
21:
22: /**
23: * @author Phil Zoio
24: */
25: public class TestRedirectHelperImpl {
26:
27: @Test
28: public void testNull() {
29: RedirectHelperImpl impl = new RedirectHelperImpl();
30: assert null == impl.getRequestParameters();
31: assert null == impl.getSessionParameters();
32: }
33:
34: @Test
35: public void testRequest() {
36: RedirectHelperImpl impl = new RedirectHelperImpl();
37:
38: impl.addRequestParameter("param1", 1);
39: impl.addRequestParameter("param2", "param2");
40:
41: assertEquals(impl.getRequestParameters().size(), 2);
42: assertEquals(impl.getRequestParameters().get("param1"), "1");
43: assertEquals(impl.getRequestParameters().get("param2"),
44: "param2");
45:
46: assert null == impl.getSessionParameters();
47: }
48:
49: @Test
50: public void testSession() {
51: RedirectHelperImpl impl = new RedirectHelperImpl();
52:
53: impl.addSessionParameter("param1", 1);
54: impl.addSessionParameter("param2", "param2");
55:
56: assertEquals(impl.getSessionParameters().size(), 2);
57: assertEquals(impl.getSessionParameters().get("param1"), 1);
58: assertEquals(impl.getSessionParameters().get("param2"),
59: "param2");
60:
61: assert null == impl.getRequestParameters();
62: }
63:
64: @Test
65: public void testStatusMessage() {
66: RedirectHelperImpl impl = new RedirectHelperImpl();
67:
68: impl.setStatusMessage("Hello");
69: assertEquals(impl.getSessionParameters().size(), 1);
70: assertEquals(impl.getSessionParameters().get(
71: InfrastructureKeys.STATUS_MESSAGE), "Hello");
72:
73: assert null == impl.getRequestParameters();
74: }
75:
76: }
|