Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void lastCommitedTxGetsStoredBetweenSessions()
        public virtual void LastCommitedTxGetsStoredBetweenSessions()
        {
            IndexProviderStore store = new IndexProviderStore(_file, _fileSystem, 0, false);

            store.Version         = 5;
            store.LastCommittedTx = 12;
            store.Close();
            store = new IndexProviderStore(_file, _fileSystem, 0, false);
            assertEquals(5, store.Version);
            assertEquals(12, store.LastCommittedTx);
            store.Close();
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteNewFileWhenExistingFileHasZeroLength() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteNewFileWhenExistingFileHasZeroLength()
        {
            // Given
            _file.createNewFile();

            // When
            IndexProviderStore store = new IndexProviderStore(_file, _fileSystem, MetaDataStore.versionStringToLong("3.5"), false);

            // Then
            assertTrue(_fileSystem.getFileSize(_file) > 0);
            store.Close();
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = org.neo4j.kernel.impl.store.NotCurrentStoreVersionException.class) public void shouldFailToGoBackToOlderVersionEvenIfAllowUpgrade()
        public virtual void ShouldFailToGoBackToOlderVersionEvenIfAllowUpgrade()
        {
            string newerVersion = "3.5";
            string olderVersion = "3.1";

            try
            {
                IndexProviderStore store = new IndexProviderStore(_file, _fileSystem, MetaDataStore.versionStringToLong(newerVersion), true);
                store.Close();
                store = new IndexProviderStore(_file, _fileSystem, MetaDataStore.versionStringToLong(olderVersion), true);
            }
            catch (NotCurrentStoreVersionException e)
            {
                assertTrue(e.Message.contains(newerVersion));
                assertTrue(e.Message.contains(olderVersion));
                throw e;
            }
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailUpgradeIfNotAllowed()
        public virtual void ShouldFailUpgradeIfNotAllowed()
        {
            IndexProviderStore store = new IndexProviderStore(_file, _fileSystem, MetaDataStore.versionStringToLong("3.1"), true);

            store.Close();
            store = new IndexProviderStore(_file, _fileSystem, MetaDataStore.versionStringToLong("3.1"), false);
            store.Close();
            try
            {
                new IndexProviderStore(_file, _fileSystem, MetaDataStore.versionStringToLong("3.5"), false);
                fail("Shouldn't be able to upgrade there");
            }
            catch (UpgradeNotAllowedByConfigurationException)
            {               // Good
            }
            store = new IndexProviderStore(_file, _fileSystem, MetaDataStore.versionStringToLong("3.5"), true);
            assertEquals("3.5", MetaDataStore.versionLongToString(store.IndexVersion));
            store.Close();
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void upgradeForMissingVersionRecord() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpgradeForMissingVersionRecord()
        {
            // This was before 1.6.M02
            IndexProviderStore store = new IndexProviderStore(_file, _fileSystem, 0, false);

            store.Close();
            FileUtils.truncateFile(_file, 4 * 8);
            try
            {
                store = new IndexProviderStore(_file, _fileSystem, 0, false);
                fail("Should have thrown upgrade exception");
            }
            catch (UpgradeNotAllowedByConfigurationException)
            {               // Good
            }

            store = new IndexProviderStore(_file, _fileSystem, 0, true);
            store.Close();
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldForceChannelAfterWritingMetadata() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldForceChannelAfterWritingMetadata()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.fs.StoreChannel[] channelUsedToCreateFile = {null};
            StoreChannel[] channelUsedToCreateFile = new StoreChannel[] { null };

            FileSystemAbstraction fs = spy(_fileSystem);
            StoreChannel          tempChannel;

            when(tempChannel = fs.Open(_file, OpenMode.READ_WRITE)).then(ignored =>
            {
                StoreChannel channel = _fileSystem.open(_file, OpenMode.READ_WRITE);
                if (channelUsedToCreateFile[0] == null)
                {
                    StoreChannel channelSpy    = spy(channel);
                    channelUsedToCreateFile[0] = channelSpy;
                    channel = channelSpy;
                }
                return(channel);
            });

            // Doing the FSA spying above, calling fs.open, actually invokes that method and so a channel
            // is opened. We put that in tempChannel and close it before deleting the file below.
            tempChannel.close();
            fs.DeleteFile(_file);

            // When
            IndexProviderStore store = new IndexProviderStore(_file, fs, MetaDataStore.versionStringToLong("3.5"), false);

            // Then
            StoreChannel channel = channelUsedToCreateFile[0];

            verify(channel).writeAll(any(typeof(ByteBuffer)), eq(0L));
            verify(channel).force(true);
            verify(channel).close();
            verifyNoMoreInteractions(channel);
            store.Close();
        }