示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowOnUnpackingMapWithDuplicateKeys() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowOnUnpackingMapWithDuplicateKeys()
        {
            // Given
            PackedOutputArray output = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output);
            packer.PackMapHeader(2);
            packer.Pack("key");
            packer.pack(intValue(1));
            packer.Pack("key");
            packer.pack(intValue(2));

            // When
            try
            {
                PackedInputArray input = new PackedInputArray(output.Bytes());
                Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = _neo4jPack.newUnpacker(input);
                unpacker.Unpack();

                fail("exception expected");
            }
            catch (BoltIOException ex)
            {
                assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Duplicate map key `key`."), Neo4jError.from(ex));
            }
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void packMapWithDuplicateKey(org.neo4j.bolt.messaging.Neo4jPack_Packer packer) throws java.io.IOException
        private static void PackMapWithDuplicateKey(Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer)
        {
            packer.PackMapHeader(2);
            packer.Pack("key1");
            packer.Pack("value1");
            packer.Pack("key1");
            packer.Pack("value2");
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void packMapWithNullKey(org.neo4j.bolt.messaging.Neo4jPack_Packer packer) throws java.io.IOException
        private static void PackMapWithNullKey(Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer)
        {
            packer.PackMapHeader(2);
            packer.Pack("key1");
            packer.Pack(ValueUtils.of(null));
            packer.Pack(ValueUtils.of(null));
            packer.Pack("value1");
        }
示例#4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private byte[] createMsgWithUnknownValue(byte signature) throws java.io.IOException
        private sbyte[] CreateMsgWithUnknownValue(sbyte signature)
        {
            PackedOutputArray @out = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = Neo4jPack.newPacker(@out);

            packer.PackStructHeader(2, signature);
            packer.Pack("Text");
            packer.PackMapHeader(1);
            packer.Pack("key1");
            packer.PackStructHeader(0, ( sbyte )'A');

            return(@out.Bytes());
        }
示例#5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private byte[] createRunWithV1Value(org.neo4j.values.AnyValue value) throws java.io.IOException
        private sbyte[] CreateRunWithV1Value(AnyValue value)
        {
            PackedOutputArray @out = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = Neo4jPack.newPacker(@out);

            packer.PackStructHeader(2, RunMessage.SIGNATURE);
            packer.Pack("RETURN $x");
            packer.PackMapHeader(1);
            packer.Pack("x");
            packer.Pack(value);

            return(@out.Bytes());
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private byte[] createRunWith(org.neo4j.function.ThrowingConsumer<org.neo4j.bolt.messaging.Neo4jPack_Packer, java.io.IOException> valuePacker) throws java.io.IOException
        private sbyte[] CreateRunWith(ThrowingConsumer <Org.Neo4j.Bolt.messaging.Neo4jPack_Packer, IOException> valuePacker)
        {
            PackedOutputArray @out = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = (new Neo4jPackV2()).newPacker(@out);

            packer.PackStructHeader(2, RunMessage.SIGNATURE);
            packer.Pack("RETURN $x");
            packer.PackMapHeader(1);
            packer.Pack("x");
            valuePacker.Accept(packer);

            return(@out.Bytes());
        }
示例#7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private byte[] packed(org.neo4j.values.AnyValue object) throws java.io.IOException
        private sbyte[] Packed(AnyValue @object)
        {
            PackedOutputArray output = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output);
            packer.Pack(@object);
            return(output.Bytes());
        }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCallExternalErrorOnInitWithDuplicateKeys() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCallExternalErrorOnInitWithDuplicateKeys()
        {
            BoltStateMachine          stateMachine = mock(typeof(BoltStateMachine));
            SynchronousBoltConnection connection   = new SynchronousBoltConnection(stateMachine);

            _channel = new EmbeddedChannel(NewDecoder(connection));

            // Generate INIT message with duplicate keys
            PackedOutputArray @out = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = PackerUnderTest.newPacker(@out);
            packer.PackStructHeader(2, InitMessage.SIGNATURE);
            packer.Pack("Test/User Agent 1.0");
            packer.PackMapHeader(3);
            packer.Pack("scheme");
            packer.Pack("basic");
            packer.Pack("principal");
            packer.Pack("user");
            packer.Pack("scheme");
            packer.Pack("password");

            _channel.writeInbound(Unpooled.wrappedBuffer(@out.Bytes()));
            _channel.finishAndReleaseAll();

            verify(stateMachine).handleExternalFailure(eq(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Duplicate map key `scheme`.")), any());
        }
示例#9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private byte[] packMessageWithSignature(byte signature) throws java.io.IOException
        private sbyte[] PackMessageWithSignature(sbyte signature)
        {
            PackedOutputArray @out = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = PackerUnderTest.newPacker(@out);
            packer.PackStructHeader(2, signature);
            packer.Pack("RETURN 'Hello World!'");
            packer.pack(EMPTY_MAP);
            return(@out.Bytes());
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowOnUnknownStructType() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowOnUnknownStructType()
        {
            PackedOutputArray @out = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = PackerUnderTest.newPacker(@out);
            packer.PackStructHeader(2, RunMessage.SIGNATURE);
            packer.Pack("RETURN $x");
            packer.PackMapHeader(1);
            packer.Pack("x");
            packer.PackStructHeader(0, ( sbyte )'A');

            try
            {
                Unpack(@out.Bytes());
            }
            catch (BoltIOException ex)
            {
                assertThat(ex.Message, equalTo("Struct types of 0x41 are not recognized."));
            }
        }
示例#11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private byte[] createMsgWithDuplicateKey(byte signature) throws java.io.IOException
        private sbyte[] CreateMsgWithDuplicateKey(sbyte signature)
        {
            PackedOutputArray @out = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = Neo4jPack.newPacker(@out);

            packer.PackStructHeader(2, signature);
            packer.Pack("Text");
            PackMapWithDuplicateKey(packer);

            return(@out.Bytes());
        }
示例#12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private byte[] runMessage(java.util.Map<String,Object> metadata) throws java.io.IOException
        private sbyte[] RunMessage(IDictionary <string, object> metadata)
        {
            PackedOutputArray @out = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = Util.Neo4jPack.newPacker(@out);

            packer.PackStructHeader(3, RunMessage.SIGNATURE);
            packer.Pack("RETURN 1");
            packer.pack(EMPTY_MAP);
            packer.pack(asMapValue(metadata));

            return(@out.Bytes());
        }
示例#13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowOnUnpackingMapWithUnsupportedKeyType() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowOnUnpackingMapWithUnsupportedKeyType()
        {
            // Given
            PackedOutputArray output = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output);
            packer.PackMapHeader(2);
            packer.Pack(ValueUtils.of(1L));
            packer.pack(intValue(1));

            // When
            try
            {
                PackedInputArray input = new PackedInputArray(output.Bytes());
                Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = _neo4jPack.newUnpacker(input);
                unpacker.Unpack();

                fail("exception expected");
            }
            catch (BoltIOException ex)
            {
                assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, "Bad key type: INTEGER"), Neo4jError.from(ex));
            }
        }
示例#14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToPackAndUnpackList() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToPackAndUnpackList()
        {
            // Given
            PackedOutputArray output = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output);
            packer.PackListHeader(ALICE.labels().length());
            IList <string> expected = new List <string>();
            TextArray      labels   = ALICE.labels();

            for (int i = 0; i < labels.Length(); i++)
            {
                string labelName = labels.StringValue(i);
                packer.Pack(labelName);
                expected.Add(labelName);
            }
            AnyValue unpacked = unpacked(output.Bytes());

            // Then
            assertThat(unpacked, instanceOf(typeof(ListValue)));
            ListValue unpackedList = ( ListValue )unpacked;

            assertThat(unpackedList, equalTo(ValueUtils.asListValue(expected)));
        }