//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotNotifyOutputWhenOutputItselfFails() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotNotifyOutputWhenOutputItselfFails()
        {
            PackOutput output = mock(typeof(PackOutput));

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = mock(typeof(Org.Neo4j.Bolt.messaging.Neo4jPack_Packer));
            IOException error = new IOException("Unable to flush");

            doThrow(error).when(output).messageSucceeded();

            BoltResponseMessageWriterV1 writer = NewWriter(output, packer);

            try
            {
                writer.Write(new RecordMessage(() => new AnyValue[] { longValue(1), longValue(2) }));
                fail("Exception expected");
            }
            catch (IOException e)
            {
                assertEquals(error, e);
            }

            InOrder inOrder = inOrder(output, packer);

            inOrder.verify(output).beginMessage();
            inOrder.verify(packer).pack(longValue(1));
            inOrder.verify(packer).pack(longValue(2));
            inOrder.verify(output).messageSucceeded();

            verify(output, never()).messageFailed();
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private <T extends org.neo4j.bolt.messaging.ResponseMessage> T serializeAndDeserialize(T msg) throws java.io.IOException
        private T SerializeAndDeserialize <T>(T msg) where T : Org.Neo4j.Bolt.messaging.ResponseMessage
        {
            RecordingByteChannel        channel = new RecordingByteChannel();
            BoltResponseMessageReader   reader  = new BoltResponseMessageReader(_neo4jPack.newUnpacker((new BufferedChannelInput(16)).reset(channel)));
            BufferedChannelOutput       output  = new BufferedChannelOutput(channel);
            BoltResponseMessageWriterV1 writer  = new BoltResponseMessageWriterV1(_neo4jPack.newPacker, output, NullLogService.Instance);

            writer.Write(msg);
            writer.Flush();

            channel.Eof();
            return(Unpack(reader, channel));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteIgnoredMessage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteIgnoredMessage()
        {
            PackOutput output = mock(typeof(PackOutput));

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = mock(typeof(Org.Neo4j.Bolt.messaging.Neo4jPack_Packer));

            BoltResponseMessageWriterV1 writer = NewWriter(output, packer);

            writer.Write(IgnoredMessage.IGNORED_MESSAGE);

            InOrder inOrder = inOrder(output, packer);

            inOrder.verify(output).beginMessage();
            inOrder.verify(packer).packStructHeader(0, IGNORED.signature());
            inOrder.verify(output).messageSucceeded();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteRecordMessage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteRecordMessage()
        {
            PackOutput output = mock(typeof(PackOutput));

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = mock(typeof(Org.Neo4j.Bolt.messaging.Neo4jPack_Packer));

            BoltResponseMessageWriterV1 writer = NewWriter(output, packer);

            writer.Write(new RecordMessage(() => new AnyValue[] { longValue(42), stringValue("42") }));

            InOrder inOrder = inOrder(output, packer);

            inOrder.verify(output).beginMessage();
            inOrder.verify(packer).pack(longValue(42));
            inOrder.verify(packer).pack(stringValue("42"));
            inOrder.verify(output).messageSucceeded();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteSuccessMessage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteSuccessMessage()
        {
            PackOutput output = mock(typeof(PackOutput));

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = mock(typeof(Org.Neo4j.Bolt.messaging.Neo4jPack_Packer));

            BoltResponseMessageWriterV1 writer = NewWriter(output, packer);

            MapValue metadata = map(new string[] { "a", "b", "c" }, new AnyValue[] { intValue(1), stringValue("2"), date(2010, 0x2, 0x2) });

            writer.Write(new SuccessMessage(metadata));

            InOrder inOrder = inOrder(output, packer);

            inOrder.verify(output).beginMessage();
            inOrder.verify(packer).pack(metadata);
            inOrder.verify(output).messageSucceeded();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteFailureMessage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteFailureMessage()
        {
            PackOutput output = mock(typeof(PackOutput));

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = mock(typeof(Org.Neo4j.Bolt.messaging.Neo4jPack_Packer));

            BoltResponseMessageWriterV1 writer = NewWriter(output, packer);

            Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction errorStatus = Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.DeadlockDetected;
            string errorMessage = "Hi Deadlock!";

            writer.Write(new FailureMessage(errorStatus, errorMessage));

            InOrder inOrder = inOrder(output, packer);

            inOrder.verify(output).beginMessage();
            inOrder.verify(packer).pack(errorStatus.code().serialize());
            inOrder.verify(packer).pack(errorMessage);
            inOrder.verify(output).messageSucceeded();
        }