001 // Copyright 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry; 016 017 import org.testng.annotations.Test; 018 019 import javax.servlet.http.HttpSession; 020 import javax.servlet.http.HttpSessionBindingEvent; 021 022 /** 023 * Tests for {@link org.apache.tapestry.BaseSessionStoreOptimized}. 024 * 025 * @author Howard M. Lewis Ship 026 * @since 4.0 027 */ 028 @Test 029 public class TestBaseSessionStoreOptimized extends BaseComponentTestCase 030 { 031 @Test 032 public void testMarkDirty() 033 { 034 BaseSessionStoreOptimized object = new BaseSessionStoreOptimized(); 035 036 assertEquals(false, object.isStoreToSessionNeeded()); 037 038 object.markSessionStoreNeeded(); 039 040 assertEquals(true, object.isStoreToSessionNeeded()); 041 } 042 043 @Test 044 public void testMarkClean() 045 { 046 HttpSession session = newMock(HttpSession.class); 047 048 BaseSessionStoreOptimized object = new BaseSessionStoreOptimized(); 049 050 object.markSessionStoreNeeded(); 051 052 replay(); 053 054 object.valueBound(new HttpSessionBindingEvent(session, "sessionid", object)); 055 056 assertEquals(false, object.isStoreToSessionNeeded()); 057 058 verify(); 059 } 060 061 @Test 062 public void testUnboundDoesNothing() 063 { 064 HttpSession session = newMock(HttpSession.class); 065 066 BaseSessionStoreOptimized object = new BaseSessionStoreOptimized(); 067 068 object.markSessionStoreNeeded(); 069 070 replay(); 071 072 object.valueUnbound(new HttpSessionBindingEvent(session, "sessionid", object)); 073 074 assertEquals(true, object.isStoreToSessionNeeded()); 075 076 verify(); 077 078 } 079 080 }