use of io.aeron.archive.client.AeronArchive.Context in project Aeron by real-logic.
the class AeronArchiveTest method closeOwningAeronClient.
@Test
void closeOwningAeronClient() {
final long controlSessionId = 42;
final Aeron.Context aeronContext = mock(Aeron.Context.class);
when(aeronContext.nanoClock()).thenReturn(SystemNanoClock.INSTANCE);
when(aeron.context()).thenReturn(aeronContext);
final IllegalMonitorStateException aeronException = new IllegalMonitorStateException("aeron closed");
doThrow(aeronException).when(aeron).close();
final Publication publication = mock(Publication.class);
when(publication.isConnected()).thenReturn(true);
doThrow(new IllegalStateException("publication is closed")).when(publication).close();
final Subscription subscription = mock(Subscription.class);
when(controlResponsePoller.subscription()).thenReturn(subscription);
doThrow(new IndexOutOfBoundsException("subscription")).when(subscription).close();
when(archiveProxy.publication()).thenReturn(publication);
final IndexOutOfBoundsException closeSessionException = new IndexOutOfBoundsException();
when(archiveProxy.closeSession(controlSessionId)).thenThrow(closeSessionException);
final Context context = new Context().aeron(aeron).idleStrategy(NoOpIdleStrategy.INSTANCE).messageTimeoutNs(100).lock(NoOpLock.INSTANCE).errorHandler(errorHandler).ownsAeronClient(true);
final AeronArchive aeronArchive = new AeronArchive(context, controlResponsePoller, archiveProxy, controlSessionId);
final IllegalMonitorStateException ex = assertThrows(IllegalMonitorStateException.class, aeronArchive::close);
assertSame(aeronException, ex);
final InOrder inOrder = inOrder(errorHandler);
inOrder.verify(errorHandler).onError(closeSessionException);
inOrder.verifyNoMoreInteractions();
}
use of io.aeron.archive.client.AeronArchive.Context in project Aeron by real-logic.
the class AeronArchiveTest method closeNotOwningAeronClient.
@Test
void closeNotOwningAeronClient() {
final long controlSessionId = 42;
final Aeron.Context aeronContext = mock(Aeron.Context.class);
when(aeronContext.nanoClock()).thenReturn(SystemNanoClock.INSTANCE);
when(aeron.context()).thenReturn(aeronContext);
doThrow(new IllegalMonitorStateException("aeron closed")).when(aeron).close();
final Publication publication = mock(Publication.class);
when(publication.isConnected()).thenReturn(true);
final IllegalStateException publicationException = new IllegalStateException("publication is closed");
doThrow(publicationException).when(publication).close();
final Subscription subscription = mock(Subscription.class);
when(controlResponsePoller.subscription()).thenReturn(subscription);
final IndexOutOfBoundsException subscriptionException = new IndexOutOfBoundsException("subscription");
doThrow(subscriptionException).when(subscription).close();
when(archiveProxy.publication()).thenReturn(publication);
final IndexOutOfBoundsException closeSessionException = new IndexOutOfBoundsException();
when(archiveProxy.closeSession(controlSessionId)).thenThrow(closeSessionException);
final Context context = new Context().aeron(aeron).idleStrategy(NoOpIdleStrategy.INSTANCE).messageTimeoutNs(100).lock(NoOpLock.INSTANCE).errorHandler(errorHandler).ownsAeronClient(false);
final AeronArchive aeronArchive = new AeronArchive(context, controlResponsePoller, archiveProxy, controlSessionId);
aeronArchive.close();
final InOrder inOrder = inOrder(errorHandler);
inOrder.verify(errorHandler).onError(closeSessionException);
inOrder.verify(errorHandler).onError(publicationException);
inOrder.verify(errorHandler).onError(subscriptionException);
inOrder.verifyNoMoreInteractions();
}
use of io.aeron.archive.client.AeronArchive.Context in project aeron by real-logic.
the class AeronArchiveTest method closeOwningAeronClient.
@Test
void closeOwningAeronClient() {
final long controlSessionId = 42;
final Aeron.Context aeronContext = mock(Aeron.Context.class);
when(aeronContext.nanoClock()).thenReturn(SystemNanoClock.INSTANCE);
when(aeron.context()).thenReturn(aeronContext);
final IllegalMonitorStateException aeronException = new IllegalMonitorStateException("aeron closed");
doThrow(aeronException).when(aeron).close();
final Publication publication = mock(Publication.class);
when(publication.isConnected()).thenReturn(true);
doThrow(new IllegalStateException("publication is closed")).when(publication).close();
final Subscription subscription = mock(Subscription.class);
when(controlResponsePoller.subscription()).thenReturn(subscription);
doThrow(new IndexOutOfBoundsException("subscription")).when(subscription).close();
when(archiveProxy.publication()).thenReturn(publication);
final IndexOutOfBoundsException closeSessionException = new IndexOutOfBoundsException();
when(archiveProxy.closeSession(controlSessionId)).thenThrow(closeSessionException);
final Context context = new Context().aeron(aeron).idleStrategy(NoOpIdleStrategy.INSTANCE).messageTimeoutNs(100).lock(NoOpLock.INSTANCE).errorHandler(errorHandler).ownsAeronClient(true);
final AeronArchive aeronArchive = new AeronArchive(context, controlResponsePoller, archiveProxy, controlSessionId);
final IllegalMonitorStateException ex = assertThrows(IllegalMonitorStateException.class, aeronArchive::close);
assertSame(aeronException, ex);
final InOrder inOrder = inOrder(errorHandler);
inOrder.verify(errorHandler).onError(closeSessionException);
inOrder.verifyNoMoreInteractions();
}
use of io.aeron.archive.client.AeronArchive.Context in project aeron by real-logic.
the class AeronArchiveTest method closeNotOwningAeronClient.
@Test
void closeNotOwningAeronClient() {
final long controlSessionId = 42;
final Aeron.Context aeronContext = mock(Aeron.Context.class);
when(aeronContext.nanoClock()).thenReturn(SystemNanoClock.INSTANCE);
when(aeron.context()).thenReturn(aeronContext);
doThrow(new IllegalMonitorStateException("aeron closed")).when(aeron).close();
final Publication publication = mock(Publication.class);
when(publication.isConnected()).thenReturn(true);
final IllegalStateException publicationException = new IllegalStateException("publication is closed");
doThrow(publicationException).when(publication).close();
final Subscription subscription = mock(Subscription.class);
when(controlResponsePoller.subscription()).thenReturn(subscription);
final IndexOutOfBoundsException subscriptionException = new IndexOutOfBoundsException("subscription");
doThrow(subscriptionException).when(subscription).close();
when(archiveProxy.publication()).thenReturn(publication);
final IndexOutOfBoundsException closeSessionException = new IndexOutOfBoundsException();
when(archiveProxy.closeSession(controlSessionId)).thenThrow(closeSessionException);
final Context context = new Context().aeron(aeron).idleStrategy(NoOpIdleStrategy.INSTANCE).messageTimeoutNs(100).lock(NoOpLock.INSTANCE).errorHandler(errorHandler).ownsAeronClient(false);
final AeronArchive aeronArchive = new AeronArchive(context, controlResponsePoller, archiveProxy, controlSessionId);
aeronArchive.close();
final InOrder inOrder = inOrder(errorHandler);
inOrder.verify(errorHandler).onError(closeSessionException);
inOrder.verify(errorHandler).onError(publicationException);
inOrder.verify(errorHandler).onError(subscriptionException);
inOrder.verifyNoMoreInteractions();
}
Aggregations