use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class TransactionHandleRegistryTest method shouldProvideInterruptHandlerForSuspendedTransaction.
@Test
public void shouldProvideInterruptHandlerForSuspendedTransaction() throws TransactionLifecycleException {
// Given
AssertableLogProvider logProvider = new AssertableLogProvider();
FakeClock clock = Clocks.fakeClock();
int timeoutLength = 123;
TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, timeoutLength, logProvider);
TransactionHandle handle = mock(TransactionHandle.class);
// Suspended Tx in Registry
long id = registry.begin(handle);
registry.release(id, handle);
// When
registry.terminate(id);
// Then
verify(handle, times(1)).terminate();
verifyNoMoreInteractions(handle);
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class TransactionHandleRegistryTest method transactionsShouldBeEvictedWhenUnusedLongerThanTimeout.
@Test
public void transactionsShouldBeEvictedWhenUnusedLongerThanTimeout() throws Exception {
// Given
FakeClock clock = Clocks.fakeClock();
AssertableLogProvider logProvider = new AssertableLogProvider();
TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, 0, logProvider);
TransactionHandle oldTx = mock(TransactionHandle.class);
TransactionHandle newTx = mock(TransactionHandle.class);
TransactionHandle handle = mock(TransactionHandle.class);
long txId1 = registry.begin(handle);
long txId2 = registry.begin(handle);
// And given one transaction was stored one minute ago, and another was stored just now
registry.release(txId1, oldTx);
clock.forward(1, TimeUnit.MINUTES);
registry.release(txId2, newTx);
// When
registry.rollbackSuspendedTransactionsIdleSince(clock.millis() - 1000);
// Then
assertThat(registry.acquire(txId2), equalTo(newTx));
// And then the other should have been evicted
try {
registry.acquire(txId1);
fail("Should have thrown exception");
} catch (InvalidTransactionId e) {
// ok
}
logProvider.assertExactly(inLog(TransactionHandleRegistry.class).info("Transaction with id 1 has been automatically rolled " + "back due to transaction timeout."));
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class TransactionHandleRegistryTest method shouldProvideInterruptHandlerForActiveTransaction.
@Test
public void shouldProvideInterruptHandlerForActiveTransaction() throws TransactionLifecycleException {
// Given
AssertableLogProvider logProvider = new AssertableLogProvider();
FakeClock clock = Clocks.fakeClock();
int timeoutLength = 123;
TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, timeoutLength, logProvider);
TransactionHandle handle = mock(TransactionHandle.class);
// Active Tx in Registry
long id = registry.begin(handle);
// When
registry.terminate(id);
// Then
verify(handle, times(1)).terminate();
verifyNoMoreInteractions(handle);
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class LoggingListenerTest method shouldBeAbleToOutputAMethodArgument.
@Test
public void shouldBeAbleToOutputAMethodArgument() {
// Given
Monitors monitors = new Monitors();
AssertableLogProvider logProvider = new AssertableLogProvider();
InterestingMonitor1 aMonitor = monitors.newMonitor(InterestingMonitor1.class);
LoggingListener listener = new LoggingListener(Collections.<Class<?>, Logger>singletonMap(InterestingMonitor1.class, logProvider.getLog(InterestingMonitor1.class).errorLogger()));
monitors.addMonitorListener(listener, listener.predicate);
// When
aMonitor.touch("APA");
// Then
logProvider.assertExactly(inLog(InterestingMonitor1.class).error("touch(String:APA)"));
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class LoggingListenerTest method shouldLogWhenThingsAreMonitored.
@Test
public void shouldLogWhenThingsAreMonitored() {
// Given
Monitors monitors = new Monitors();
AssertableLogProvider logProvider = new AssertableLogProvider();
InterestingMonitor1 aMonitor = monitors.newMonitor(InterestingMonitor1.class);
LoggingListener listener = new LoggingListener(Collections.<Class<?>, Logger>singletonMap(InterestingMonitor1.class, logProvider.getLog(InterestingMonitor1.class).infoLogger()));
monitors.addMonitorListener(listener, listener.predicate);
// When
aMonitor.touch();
// Then
logProvider.assertExactly(inLog(InterestingMonitor1.class).info("touch()"));
}
Aggregations