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); }
//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(); }