//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogContentOfTheMessageOnError() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLogContentOfTheMessageOnError() { BoltRequestMessageReader requestMessageReader = mock(typeof(BoltRequestMessageReader)); Exception error = new Exception("Hello!"); doThrow(error).when(requestMessageReader).read(any()); LogService logService = mock(typeof(LogService)); Log log = mock(typeof(Log)); when(logService.GetInternalLog(typeof(MessageDecoder))).thenReturn(log); _channel = new EmbeddedChannel(new MessageDecoder(PackerUnderTest.newUnpacker, requestMessageReader, logService)); sbyte[] messageBytes = PackMessageWithSignature(RunMessage.SIGNATURE); try { _channel.writeInbound(Unpooled.wrappedBuffer(messageBytes)); fail("Exception expected"); } catch (Exception e) { assertEquals(error, e); } AssertMessageHexDumpLogged(log, messageBytes); }
internal static ICollection <StorageCommand> ExtractCommands(sbyte[] commandBytes) { ByteBuf txBuffer = Unpooled.wrappedBuffer(commandBytes); NetworkReadableClosableChannelNetty4 channel = new NetworkReadableClosableChannelNetty4(txBuffer); LogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(new RecordStorageCommandReaderFactory(), InvalidLogEntryHandler.STRICT); LogEntryCommand entryRead; IList <StorageCommand> commands = new LinkedList <StorageCommand>(); try { while ((entryRead = ( LogEntryCommand )reader.ReadLogEntry(channel)) != null) { commands.Add(entryRead.Command); } } catch (IOException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); // TODO: Handle or throw. } return(commands); }
//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()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogContentOfTheMessageOnIOError() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLogContentOfTheMessageOnIOError() { BoltConnection connection = mock(typeof(BoltConnection)); BoltResponseMessageWriter responseMessageHandler = mock(typeof(BoltResponseMessageWriter)); BoltRequestMessageReader requestMessageReader = new BoltRequestMessageReaderV1(connection, responseMessageHandler, NullLogService.Instance); LogService logService = mock(typeof(LogService)); Log log = mock(typeof(Log)); when(logService.GetInternalLog(typeof(MessageDecoder))).thenReturn(log); _channel = new EmbeddedChannel(new MessageDecoder(PackerUnderTest.newUnpacker, requestMessageReader, logService)); sbyte invalidMessageSignature = sbyte.MaxValue; sbyte[] messageBytes = PackMessageWithSignature(invalidMessageSignature); try { _channel.writeInbound(Unpooled.wrappedBuffer(messageBytes)); fail("Exception expected"); } catch (Exception) { } AssertMessageHexDumpLogged(log, messageBytes); }
public override TransactionRepresentation Extract(ByteArrayReplicatedTransaction replicatedTransaction) { ByteBuf buffer = Unpooled.wrappedBuffer(replicatedTransaction.TxBytes); NetworkReadableClosableChannelNetty4 channel = new NetworkReadableClosableChannelNetty4(buffer); return(Read(channel)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void unpack(byte[] input) throws java.io.IOException private void Unpack(sbyte[] input) { BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine); _channel = new EmbeddedChannel(NewDecoder(connection)); _channel.writeInbound(Unpooled.wrappedBuffer(input)); _channel.finishAndReleaseAll(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDispatchPullAll() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDispatchPullAll() { BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine); _channel = new EmbeddedChannel(NewDecoder(connection)); _channel.writeInbound(Unpooled.wrappedBuffer(serialize(PackerUnderTest, PullAllMessage.INSTANCE))); _channel.finishAndReleaseAll(); verify(stateMachine).process(eq(PullAllMessage.INSTANCE), any()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void testUnpackableStructParametersWithKnownType(org.neo4j.bolt.messaging.Neo4jPack packerForSerialization, org.neo4j.values.AnyValue parameterValue, String expectedMessage) throws Exception private void TestUnpackableStructParametersWithKnownType(Neo4jPack packerForSerialization, AnyValue parameterValue, string expectedMessage) { string statement = "RETURN $x"; MapValue parameters = VirtualValues.map(new string[] { "x" }, new AnyValue[] { parameterValue }); BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine); _channel = new EmbeddedChannel(NewDecoder(connection)); _channel.writeInbound(Unpooled.wrappedBuffer(serialize(packerForSerialization, new RunMessage(statement, parameters)))); _channel.finishAndReleaseAll(); verify(stateMachine).handleExternalFailure(eq(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.TypeError, expectedMessage)), any()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCallExternalErrorOnInitWithNullKeys() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCallExternalErrorOnInitWithNullKeys() { BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine); _channel = new EmbeddedChannel(NewDecoder(connection)); string userAgent = "Test/User Agent 1.0"; IDictionary <string, object> authToken = MapUtil.map("scheme", "basic", null, "user", "credentials", "password"); _channel.writeInbound(Unpooled.wrappedBuffer(serialize(PackerUnderTest, new InitMessage(userAgent, authToken)))); _channel.finishAndReleaseAll(); verify(stateMachine).handleExternalFailure(eq(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Value `null` is not supported as key in maps, must be a non-nullable string.")), any()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDispatchRun() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDispatchRun() { BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine); _channel = new EmbeddedChannel(NewDecoder(connection)); string statement = "RETURN 1"; MapValue parameters = ValueUtils.asMapValue(MapUtil.map("param1", 1, "param2", "2", "param3", true, "param4", 5.0)); _channel.writeInbound(Unpooled.wrappedBuffer(serialize(PackerUnderTest, new RunMessage(statement, parameters)))); _channel.finishAndReleaseAll(); verify(stateMachine).process(eq(new RunMessage(statement, parameters)), any()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDispatchInit() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDispatchInit() { BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine); _channel = new EmbeddedChannel(NewDecoder(connection)); string userAgent = "Test/User Agent 1.0"; IDictionary <string, object> authToken = MapUtil.map("scheme", "basic", "principal", "user", "credentials", "password"); _channel.writeInbound(Unpooled.wrappedBuffer(serialize(PackerUnderTest, new InitMessage(userAgent, authToken)))); _channel.finishAndReleaseAll(); verify(stateMachine).process(refEq(new InitMessage(userAgent, authToken), "authToken"), any()); }