001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.http.commons.session; 019 020import static org.junit.Assert.assertEquals; 021import static org.junit.Assert.assertFalse; 022import static org.junit.Assert.assertTrue; 023import static org.mockito.Mockito.when; 024 025import org.fcrepo.kernel.api.FedoraSession; 026 027import org.junit.Before; 028import org.junit.Test; 029import org.junit.runner.RunWith; 030import org.mockito.Mock; 031import org.mockito.junit.MockitoJUnitRunner; 032 033/** 034 * Test the HttpSession class 035 * @author acoburn 036 */ 037@RunWith(MockitoJUnitRunner.class) 038public class HttpSessionTest { 039 040 private final String SESSION_ID = "session-id"; 041 042 @Mock 043 private FedoraSession mockSession; 044 045 @Before 046 public void setUp() { 047 when(mockSession.getId()).thenReturn(SESSION_ID); 048 } 049 050 @Test 051 public void testHttpSession() { 052 final HttpSession session = new HttpSession(mockSession); 053 assertFalse(session.isBatchSession()); 054 session.makeBatchSession(); 055 assertTrue(session.isBatchSession()); 056 assertEquals(SESSION_ID, session.getId()); 057 assertEquals(mockSession, session.getFedoraSession()); 058 } 059}