private void validateAuthTokenCheckFailed(MockConnectionFactory factory, Supplier<CompletableFuture<?>> futureSupplier) { CompletableFuture<?> future = futureSupplier.get(); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", future::join, ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException); }
@Test public void abortTransaction() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Controller.TxnStatus> retVal = helper.abortTransaction("", "", 0L, new UUID(0, 0L), new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void truncateSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.truncateSegment("", "", 0L, 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void updateSegmentPolicy() { processor.updateSegmentPolicy(new WireCommands.UpdateSegmentPolicy(100L, "segment", (byte) 0, 0, "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); } }
@Test public void updatePolicy() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Void> retVal = helper.updatePolicy("", "", ScalingPolicy.fixed(1), 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void createTransaction() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<UUID> retVal = helper.createTransaction("", "", 0L, new UUID(0, 0L), new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void sealSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.sealSegment("", "", 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void readSegment() { processor.readSegment(new WireCommands.ReadSegment("segment", 0, 10, "")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(0, "")); }
@Test public void commitTransaction() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Controller.TxnStatus> retVal = helper.commitTransaction("", "", 0L, 0L, new UUID(0, 0L), new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void deleteSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.deleteSegment("", "", 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void createSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.createSegment("", "", 0, ScalingPolicy.fixed(2), new MockHostControllerStore(), factory, "", Long.MIN_VALUE); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void setupAppend() { processor.setupAppend(new WireCommands.SetupAppend(100L, UUID.randomUUID(), "segment", "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); } }
@Test public void mergeSegments() { processor.mergeSegments(new WireCommands.MergeSegments(100L, "segment", "segment2", "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); }
@Test public void createSegment() { processor.createSegment(new WireCommands.CreateSegment(100L, "segment", (byte) 0, 0, "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); }
@Test public void getSegmentAttribute() { processor.getSegmentAttribute(new WireCommands.GetSegmentAttribute(100L, "segment", null, "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); }
public static WireCommand readFrom(ByteBufInputStream in, int length) throws IOException { long requestId = in.readLong(); String serverStackTrace = (in.available() > 0) ? in.readUTF() : EMPTY_STACK_TRACE; return new AuthTokenCheckFailed(requestId, serverStackTrace); } }
@Override public Void answer(InvocationOnMock invocation) throws Throwable { connectionFactory.getProcessor(endpoint).authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(100, "SomeException")); return null; } }).doAnswer(new Answer<Void>() {
@Test public void deleteSegment() { processor.deleteSegment(new WireCommands.DeleteSegment(100L, "segment", "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); }
@Test public void getStreamSegmentInfo() { processor.getStreamSegmentInfo(new WireCommands.GetStreamSegmentInfo(100L, "segment", "token")); verify(connection).send(new WireCommands.AuthTokenCheckFailed(100L, "")); }
@Test public void getSegmentInfo() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<WireCommands.StreamSegmentInfo> retVal = helper.getSegmentInfo("", "", 0L, new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }