/**
 * Copyright (c) 2002-2011 "Neo Technology,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.neo4j.kernel.impl.nioneo.store;

import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.internal.matchers.StringContains.containsString;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;

import org.junit.Test;
import org.neo4j.kernel.CommonFactories;
import org.neo4j.kernel.IdGeneratorFactory;
import org.neo4j.kernel.impl.util.FileUtils;

public class StoreVersionTest
{
    @Test
    public void allStoresShouldHaveTheCurrentVersionIdentifier() throws IOException
    {
        File outputDir = new File( "target/var/" + StoreVersionTest.class.getSimpleName() );
        FileUtils.deleteRecursively( outputDir );
        assertTrue( outputDir.mkdirs() );
        String storeFileName = new File(outputDir, "neostore").getPath();

        HashMap config = new HashMap();
        config.put( IdGeneratorFactory.class, CommonFactories.defaultIdGeneratorFactory() );
        config.put( FileSystemAbstraction.class, CommonFactories.defaultFileSystemAbstraction() );
        config.put( "neo_store", storeFileName );

        NeoStore.createStore( storeFileName, config );
        NeoStore neoStore = new NeoStore( config );

        CommonAbstractStore[] stores = {
                neoStore.getNodeStore(),
                neoStore.getRelationshipStore(),
                neoStore.getRelationshipTypeStore(),
                neoStore.getPropertyStore(),
                neoStore.getPropertyStore().getIndexStore()
        };

        for ( CommonAbstractStore store : stores )
        {
            assertThat(store.getTypeAndVersionDescriptor(), containsString( CommonAbstractStore.ALL_STORES_VERSION ));
        }
    }
}

@@ -921,16 +921,53 @@
 rtTrue;%0A
+import static org.junit.Assert.fail;%0A
 import s
@@ -1031,16 +1031,16 @@
 String;%0A
-
 %0Aimport 
@@ -1081,16 +1081,37 @@
 eption;%0A
+import java.net.URL;%0A
 import j
@@ -1237,16 +1237,75 @@
 actory;%0A
+import org.neo4j.kernel.impl.storemigration.StoreMigrator;%0A
 import o
@@ -1699,16 +1699,17 @@
 ew File(
+ 
 outputDi
@@ -1721,16 +1721,17 @@
 eostore%22
+ 
 ).getPat
@@ -2512,16 +2512,17 @@
 ertThat(
+ 
 store.ge
@@ -2606,16 +2606,17 @@
 ERSION )
+ 
 );%0A     
@@ -2625,11 +2625,1024 @@
  %7D%0A    %7D
+%0A%0A    @Test%0A    public void shouldFailToCreateAStoreContainingOldVersionNumber() throws IOException%0A    %7B%0A        File outputDir = new File( %22target/var/%22 + StoreVersionTest.class.getSimpleName() );%0A        FileUtils.deleteRecursively( outputDir );%0A        assertTrue( outputDir.mkdirs() );%0A%0A        URL legacyStoreResource = StoreMigrator.class.getResource( %22oldformatstore/neostore.nodestore.db%22 );%0A        File workingFile = new File( outputDir, %22neostore.nodestore.db%22 );%0A        FileUtils.copyFile( new File( legacyStoreResource.getFile() ), workingFile );%0A%0A        HashMap config = new HashMap();%0A        config.put( IdGeneratorFactory.class, CommonFactories.defaultIdGeneratorFactory() );%0A        config.put( FileSystemAbstraction.class, CommonFactories.defaultFileSystemAbstraction() );%0A%0A        try %7B%0A            new NodeStore( workingFile.getPath(), config );%0A            fail( %22Should have thrown exception%22 );%0A        %7D catch ( IllegalStoreVersionException e ) %7B%0A            //expected%0A        %7D%0A    %7D
 %0A%7D%0A

Add a simple test around creating store based on old version files