Search in sources :

Example 6 with PackOutput

use of org.neo4j.bolt.packstream.PackOutput in project neo4j by neo4j.

the class BoltResponseMessageWriterV3Test method shouldWriteSuccessMessage.

@Test
void shouldWriteSuccessMessage() throws Exception {
    PackOutput output = mock(PackOutput.class);
    Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
    var writer = newWriter(output, packer);
    MapValue metadata = map(new String[] { "a", "b", "c" }, new AnyValue[] { intValue(1), stringValue("2"), date(2010, 02, 02) });
    writer.write(new SuccessMessage(metadata));
    InOrder inOrder = inOrder(output, packer);
    inOrder.verify(output).beginMessage();
    inOrder.verify(packer).pack(metadata);
    inOrder.verify(output).messageSucceeded();
}
Also used : InOrder(org.mockito.InOrder) SuccessMessage(org.neo4j.bolt.v3.messaging.response.SuccessMessage) MapValue(org.neo4j.values.virtual.MapValue) PackOutput(org.neo4j.bolt.packstream.PackOutput) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) Test(org.junit.jupiter.api.Test)

Example 7 with PackOutput

use of org.neo4j.bolt.packstream.PackOutput in project neo4j by neo4j.

the class BoltResponseMessageWriterV3Test method shouldFlush.

@Test
void shouldFlush() throws Exception {
    PackOutput output = mock(PackOutput.class);
    Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
    var writer = newWriter(output, packer);
    writer.flush();
    verify(output).flush();
}
Also used : PackOutput(org.neo4j.bolt.packstream.PackOutput) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) Test(org.junit.jupiter.api.Test)

Example 8 with PackOutput

use of org.neo4j.bolt.packstream.PackOutput in project neo4j by neo4j.

the class BoltResponseMessageWriterV3Test method shouldNotifyOutputAboutFailedRecordMessage.

@Test
void shouldNotifyOutputAboutFailedRecordMessage() throws Exception {
    PackOutput output = mock(PackOutput.class);
    Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
    IOException error = new IOException("Unable to pack 42");
    doThrow(error).when(packer).pack(longValue(42));
    var writer = newWriter(output, packer);
    var e = assertThrows(IOException.class, () -> writer.write(new RecordMessage(new AnyValue[] { stringValue("42"), longValue(42) })));
    assertEquals(error, e);
    InOrder inOrder = inOrder(output, packer);
    inOrder.verify(output).beginMessage();
    inOrder.verify(packer).pack(stringValue("42"));
    inOrder.verify(packer).pack(longValue(42));
    inOrder.verify(output).messageFailed();
}
Also used : InOrder(org.mockito.InOrder) IOException(java.io.IOException) PackOutput(org.neo4j.bolt.packstream.PackOutput) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) RecordMessage(org.neo4j.bolt.v3.messaging.response.RecordMessage) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)8 Neo4jPack (org.neo4j.bolt.packstream.Neo4jPack)8 PackOutput (org.neo4j.bolt.packstream.PackOutput)8 InOrder (org.mockito.InOrder)6 IOException (java.io.IOException)3 RecordMessage (org.neo4j.bolt.v3.messaging.response.RecordMessage)3 AnyValue (org.neo4j.values.AnyValue)2 FailureMessage (org.neo4j.bolt.v3.messaging.response.FailureMessage)1 SuccessMessage (org.neo4j.bolt.v3.messaging.response.SuccessMessage)1 Status (org.neo4j.kernel.api.exceptions.Status)1 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)1 SimpleLogService (org.neo4j.logging.internal.SimpleLogService)1 MapValue (org.neo4j.values.virtual.MapValue)1