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: package org.apache.pluto.testsuite.test;
18:
19: import java.io.IOException;
20:
21: import javax.portlet.PortletPreferences;
22: import javax.portlet.PortletRequest;
23: import javax.portlet.ValidatorException;
24:
25: import org.apache.pluto.testsuite.TestResult;
26: import org.apache.pluto.testsuite.TestUtils;
27:
28: public class PreferenceInRenderTest extends PreferenceCommonTest {
29:
30: // Test Methods ------------------------------------------------------------
31:
32: protected TestResult checkStorePreferences(PortletRequest request) {
33: TestResult result = new TestResult();
34: result
35: .setDescription("Ensure that if the store() method is invoked "
36: + "within render() method, an IllegalStateException will be "
37: + "thrown out.");
38: result.setSpecPLT("14.1");
39:
40: PortletPreferences preferences = request.getPreferences();
41: boolean exceptionThrown = false;
42:
43: // Store preferences and wait for IllegalStateException.
44: try {
45: preferences.store();
46: } catch (ValidatorException ex) {
47: TestUtils.failOnException("Unable to store preferences.",
48: ex, result);
49: return result;
50: } catch (IOException ex) {
51: TestUtils.failOnException("Unable to store preferences.",
52: ex, result);
53: return result;
54: } catch (IllegalStateException ex) {
55: exceptionThrown = true;
56: }
57:
58: if (exceptionThrown) {
59: result.setReturnCode(TestResult.PASSED);
60: } else {
61: result.setReturnCode(TestResult.FAILED);
62: result
63: .setResultMessage("IllegalStateException is not thrown out "
64: + "when store() method is invoked within render() method.");
65: }
66: return result;
67: }
68:
69: }
|