use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.
the class PullMessageTest method shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly.
@Test
void shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly() throws Throwable {
// Given
Map<String, Object> msgMetadata = map("n", "invalid value type");
MapValue meta = asMapValue(msgMetadata);
// When & Then
BoltIOException exception = assertThrows(BoltIOException.class, () -> new PullMessage(meta));
assertThat(exception.getMessage()).startsWith("Expecting PULL size n to be a Long value, but got: String(\"invalid value type\")");
}
use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.
the class PullMessageTest method shouldThrowExceptionIfMissingMeta.
@Test
void shouldThrowExceptionIfMissingMeta() throws Throwable {
// When & Then
BoltIOException exception = assertThrows(BoltIOException.class, () -> new PullMessage(MapValue.EMPTY));
assertThat(exception.getMessage()).startsWith("Expecting PULL size n to be a Long value, but got: NO_VALUE");
}
use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.
the class PullMessageTest method shouldThrowExceptionIfZero.
@ParameterizedTest
@ValueSource(longs = { -100L, 0L })
void shouldThrowExceptionIfZero(long value) throws Throwable {
// When & Then
BoltIOException exception = assertThrows(BoltIOException.class, () -> new PullMessage(asMapValue(singletonMap("n", value))));
assertThat(exception.getMessage()).startsWith("Expecting PULL size to be at least 1");
}
use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.
the class HelloMessageDecoderTest method testShouldErrorForMissingUserAgent.
@Test
protected void testShouldErrorForMissingUserAgent() throws Exception {
Neo4jPack neo4jPack = newNeo4jPack();
Map<String, Object> authToken = new HashMap<>();
HelloMessage originalMessage = new HelloMessage(authToken);
PackedInputArray input = new PackedInputArray(encode(neo4jPack, originalMessage));
Neo4jPack.Unpacker unpacker = neo4jPack.newUnpacker(input);
// these two steps are executed before decoding in order to select a correct decoder
unpacker.unpackStructHeader();
unpacker.unpackStructSignature();
BoltIOException exception = assertThrows(BoltIOException.class, () -> decoder.decode(unpacker));
assertEquals("Expected \"user_agent\" in metadata", exception.getMessage());
}
use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.
the class MessageMetadataParserTest method shouldThrowForIncorrectTransactionMetadata.
@Test
void shouldThrowForIncorrectTransactionMetadata() {
BoltIOException e = assertThrows(BoltIOException.class, () -> parseTransactionMetadata(asMapValue(map("tx_metadata", "{key1: 'value1', key2: 'value2'}"))));
assertTrue(e.causesFailureMessage());
}
Aggregations