package org.neo4j.kernel.api;

import org.junit.Test;

import org.neo4j.kernel.api.scan.LabelScanReader;
import org.neo4j.kernel.api.scan.LabelScanStore;
import org.neo4j.kernel.impl.api.IndexReaderFactory;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

public class KernelStatementTest
{
    @Test
    public void shouldCloseOpenedLabelScanReader() throws Exception
    {
        // given
        LabelScanStore scanStore = mock( LabelScanStore.class );
        LabelScanReader scanReader = mock( LabelScanReader.class );

        when( scanStore.newReader() ).thenReturn( scanReader );
        KernelStatement statement =
            new KernelStatement(
                mock( KernelTransactionImplementation.class ),
                mock( IndexReaderFactory.class ), scanStore, null, null, null, null );

        statement.acquire();

        // when
        LabelScanReader actualReader = statement.getLabelScanReader();

        // then
        assertEquals( scanReader, actualReader );

        // when
        statement.close();

        // then
        verify( scanStore ).newReader();
        verifyNoMoreInteractions( scanStore );

        verify( scanReader ).close();
        verifyNoMoreInteractions( scanReader );
    }
}

@@ -1,8 +1,805 @@
+/**%0A * Copyright (c) 2002-2013 %22Neo Technology,%22%0A * Network Engine for Objects in Lund AB %5Bhttp://neotechnology.com%5D%0A *%0A * This file is part of Neo4j.%0A *%0A * Neo4j is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A *%0A * You should have received a copy of the GNU General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A
 package 

Add forgotten license header. Meh.