KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portalImpl > portlet > test > ExternalAppScopedAttributeTest


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
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 JavaDoc INT_KEY = "org.apache.pluto.testsuite.INTERNALLY_SET_APP_SCOPED_SESSION_TEST_KEY";
27     public static final String JavaDoc EXT_KEY = "org.apache.pluto.testsuite.EXTERNALLY_SET_APP_SCOPED_SESSION_TEST_KEY";
28     public static final String JavaDoc VALUE = "Should be visible to all Portlets and Web Resources.";
29
30     public String JavaDoc 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 JavaDoc 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 }
61
Popular Tags