001 package org.apache.turbine.test;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022 import com.mockobjects.servlet.MockHttpSession;
023 /**
024 * Extension to the basic MockHttpSession to provide some extra parameters
025 * required by Turbine.
026 *
027 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
028 * @version $Id: EnhancedMockHttpSession.java 615328 2008-01-25 20:25:05Z tv $
029 */
030 public class EnhancedMockHttpSession extends MockHttpSession
031 {
032 private boolean isNew = true;
033 private int maxInactiveInterval =0;
034
035 /**
036 *
037 */
038 public EnhancedMockHttpSession()
039 {
040 super();
041 }
042 /**
043 * The default MockHttpSession doesn't implement this method. It always
044 * returns true.
045 */
046 public boolean isNew()
047 {
048 return isNew;
049 }
050
051 public void setMaxInactiveInterval(int maxInactiveInterval){
052 this.maxInactiveInterval =maxInactiveInterval;
053 }
054
055 public int getMaxInactiveInterval(){
056 return maxInactiveInterval;
057 }
058
059 /**
060 * The underlying mock objects throws an Assert failure if we don't have
061 * an attribute. However, in Turbine, getting a null is okay, it just
062 * means we haven't put the object in yet!
063 */
064 public Object getAttribute(String attributeName)
065 {
066 try
067 {
068 return super.getAttribute(attributeName);
069 }
070 catch (junit.framework.AssertionFailedError afe)
071 {
072 return null;
073 }
074 }
075 }