1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.pluto.portalImpl.portlet.test;
18
19 import javax.portlet.PortletSession;
20
21 /***
22 * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
23 */
24 public class ExternalAppScopedAttributeTest extends AbstractReflectivePortletTest {
25
26 public static final String INT_KEY = "org.apache.pluto.testsuite.INTERNALLY_SET_APP_SCOPED_SESSION_TEST_KEY";
27 public static final String EXT_KEY = "org.apache.pluto.testsuite.EXTERNALLY_SET_APP_SCOPED_SESSION_TEST_KEY";
28 public static final String VALUE = "Should be visible to all Portlets and Web Resources.";
29
30 public String getTestSuiteName() {
31 return "External Application Scoped Attribute Test";
32 }
33
34 public TestResult checkSetHereSeenElsewhere(PortletSession session) {
35 TestResult res = new TestResult();
36 res.setName("Session Visibility Test");
37 res.setDesc("Ensure application scoped attributes set here can be seen elsewhere.");
38 res.setReturnCode(TestResult.WARNING);
39 res.setResults("Click the provided link to validate test.");
40
41 session.setAttribute(INT_KEY, VALUE, PortletSession.APPLICATION_SCOPE);
42 return res;
43 }
44
45 public TestResult checkSetElsewhereSeenHere(PortletSession session) {
46 TestResult res = new TestResult();
47 res.setName("Session Visibility Test");
48 res.setDesc("Ensure application scoped attributes set elsewhere can be seen here.");
49
50 Object val = session.getAttribute(EXT_KEY, PortletSession.APPLICATION_SCOPE);
51 if(VALUE.equals(val)) {
52 res.setReturnCode(TestResult.PASSED);
53 }
54 else {
55 res.setReturnCode(TestResult.WARNING);
56 res.setResults("This test will not pass until you have opened the external resource using the link provided below.");
57 }
58 return res;
59 }
60 }