예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDropUniquenessConstraintWithBackingIndexHavingNoOwner() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void ShouldDropUniquenessConstraintWithBackingIndexHavingNoOwner()
		 {
			  // given
			  using ( Transaction tx = Db.beginTx() )
			  {
					Db.schema().constraintFor(_label).assertPropertyIsUnique(_key).create();
					tx.Success();
			  }

			  // when intentionally breaking the schema by setting the backing index rule to unused
			  RecordStorageEngine storageEngine = Db.DependencyResolver.resolveDependency( typeof( RecordStorageEngine ) );
			  SchemaStore schemaStore = storageEngine.TestAccessNeoStores().SchemaStore;
			  SchemaRule indexRule = single( filter( rule => rule is StoreIndexDescriptor, schemaStore.LoadAllSchemaRules() ) );
			  SetOwnerNull( schemaStore, ( StoreIndexDescriptor ) indexRule );
			  // At this point the SchemaCache doesn't know about this change so we have to reload it
			  storageEngine.LoadSchemaCache();
			  using ( Transaction tx = Db.beginTx() )
			  {
					single( Db.schema().getConstraints(_label).GetEnumerator() ).drop();
					tx.Success();
			  }

			  // then
			  using ( Transaction ignore = Db.beginTx() )
			  {
					assertFalse( Db.schema().Constraints.GetEnumerator().hasNext() );
					assertFalse( Db.schema().Indexes.GetEnumerator().hasNext() );
			  }
		 }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDropUniquenessConstraintWhereConstraintRecordIsMissingAndIndexHasNoOwner() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void ShouldDropUniquenessConstraintWhereConstraintRecordIsMissingAndIndexHasNoOwner()
		 {
			  // given
			  using ( Transaction tx = Db.beginTx() )
			  {
					Db.schema().constraintFor(_label).assertPropertyIsUnique(_key).create();
					tx.Success();
			  }

			  // when intentionally breaking the schema by setting the backing index rule to unused
			  RecordStorageEngine storageEngine = Db.DependencyResolver.resolveDependency( typeof( RecordStorageEngine ) );
			  SchemaStore schemaStore = storageEngine.TestAccessNeoStores().SchemaStore;
			  SchemaRule constraintRule = single( filter( rule => rule is ConstraintRule, schemaStore.LoadAllSchemaRules() ) );
			  SetSchemaRecordNotInUse( schemaStore, constraintRule.Id );
			  SchemaRule indexRule = single( filter( rule => rule is StoreIndexDescriptor, schemaStore.LoadAllSchemaRules() ) );
			  SetOwnerNull( schemaStore, ( StoreIndexDescriptor ) indexRule );
			  // At this point the SchemaCache doesn't know about this change so we have to reload it
			  storageEngine.LoadSchemaCache();
			  using ( Transaction tx = Db.beginTx() )
			  {
					// We don't use single() here, because it is okay for the schema cache reload to clean up after us.
					Db.schema().getConstraints(_label).forEach(ConstraintDefinition.drop);
					Db.schema().getIndexes(_label).forEach(IndexDefinition.drop);
					tx.Success();
			  }

			  // then
			  using ( Transaction ignore = Db.beginTx() )
			  {
					assertFalse( Db.schema().Constraints.GetEnumerator().hasNext() );
					assertFalse( Db.schema().Indexes.GetEnumerator().hasNext() );
			  }
		 }
예제 #3
0
        private void PrepareDbWithDeletedRelationshipPartOfTheChain()
        {
            GraphDatabaseAPI db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(_testDirectory.databaseDir()).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).setConfig("dbms.backup.enabled", "false").newGraphDatabase();

            try
            {
                RelationshipType relationshipType = RelationshipType.withName("testRelationshipType");
                using (Transaction tx = Db.beginTx())
                {
                    Node node1 = set(Db.createNode());
                    Node node2 = set(Db.createNode(), property("key", "value"));
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    node1.CreateRelationshipTo(node2, relationshipType);
                    tx.Success();
                }

                RecordStorageEngine recordStorageEngine = Db.DependencyResolver.resolveDependency(typeof(RecordStorageEngine));

                NeoStores          neoStores          = recordStorageEngine.TestAccessNeoStores();
                RelationshipStore  relationshipStore  = neoStores.RelationshipStore;
                RelationshipRecord relationshipRecord = new RelationshipRecord(-1);
                RelationshipRecord record             = relationshipStore.GetRecord(4, relationshipRecord, RecordLoad.FORCE);
                record.InUse = false;
                relationshipStore.UpdateRecord(relationshipRecord);
            }
            finally
            {
                Db.shutdown();
            }
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void skipMigrationIfStoreFormatNotSpecifiedButIsAvailableInRuntime()
        internal virtual void SkipMigrationIfStoreFormatNotSpecifiedButIsAvailableInRuntime()
        {
            GraphDatabaseService database = StartDatabaseWithFormatUnspecifiedUpgrade(_storeDir, StandardV3_2.NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode();
                node.SetProperty("a", "b");
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseAPI    nonUpgradedStore = ( GraphDatabaseAPI )(new GraphDatabaseFactory()).newEmbeddedDatabase(_storeDir);
            RecordStorageEngine storageEngine    = nonUpgradedStore.DependencyResolver.resolveDependency(typeof(RecordStorageEngine));

            assertEquals(StandardV3_2.NAME, storageEngine.TestAccessNeoStores().RecordFormats.name());
            nonUpgradedStore.Shutdown();
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rotationShouldNotCauseUnmappedFileProblem() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RotationShouldNotCauseUnmappedFileProblem()
        {
            // GIVEN
            GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase();

            DependencyResolver  resolver      = Db.DependencyResolver;
            RecordStorageEngine storageEngine = resolver.ResolveDependency(typeof(RecordStorageEngine));
            CountsTracker       countStore    = storageEngine.TestAccessNeoStores().Counts;

            AtomicBoolean workerContinueFlag = new AtomicBoolean(true);
            AtomicLong    lookupsCounter     = new AtomicLong();
            int           rotations          = 100;

            for (int i = 0; i < 5; i++)
            {
                _threadingRule.execute(CountStoreLookup(workerContinueFlag, lookupsCounter), countStore);
            }

            long startTxId = countStore.TxId();

            for (int i = 1; (i < rotations) || (lookupsCounter.get() == 0); i++)
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode(_b);
                    tx.Success();
                }
                CheckPoint(db);
            }
            workerContinueFlag.set(false);

            assertEquals("Should perform at least 100 rotations.", rotations, Math.Min(rotations, countStore.TxId() - startTxId));
            assertTrue("Should perform more then 0 lookups without exceptions.", lookupsCounter.get() > 0);

            Db.shutdown();
        }