예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void consistencyCheckerLogUseSystemTimezoneIfConfigurable() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ConsistencyCheckerLogUseSystemTimezoneIfConfigurable()
        {
            TimeZone defaultTimeZone = TimeZone.Default;

            try
            {
                ConsistencyCheckService service = mock(typeof(ConsistencyCheckService));
                Mockito.when(service.runFullConsistencyCheck(any(typeof(DatabaseLayout)), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(typeof(ConsistencyFlags)))).then(invocationOnMock =>
                {
                    LogProvider provider = invocationOnMock.getArgument(3);
                    provider.getLog("test").info("testMessage");
                    return(ConsistencyCheckService.Result.success(new File(StringUtils.EMPTY)));
                });
                File       storeDir   = _testDirectory.directory();
                File       configFile = _testDirectory.file(Config.DEFAULT_CONFIG_FILE_NAME);
                Properties properties = new Properties();
                properties.setProperty(GraphDatabaseSettings.db_timezone.name(), LogTimeZone.SYSTEM.name());
                properties.store(new StreamWriter(configFile), null);
                string[] args = new string[] { storeDir.Path, "-config", configFile.Path };

                CheckLogRecordTimeZone(service, args, 5, "+0500");
                CheckLogRecordTimeZone(service, args, -5, "-0500");
            }
            finally
            {
                TimeZone.Default = defaultTimeZone;
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void addTwoMergeTasksWhenWriterHastwoMergeToPerform() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void AddTwoMergeTasksWhenWriterHastwoMergeToPerform()
        {
            SegmentCommitInfo segmentCommitInfo = SegmentCommitInfo;

            Mockito.when(_indexWriter.NextMerge).thenReturn(new TestOneMerge(segmentCommitInfo)).thenReturn(new TestOneMerge(segmentCommitInfo)).thenReturn(null);

            _mergeScheduler.merge(_indexWriter, MergeTrigger.EXPLICIT, false);

            assertEquals(2, _mergeScheduler.WriterTaskCount);
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testPluginInitialization()
        public virtual void TestPluginInitialization()
        {
            Config    config    = Config.defaults(ServerSettings.transaction_idle_timeout, "600");
            NeoServer neoServer = Mockito.mock(typeof(NeoServer), Mockito.RETURNS_DEEP_STUBS);

            Mockito.when(neoServer.Config).thenReturn(config);
            ExtensionInitializer extensionInitializer = new ExtensionInitializer(neoServer);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Collection<org.neo4j.server.plugins.Injectable<?>> injectableProperties = extensionInitializer.initializePackages(java.util.Collections.singletonList("org.neo4j.server.modules"));
            ICollection <Injectable <object> > injectableProperties = extensionInitializer.InitializePackages(Collections.singletonList("org.neo4j.server.modules"));

            assertTrue(injectableProperties.Any(i => ServerSettings.transaction_idle_timeout.name().Equals(i.Value)));
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowExceptionOnRelationshipDuplicateRuleFound() throws org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionOnRelationshipDuplicateRuleFound()
        {
            // GIVEN
            TokenNameLookup tokenNameLookup = DefaultTokenNameLookup;

            SchemaStorage schemaStorageSpy = Mockito.spy(_storage);

            Mockito.when(schemaStorageSpy.LoadAllSchemaRules(any(), any(), anyBoolean())).thenReturn(Iterators.iterator(GetRelationshipPropertyExistenceConstraintRule(1L, TYPE1, PROP1), GetRelationshipPropertyExistenceConstraintRule(2L, TYPE1, PROP1)));

            //EXPECT
            ExpectedException.expect(typeof(DuplicateSchemaRuleException));
            ExpectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "Multiple relationship property existence constraints found for -[:Type1(prop1)]-."));

            // WHEN
            schemaStorageSpy.ConstraintsGetSingle(ConstraintDescriptorFactory.existsForRelType(TypeId(TYPE1), PropId(PROP1)));
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowExceptionOnNodeDuplicateRuleFound() throws org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionOnNodeDuplicateRuleFound()
        {
            // GIVEN
            TokenNameLookup tokenNameLookup = DefaultTokenNameLookup;

            SchemaStorage schemaStorageSpy = Mockito.spy(_storage);

            Mockito.when(schemaStorageSpy.LoadAllSchemaRules(any(), any(), anyBoolean())).thenReturn(Iterators.iterator(GetUniquePropertyConstraintRule(1L, LABEL1, PROP1), GetUniquePropertyConstraintRule(2L, LABEL1, PROP1)));

            //EXPECT
            ExpectedException.expect(typeof(DuplicateSchemaRuleException));
            ExpectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "Multiple uniqueness constraints found for :Label1(prop1)."));

            // WHEN
            schemaStorageSpy.ConstraintsGetSingle(ConstraintDescriptorFactory.uniqueForLabel(LabelId(LABEL1), PropId(PROP1)));
        }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private org.neo4j.cypher.internal.javacompat.ExecutionResult result(String column, Object value)
        private ExecutionResult Result(string column, object value)
        {
            ExecutionResult result = Mockito.mock(typeof(ExecutionResult));

            Mockito.when(result.Columns()).thenReturn(asList(column));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.Iterator<java.util.Map<String, Object>> inner = asList(singletonMap(column, value)).iterator();
            IEnumerator <IDictionary <string, object> > inner = asList(singletonMap(column, value)).GetEnumerator();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.ResourceIterator<java.util.Map<String, Object>> iterator = new org.neo4j.graphdb.ResourceIterator<java.util.Map<String, Object>>()
            ResourceIterator <IDictionary <string, object> > iterator = new ResourceIteratorAnonymousInnerClass(this, inner);

            Mockito.when(result.GetEnumerator()).thenReturn(iterator);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            Mockito.when(result.HasNext()).thenAnswer(invocation => iterator.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            Mockito.when(result.Next()).thenAnswer(invocation => iterator.next());
            return(result);
        }
예제 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void writerCloseWaitForMergesInMergeQueue()
        internal virtual void WriterCloseWaitForMergesInMergeQueue()
        {
            assertTimeout(Duration.ofSeconds(10), () =>
            {
                _indexWriter = mock(typeof(IndexWriter));
                SegmentCommitInfo segmentCommitInfo = SegmentCommitInfo;

                Mockito.when(_indexWriter.NextMerge).thenReturn(new TestOneMerge(segmentCommitInfo)).thenReturn(null);

                _mergeScheduler.merge(_indexWriter, MergeTrigger.EXPLICIT, false);

                assertEquals(1, _mergeScheduler.WriterTaskCount);

                Thread closeSchedulerThread = ThreadTestUtils.fork(() => _mergeScheduler.close());
                ThreadTestUtils.awaitThreadState(closeSchedulerThread, TimeUnit.SECONDS.toMillis(5), Thread.State.TIMED_WAITING);
                _mergeScheduler.ExecutionLatch.Signal();
                closeSchedulerThread.Join();

                assertEquals(0, _mergeScheduler.WriterTaskCount);
            });
        }