Example #1
0
        private void SetupDb(GraphDatabaseSettings.SchemaIndex schemaIndex)
        {
            TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory();
            GraphDatabaseBuilder     builder   = dbFactory.NewEmbeddedDatabaseBuilder(_directory.storeDir()).setConfig(GraphDatabaseSettings.default_schema_provider, schemaIndex.providerName());

            _db = builder.NewGraphDatabase();
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void restart(org.neo4j.io.fs.FileSystemAbstraction fs) throws java.io.IOException
        private void Restart(FileSystemAbstraction fs)
        {
            if (_db != null)
            {
                _db.shutdown();
            }

            fs.Mkdirs(_storeDir);
            TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory();

            _db = dbFactory.setUserLogProvider(_userLogProvider).setInternalLogProvider(_internalLogProvider).setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs)).newImpermanentDatabaseBuilder(_storeDir).setConfig(index_background_sampling_enabled, "false").newGraphDatabase();
        }
Example #3
0
        private GraphDatabaseAPI NewDb(string logPruning, int rotateEveryNTransactions)
        {
            this._rotateEveryNTransactions = rotateEveryNTransactions;
            _fs = new EphemeralFileSystemAbstraction();
            TestGraphDatabaseFactory gdf = new TestGraphDatabaseFactory();

            gdf.FileSystem = new UncloseableDelegatingFileSystemAbstraction(_fs);
            GraphDatabaseBuilder builder = gdf.NewImpermanentDatabaseBuilder();

            builder.setConfig(keep_logical_logs, logPruning);
            this._db = ( GraphDatabaseAPI )builder.NewGraphDatabase();
            _files   = _db.DependencyResolver.resolveDependency(typeof(LogFiles));
            return(_db);
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveAvailableOrphanedConstraintIndexIfUniqueConstraintCreationFails()
        public virtual void ShouldHaveAvailableOrphanedConstraintIndexIfUniqueConstraintCreationFails()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction fs = fileSystemRule.get();
            EphemeralFileSystemAbstraction fs = FileSystemRule.get();

            fs.Mkdir(new File("/tmp"));
            File pathToDb = new File("/tmp/bar2");

            TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory();

            dbFactory.FileSystem = fs;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction[] storeInNeedOfRecovery = new org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction[1];
            EphemeralFileSystemAbstraction[] storeInNeedOfRecovery = new EphemeralFileSystemAbstraction[1];
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean monitorCalled = new java.util.concurrent.atomic.AtomicBoolean(false);
            AtomicBoolean monitorCalled = new AtomicBoolean(false);

            Monitors monitors = new Monitors();

            monitors.AddMonitorListener(new MonitorAdapterAnonymousInnerClass(this, fs, storeInNeedOfRecovery, monitorCalled));
            dbFactory.Monitors = monitors;

            // This test relies on behaviour that is specific to the Lucene populator, where uniqueness is controlled
            // after index has been populated, which is why we're using NATIVE20 and index booleans (they end up in Lucene)
            _db = ( GraphDatabaseAPI )dbFactory.NewImpermanentDatabaseBuilder(pathToDb).setConfig(default_schema_provider, NATIVE20.providerName()).newGraphDatabase();

            using (Transaction tx = _db.beginTx())
            {
                for (int i = 0; i < 2; i++)
                {
                    _db.createNode(_label).setProperty(KEY, true);
                }

                tx.Success();
            }

            try
            {
                using (Transaction tx = _db.beginTx())
                {
                    _db.schema().constraintFor(_label).assertPropertyIsUnique(KEY).create();
                    fail("Should have failed with ConstraintViolationException");
                    tx.Success();
                }
            }
            catch (ConstraintViolationException)
            {
            }

            _db.shutdown();

            assertTrue(monitorCalled.get());

            // when
            dbFactory            = new TestGraphDatabaseFactory();
            dbFactory.FileSystem = storeInNeedOfRecovery[0];
            _db = ( GraphDatabaseAPI )dbFactory.NewImpermanentDatabase(pathToDb);

            // then
            using (Transaction ignore = _db.beginTx())
            {
                _db.schema().awaitIndexesOnline(10, TimeUnit.SECONDS);
            }

            using (Transaction ignore = _db.beginTx())
            {
                assertEquals(2, Iterables.count(_db.AllNodes));
            }

            using (Transaction ignore = _db.beginTx())
            {
                assertEquals(0, Iterables.count(Iterables.asList(_db.schema().Constraints)));
            }

            using (Transaction ignore = _db.beginTx())
            {
                IndexDefinition orphanedConstraintIndex = single(_db.schema().Indexes);
                assertEquals(_label.name(), single(orphanedConstraintIndex.Labels).name());
                assertEquals(KEY, single(orphanedConstraintIndex.PropertyKeys));
            }

            _db.shutdown();
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            _factory                  = new TestGraphDatabaseFactory();
            _factory.FileSystem       = new UncloseableDelegatingFileSystemAbstraction(Fs.get());
            _factory.KernelExtensions = Collections.singletonList(singleInstanceIndexProviderFactory("test", _provider));
        }