/*
* Copyright 2004-2006 Fouad HAMDI with the idea
* of SameLAN, S.L. Soluciones Tecnolgicas.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.csvbeans.context;
import junit.framework.TestCase;
/**
* Tests for ContextManager.
*
* @author Fouad Hamdi
* @since 0.7
*/
public class ContextManagerTest extends TestCase {
private ContextManager manager;
protected void setUp() throws Exception {
manager = new ContextManagerImpl();
}
public void testRecordContext() throws Exception {
manager.setRecordAttribute("attribute", "value");
assertEquals("value", manager.getRecordAttribute("attribute"));
assertEquals("value", manager.getAttribute("attribute"));
assertEquals("value", manager.getAttribute("attribute", "record"));
manager.setAttribute("attribute", "value2", "record");
assertEquals("value2", manager.getRecordAttribute("attribute"));
}
public void testSessionContext() throws Exception {
manager.setSessionAttribute("attribute", "value");
assertEquals("value", manager.getSessionAttribute("attribute"));
assertEquals("value", manager.getAttribute("attribute"));
assertEquals("value", manager.getAttribute("attribute", "session"));
manager.setAttribute("attribute", "value2", "session");
assertEquals("value2", manager.getSessionAttribute("attribute"));
}
public void testMixedAttributes() throws Exception {
manager.setRecordAttribute("attribute", "value1");
manager.setSessionAttribute("attribute", "value2");
assertEquals("value1", manager.getAttribute("attribute"));
}
}
|