use of io.aeron.archive.ArchiveThreadingMode.SHARED in project aeron by real-logic.
the class ArchiveTest method shouldErrorWhenUnauthorised.
@Test
@InterruptAfter(10)
public void shouldErrorWhenUnauthorised() {
final MediaDriver.Context driverCtx = new MediaDriver.Context().dirDeleteOnStart(true).threadingMode(ThreadingMode.SHARED);
final AuthorisationServiceSupplier authorisationServiceSupplier = () -> (protocolId, actionId, type, encodedPrincipal) -> {
return actionId != TruncateRecordingRequestDecoder.TEMPLATE_ID;
};
final Archive.Context archiveCtx = new Archive.Context().deleteArchiveOnStart(true).authorisationServiceSupplier(authorisationServiceSupplier).threadingMode(SHARED);
try (ArchivingMediaDriver ignore = ArchivingMediaDriver.launch(driverCtx, archiveCtx);
AeronArchive archive = AeronArchive.connect()) {
try {
archive.truncateRecording(0, 0);
} catch (final ArchiveException ex) {
assertEquals(ArchiveException.UNAUTHORISED_ACTION, ex.errorCode());
return;
}
fail("Expected exception");
} finally {
archiveCtx.deleteDirectory();
driverCtx.deleteDirectory();
}
}
Aggregations