use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class ExecutionResultSerializerTest method shouldAbbreviateWellKnownIOErrors.
@Test
public void shouldAbbreviateWellKnownIOErrors() throws Exception {
// given
OutputStream output = mock(OutputStream.class, new ThrowsException(new IOException("Broken pipe")));
AssertableLogProvider logProvider = new AssertableLogProvider();
ExecutionResultSerializer serializer = getSerializerWith(output, null, logProvider);
// when
serializer.finish();
// then
logProvider.assertExactly(AssertableLogProvider.inLog(ExecutionResultSerializer.class).error("Unable to reply to request, because the client has closed the connection (Broken pipe)."));
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class ExecutionResultSerializerTest method shouldLogIOErrors.
@Test
public void shouldLogIOErrors() throws Exception {
// given
IOException failure = new IOException();
OutputStream output = mock(OutputStream.class, new ThrowsException(failure));
AssertableLogProvider logProvider = new AssertableLogProvider();
ExecutionResultSerializer serializer = getSerializerWith(output, null, logProvider);
// when
serializer.finish();
// then
logProvider.assertExactly(AssertableLogProvider.inLog(ExecutionResultSerializer.class).error(is("Failed to generate JSON output."), sameInstance(failure)));
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class TransactionHandleRegistryTest method acquiringATransactionThatHasAlreadyBeenAcquiredShouldThrowInvalidConcurrentTransactionAccess.
@Test
public void acquiringATransactionThatHasAlreadyBeenAcquiredShouldThrowInvalidConcurrentTransactionAccess() throws Exception {
// Given
AssertableLogProvider logProvider = new AssertableLogProvider();
TransactionHandleRegistry registry = new TransactionHandleRegistry(Clocks.fakeClock(), 0, logProvider);
TransactionHandle handle = mock(TransactionHandle.class);
long id = registry.begin(handle);
registry.release(id, handle);
registry.acquire(id);
// When
try {
registry.acquire(id);
fail("Should have thrown exception");
} catch (InvalidConcurrentTransactionAccess e) {
// expected
}
// then
logProvider.assertNoLoggingOccurred();
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class TransactionHandleRegistryTest method acquiringANonExistentTransactionShouldThrowErrorInvalidTransactionId.
@Test
public void acquiringANonExistentTransactionShouldThrowErrorInvalidTransactionId() throws Exception {
// Given
AssertableLogProvider logProvider = new AssertableLogProvider();
TransactionHandleRegistry registry = new TransactionHandleRegistry(Clocks.fakeClock(), 0, logProvider);
long madeUpTransactionId = 1337;
// When
try {
registry.acquire(madeUpTransactionId);
fail("Should have thrown exception");
} catch (InvalidTransactionId e) {
// expected
}
// then
logProvider.assertNoLoggingOccurred();
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class TransactionHandleRegistryTest method gettingInterruptHandlerForUnknownIdShouldThrowErrorInvalidTransactionId.
@Test(expected = InvalidTransactionId.class)
public void gettingInterruptHandlerForUnknownIdShouldThrowErrorInvalidTransactionId() throws TransactionLifecycleException {
// Given
AssertableLogProvider logProvider = new AssertableLogProvider();
FakeClock clock = Clocks.fakeClock();
int timeoutLength = 123;
TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, timeoutLength, logProvider);
// When
registry.terminate(456);
}
Aggregations