예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListInboundProtocols() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldListInboundProtocols()
        {
            // given
            InstalledProtocolsProcedure installedProtocolsProcedure = new InstalledProtocolsProcedure(Stream.empty, () => Stream.of(_inbound1, _inbound2));

            // when
            RawIterator <object[], ProcedureException> result = installedProtocolsProcedure.Apply(null, null, null);

            // then
            assertThat(result.Next(), arrayContaining("inbound", "host3:3", "raft", 3L, "[TestSnappy]"));
            assertThat(result.Next(), arrayContaining("inbound", "host4:4", "raft", 4L, "[]"));
            assertFalse(result.HasNext());
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldListOutboundProtocols() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldListOutboundProtocols()
        {
            // given
            InstalledProtocolsProcedure installedProtocolsProcedure = new InstalledProtocolsProcedure(() => Stream.of(_outbound1, _outbound2), Stream.empty);

            // when
            RawIterator <object[], ProcedureException> result = installedProtocolsProcedure.Apply(null, null, null);

            // then
            assertThat(result.Next(), arrayContaining("outbound", "host1:1", "raft", 1L, "[TestSnappy]"));
            assertThat(result.Next(), arrayContaining("outbound", "host2:2", "raft", 2L, "[TestSnappy,ROT13]"));
            assertFalse(result.HasNext());
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void testCreateIndexWithGivenProvider(String label, String... properties) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        private void TestCreateIndexWithGivenProvider(string label, params string[] properties)
        {
            // given
            Transaction transaction = NewTransaction(AnonymousContext.writeToken());
            int         labelId     = transaction.TokenWrite().labelGetOrCreateForName(label);

            int[]     propertyKeyIds = CreateProperties(transaction, properties);
            TextValue value          = stringValue("some value");
            long      node           = CreateNodeWithPropertiesAndLabel(transaction, labelId, propertyKeyIds, value);

            Commit();

            // when
            NewTransaction(AnonymousContext.full());
            string pattern           = IndexPattern(label, properties);
            string specifiedProvider = NATIVE10.providerName();
            RawIterator <object[], ProcedureException> result = CallIndexProcedure(pattern, specifiedProvider);

            // then
            assertThat(Arrays.asList(result.Next()), contains(pattern, specifiedProvider, ExpectedSuccessfulCreationStatus));
            Commit();
            AwaitIndexOnline();

            // and then
            transaction = NewTransaction(AnonymousContext.read());
            SchemaRead     schemaRead = transaction.SchemaRead();
            IndexReference index      = schemaRead.Index(labelId, propertyKeyIds);

            AssertCorrectIndex(labelId, propertyKeyIds, UniquenessConstraint, index);
            AssertIndexData(transaction, propertyKeyIds, value, node, index);
            Commit();
        }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.util.List<ProtocolInfo> installedProtocols(org.neo4j.kernel.impl.factory.GraphDatabaseFacade db, String wantedOrientation) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException, org.neo4j.internal.kernel.api.exceptions.ProcedureException
        private IList <ProtocolInfo> InstalledProtocols(GraphDatabaseFacade db, string wantedOrientation)
        {
            IList <ProtocolInfo> infos = new LinkedList <ProtocolInfo>();
            Kernel kernel = Db.DependencyResolver.resolveDependency(typeof(Kernel));

            using (Transaction tx = kernel.BeginTransaction([email protected]_Type.Implicit, AnonymousContext.read()))
            {
                RawIterator <object[], ProcedureException> itr = tx.Procedures().procedureCallRead(procedureName("dbms", "cluster", InstalledProtocolsProcedure.PROCEDURE_NAME), null, ProcedureCallContext.EMPTY);

                while (itr.HasNext())
                {
                    object[] row         = itr.Next();
                    string   orientation = ( string )row[0];
                    string   address     = Localhost(( string )row[1]);
                    string   protocol    = ( string )row[2];
                    long     version     = ( long )row[3];
                    string   modifiers   = ( string )row[4];
                    if (orientation.Equals(wantedOrientation))
                    {
                        infos.Add(new ProtocolInfo(orientation, address, protocol, version, modifiers));
                    }
                }
                return(infos);
            }
        }
예제 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <T, EX extends Exception> java.util.List<T> asList(org.neo4j.collection.RawIterator<T, EX> iterator) throws EX
        public static IList <T> AsList <T, EX>(RawIterator <T, EX> iterator) where EX : Exception
        {
            IList <T> @out = new List <T>();

            while (iterator.HasNext())
            {
                @out.Add(iterator.Next());
            }
            return(@out);
        }
예제 #6
0
        private static IList <int> List(RawIterator <int, Exception> iter)
        {
            LinkedList <int> @out = new LinkedList <int>();

            while (iter.HasNext())
            {
                @out.AddLast(iter.Next());
            }
            return(@out);
        }
예제 #7
0
파일: CsvInput.cs 프로젝트: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long[] sample(Iterable<DataFactory> dataFactories, Header.Factory headerFactory, System.Func<org.neo4j.values.storable.Value[], int> valueSizeCalculator, System.Func<org.neo4j.unsafe.impl.batchimport.input.InputEntity, int> additionalCalculator) throws java.io.IOException
        private long[] Sample(IEnumerable <DataFactory> dataFactories, Header.Factory headerFactory, System.Func <Value[], int> valueSizeCalculator, System.Func <InputEntity, int> additionalCalculator)
        {
            long[] estimates = new long[4];               // [entity count, property count, property size, labels (for nodes only)]
            using (CsvInputChunkProxy chunk = new CsvInputChunkProxy())
            {
                // One group of input files
                int groupId = 0;
                foreach (DataFactory dataFactory in dataFactories)                           // one input group
                {
                    groupId++;
                    Header header = null;
                    Data   data   = dataFactory.Create(_config);
                    RawIterator <CharReadable, IOException> sources = data.Stream();
                    while (sources.HasNext())
                    {
                        using (CharReadable source = sources.Next())
                        {
                            if (header == null)
                            {
                                // Extract the header from the first file in this group
                                header = extractHeader(source, headerFactory, _idType, _config, _groups);
                            }
                            using (CsvInputIterator iterator = new CsvInputIterator(source, data.Decorator(), header, _config, _idType, EMPTY, extractors(_config), groupId), InputEntity entity = new InputEntity())
                            {
                                int entities     = 0;
                                int properties   = 0;
                                int propertySize = 0;
                                int additional   = 0;
                                while (iterator.Position() < _estimateSampleSize && iterator.Next(chunk))
                                {
                                    for ( ; chunk.Next(entity); entities++)
                                    {
                                        properties   += entity.PropertyCount();
                                        propertySize += calculatePropertySize(entity, valueSizeCalculator);
                                        additional   += additionalCalculator(entity);
                                    }
                                }
                                if (entities > 0)
                                {
                                    long entityCountInSource = ( long )((( double )source.Length() / iterator.Position()) * entities);
                                    estimates[0] += entityCountInSource;
                                    estimates[1] += ( long )((( double )properties / entities) * entityCountInSource);
                                    estimates[2] += ( long )((( double )propertySize / entities) * entityCountInSource);
                                    estimates[3] += ( long )((( double )additional / entities) * entityCountInSource);
                                }
                            }
                        }
                    }
                }
            }
            return(estimates);
        }
예제 #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private Callables loadProcedures(java.net.URL jar, ClassLoader loader, Callables target) throws java.io.IOException, org.neo4j.internal.kernel.api.exceptions.KernelException
        private Callables LoadProcedures(URL jar, ClassLoader loader, Callables target)
        {
            RawIterator <Type, IOException> classes = ListClassesIn(jar, loader);

            while (classes.HasNext())
            {
                Type next = classes.Next();
                target.AddAllProcedures(_compiler.compileProcedure(next, null, false));
                target.AddAllFunctions(_compiler.compileFunction(next));
                target.AddAllAggregationFunctions(_compiler.compileAggregationFunction(next));
            }
            return(target);
        }
예제 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void listAllIndexesWithFailedIndex() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ListAllIndexesWithFailedIndex()
        {
            // Given
            Transaction transaction    = NewTransaction(AUTH_DISABLED);
            int         failedLabel    = transaction.TokenWrite().labelGetOrCreateForName("Fail");
            int         propertyKeyId1 = transaction.TokenWrite().propertyKeyGetOrCreateForName("foo");

            _failNextIndexPopulation.set(true);
            LabelSchemaDescriptor descriptor = forLabel(failedLabel, propertyKeyId1);

            transaction.SchemaWrite().indexCreate(descriptor);
            Commit();

            //let indexes come online
            try
            {
                using (Org.Neo4j.Graphdb.Transaction ignored = Db.beginTx())
                {
                    Db.schema().awaitIndexesOnline(2, MINUTES);
                    fail("Expected to fail when awaiting for index to come online");
                }
            }
            catch (System.InvalidOperationException)
            {
                // expected
            }

            // When
            RawIterator <object[], ProcedureException> stream = Procs().procedureCallRead(Procs().procedureGet(procedureName("db", "indexes")).id(), new object[0], ProcedureCallContext.EMPTY);

            assertTrue(stream.HasNext());
            object[] result = stream.Next();
            assertFalse(stream.HasNext());

            // Then
            assertEquals("INDEX ON :Fail(foo)", result[0]);
            assertEquals("Unnamed index", result[1]);
            assertEquals(Collections.singletonList("Fail"), result[2]);
            assertEquals(Collections.singletonList("foo"), result[3]);
            assertEquals("FAILED", result[4]);
            assertEquals("node_label_property", result[5]);
            assertEquals(0.0, result[6]);
            IDictionary <string, string> providerDescriptionMap = MapUtil.stringMap("key", GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10.providerKey(), "version", GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10.providerVersion());

            assertEquals(providerDescriptionMap, result[7]);
            assertEquals(IndexingService.getIndexId(descriptor), result[8]);
            assertThat(( string )result[9], containsString("java.lang.RuntimeException: Fail on update during population"));

            Commit();
        }
예제 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIgnoreWhiteListingIfFullAccess() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIgnoreWhiteListingIfFullAccess()
        {
            // Given
            ProcedureConfig             config            = new ProcedureConfig(Config.defaults(procedure_whitelist, "empty"));
            Log                         log               = mock(typeof(Log));
            ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, _components, log, config);

            // When
            CallableProcedure proc = procedureCompiler.CompileProcedure(typeof(SingleReadOnlyProcedure), null, true)[0];
            // Then
            RawIterator <object[], ProcedureException> result = proc.Apply(new BasicContext(), new object[0], _resourceTracker);

            assertEquals(result.Next()[0], "Bonnie");
        }
예제 #11
0
파일: CsvInput.cs 프로젝트: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void warnAboutDuplicateSourceFiles(java.util.Set<String> seenSourceFiles, Iterable<DataFactory> dataFactories) throws java.io.IOException
        private void WarnAboutDuplicateSourceFiles(ISet <string> seenSourceFiles, IEnumerable <DataFactory> dataFactories)
        {
            foreach (DataFactory dataFactory in dataFactories)
            {
                RawIterator <CharReadable, IOException> stream = dataFactory.Create(_config).stream();
                while (stream.HasNext())
                {
                    using (CharReadable source = stream.Next())
                    {
                        WarnAboutDuplicateSourceFiles(seenSourceFiles, source);
                    }
                }
            }
        }
예제 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLoadWhiteListedProcedure() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLoadWhiteListedProcedure()
        {
            // Given
            ProcedureConfig config = new ProcedureConfig(Config.defaults(procedure_whitelist, "org.neo4j.kernel.impl.proc.listCoolPeople"));

            Log log = mock(typeof(Log));
            ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), _components, _components, log, config);

            // When
            CallableProcedure proc = procedureCompiler.CompileProcedure(typeof(SingleReadOnlyProcedure), null, false)[0];
            // When
            RawIterator <object[], ProcedureException> result = proc.Apply(new BasicContext(), new object[0], _resourceTracker);

            // Then
            assertEquals(result.Next()[0], "Bonnie");
        }
예제 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private java.util.List<MemberInfo> clusterOverview(org.neo4j.kernel.impl.factory.GraphDatabaseFacade db) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException, org.neo4j.internal.kernel.api.exceptions.ProcedureException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        private IList <MemberInfo> ClusterOverview(GraphDatabaseFacade db)
        {
            Kernel kernel = Db.DependencyResolver.resolveDependency(typeof(Kernel));

            IList <MemberInfo> infos = new List <MemberInfo>();

            using (Transaction tx = kernel.BeginTransaction(Transaction_Type.@implicit, AnonymousContext.read()))
            {
                RawIterator <object[], ProcedureException> itr = tx.Procedures().procedureCallRead(procedureName("dbms", "cluster", ClusterOverviewProcedure.PROCEDURE_NAME), null, ProcedureCallContext.EMPTY);

                while (itr.HasNext())
                {
                    object[]       row       = itr.Next();
                    IList <string> addresses = (IList <string>)row[1];
                    infos.Add(new MemberInfo(addresses.ToArray(), Enum.Parse(typeof(RoleInfo), (string)row[2])));
                }

                return(infos);
            }
        }
예제 #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseResourcesAndGiveHelpfulErrorOnMidStreamException() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCloseResourcesAndGiveHelpfulErrorOnMidStreamException()
        {
            // Given
            CallableProcedure proc = Compile(typeof(ProcedureThatThrowsNullMsgExceptionMidStream))[0];

            // Expect
            Exception.expect(typeof(ProcedureException));
            Exception.expectMessage("Failed to invoke procedure `org.neo4j.kernel.impl.proc.throwsInStream`: " + "Caused by: java.lang.IndexOutOfBoundsException");

            // Expect that we get a suppressed exception from Stream.onClose (which also verifies that we actually call
            // onClose on the first exception)
            Exception.expect(new BaseMatcherAnonymousInnerClass(this));

            // When
            RawIterator <object[], ProcedureException> stream = proc.Apply(new BasicContext(), new object[0], _resourceTracker);

            if (stream.HasNext())
            {
                stream.Next();
            }
        }