1 package org.apache.turbine.test;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import com.mockobjects.servlet.MockHttpSession;
23 /**
24 * Extension to the basic MockHttpSession to provide some extra parameters
25 * required by Turbine.
26 *
27 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
28 * @version $Id: EnhancedMockHttpSession.java 615328 2008-01-25 20:25:05Z tv $
29 */
30 public class EnhancedMockHttpSession extends MockHttpSession
31 {
32 private boolean isNew = true;
33 private int maxInactiveInterval =0;
34
35 /**
36 *
37 */
38 public EnhancedMockHttpSession()
39 {
40 super();
41 }
42 /**
43 * The default MockHttpSession doesn't implement this method. It always
44 * returns true.
45 */
46 public boolean isNew()
47 {
48 return isNew;
49 }
50
51 public void setMaxInactiveInterval(int maxInactiveInterval){
52 this.maxInactiveInterval =maxInactiveInterval;
53 }
54
55 public int getMaxInactiveInterval(){
56 return maxInactiveInterval;
57 }
58
59 /**
60 * The underlying mock objects throws an Assert failure if we don't have
61 * an attribute. However, in Turbine, getting a null is okay, it just
62 * means we haven't put the object in yet!
63 */
64 public Object getAttribute(String attributeName)
65 {
66 try
67 {
68 return super.getAttribute(attributeName);
69 }
70 catch (junit.framework.AssertionFailedError afe)
71 {
72 return null;
73 }
74 }
75 }