Search in sources :

Example 6 with BoltIOException

use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.

the class AbstractTransactionInitiatingMessage method shouldThrowExceptionIfFailedToParseAccessModeCorrectly.

@Test
void shouldThrowExceptionIfFailedToParseAccessModeCorrectly() throws Throwable {
    // Given
    Map<String, Object> msgMetadata = map("mode", 666);
    MapValue meta = ValueUtils.asMapValue(msgMetadata);
    // When & Then
    BoltIOException exception = assertThrows(BoltIOException.class, () -> createMessage(meta));
    assertThat(exception.getMessage()).startsWith("Expecting access mode value to be a String value");
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) MapValue(org.neo4j.values.virtual.MapValue) Test(org.junit.jupiter.api.Test)

Example 7 with BoltIOException

use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.

the class DiscardMessageTest method shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly.

@Test
void shouldThrowExceptionIfFailedToParseTransactionMetadataCorrectly() throws Throwable {
    // Given
    Map<String, Object> msgMetadata = map("n", "invalid value type");
    MapValue meta = ValueUtils.asMapValue(msgMetadata);
    // When & Then
    BoltIOException exception = assertThrows(BoltIOException.class, () -> new DiscardMessage(meta));
    assertThat(exception.getMessage()).startsWith("Expecting DISCARD size n to be a Long value, but got: String(\"invalid value type\")");
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) ValueUtils.asMapValue(org.neo4j.kernel.impl.util.ValueUtils.asMapValue) MapValue(org.neo4j.values.virtual.MapValue) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with BoltIOException

use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.

the class DiscardMessageTest method shouldThrowExceptionIfMissingMeta.

@Test
void shouldThrowExceptionIfMissingMeta() throws Throwable {
    // When & Then
    BoltIOException exception = assertThrows(BoltIOException.class, () -> new DiscardMessage(MapValue.EMPTY));
    assertThat(exception.getMessage()).startsWith("Expecting DISCARD size n to be a Long value, but got: NO_VALUE");
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with BoltIOException

use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.

the class TransactionStateMachineSPIProviderV4Test method shouldErrorIfDatabaseNotFound.

@Test
void shouldErrorIfDatabaseNotFound() {
    DatabaseManagementService managementService = mock(DatabaseManagementService.class);
    var databaseName = "database";
    when(managementService.database(databaseName)).thenThrow(new DatabaseNotFoundException(databaseName));
    TransactionStateMachineSPIProvider spiProvider = newSpiProvider(managementService);
    BoltIOException error = assertThrows(BoltIOException.class, () -> spiProvider.getTransactionStateMachineSPI(databaseName, mock(StatementProcessorReleaseManager.class)));
    assertThat(error.status()).isEqualTo(Status.Database.DatabaseNotFound);
    assertThat(error.getMessage()).contains("Database does not exist. Database name: 'database'.");
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) DatabaseNotFoundException(org.neo4j.dbms.api.DatabaseNotFoundException) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider) Test(org.junit.jupiter.api.Test)

Example 10 with BoltIOException

use of org.neo4j.bolt.messaging.BoltIOException in project neo4j by neo4j.

the class MessageMetadataParserTest method shouldThrowForIncorrectDatabaseName.

@Test
void shouldThrowForIncorrectDatabaseName() {
    BoltIOException e = assertThrows(BoltIOException.class, () -> parseDatabaseName(asMapValue(map("db", 10L))));
    assertTrue(e.causesFailureMessage());
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) Test(org.junit.jupiter.api.Test)

Aggregations

BoltIOException (org.neo4j.bolt.messaging.BoltIOException)16 Test (org.junit.jupiter.api.Test)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 MapValue (org.neo4j.values.virtual.MapValue)5 HashMap (java.util.HashMap)2 ValueSource (org.junit.jupiter.params.provider.ValueSource)2 Neo4jPack (org.neo4j.bolt.packstream.Neo4jPack)2 PackedInputArray (org.neo4j.bolt.packstream.PackedInputArray)2 AuthTokenDecoderTest (org.neo4j.bolt.security.auth.AuthTokenDecoderTest)2 BoltProtocolV3ComponentFactory.newNeo4jPack (org.neo4j.bolt.v3.BoltProtocolV3ComponentFactory.newNeo4jPack)2 ValueUtils.asMapValue (org.neo4j.kernel.impl.util.ValueUtils.asMapValue)2 ByteBuf (io.netty.buffer.ByteBuf)1 TransactionStateMachineSPIProvider (org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider)1 TransportThrottleException (org.neo4j.bolt.transport.TransportThrottleException)1 HelloMessage (org.neo4j.bolt.v3.messaging.request.HelloMessage)1 HelloMessage (org.neo4j.bolt.v41.messaging.request.HelloMessage)1 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)1 DatabaseNotFoundException (org.neo4j.dbms.api.DatabaseNotFoundException)1