01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.pluto.testsuite.test;
19:
20: import org.apache.pluto.testsuite.TestResult;
21: import org.apache.pluto.testsuite.TestUtils;
22:
23: import javax.portlet.PortletSession;
24:
25: /**
26: */
27: public class AppScopedSessionAttributeTest extends
28: AbstractReflectivePortletTest {
29:
30: private static final String BOGUS_KEY = "org.apache.pluto.testsuite.BOGUS_KEY";
31: private static final String KEY = "org.apache.pluto.testsuite.KEY";
32: private static final String VALUE = "VALUE";
33:
34: // Test Methods ------------------------------------------------------------
35:
36: protected TestResult checkGetEmptyAppScopedAttribute(
37: PortletSession session) {
38: TestResult result = new TestResult();
39: result
40: .setDescription("Retrieve an attribute that has not been set "
41: + "in the session's application scope "
42: + "and ensure it's value is null.");
43: result.setSpecPLT("15.3");
44:
45: Object value = session.getAttribute(BOGUS_KEY,
46: PortletSession.APPLICATION_SCOPE);
47: if (value == null) {
48: result.setReturnCode(TestResult.PASSED);
49: } else {
50: TestUtils.failOnAssertion("session attribute", value, null,
51: result);
52: }
53: return result;
54: }
55:
56: protected TestResult checkSetAppScopedAttribute(
57: PortletSession session) {
58: TestResult result = new TestResult();
59: result
60: .setDescription("Set an application scoped session attribute "
61: + "and ensure it's retrievable.");
62: result.setSpecPLT("15.3");
63:
64: session.setAttribute(KEY, VALUE,
65: PortletSession.APPLICATION_SCOPE);
66: Object value = session.getAttribute(KEY,
67: PortletSession.APPLICATION_SCOPE);
68: if (VALUE.equals(value)) {
69: result.setReturnCode(TestResult.PASSED);
70: } else {
71: TestUtils.failOnAssertion("session attribute", value,
72: VALUE, result);
73: }
74: return result;
75: }
76:
77: protected TestResult checkRemoveAppScopedAttribute(
78: PortletSession session) {
79: TestResult result = new TestResult();
80: result
81: .setDescription("Remove an application scoped session attribute "
82: + "and ensure it's null.");
83: result.setSpecPLT("15.3");
84:
85: session.setAttribute(KEY, VALUE,
86: PortletSession.APPLICATION_SCOPE);
87: session.removeAttribute(KEY, PortletSession.APPLICATION_SCOPE);
88: Object value = session.getAttribute(KEY,
89: PortletSession.APPLICATION_SCOPE);
90: if (value == null) {
91: result.setReturnCode(TestResult.PASSED);
92: } else {
93: TestUtils.failOnAssertion("session attribute", value, null,
94: result);
95: }
96: return result;
97: }
98:
99: }
|