(ManagedChannel channel)
| 761 | } |
| 762 | |
| 763 | private static Status assertRpcFails(ManagedChannel channel) { |
| 764 | Status status = null; |
| 765 | SimpleServiceGrpc.SimpleServiceBlockingStub stub = SimpleServiceGrpc.newBlockingStub(channel); |
| 766 | try { |
| 767 | stub.unaryRpc(SimpleRequest.getDefaultInstance()); |
| 768 | assertWithMessage("TLS handshake should have failed, but didn't; received RPC response") |
| 769 | .fail(); |
| 770 | } catch (StatusRuntimeException e) { |
| 771 | assertWithMessage(Throwables.getStackTraceAsString(e)) |
| 772 | .that(e.getStatus().getCode()).isEqualTo(Status.Code.UNAVAILABLE); |
| 773 | status = e.getStatus(); |
| 774 | } |
| 775 | // We really want to see TRANSIENT_FAILURE here, but if the test runs slowly the 1s backoff |
| 776 | // may be exceeded by the time the failure happens (since it counts from the start of the |
| 777 | // attempt). Even so, CONNECTING is a strong indicator that the handshake failed; otherwise we'd |
| 778 | // expect READY or IDLE. |
| 779 | assertThat(channel.getState(false)) |
| 780 | .isAnyOf(ConnectivityState.TRANSIENT_FAILURE, ConnectivityState.CONNECTING); |
| 781 | return status; |
| 782 | } |
| 783 | |
| 784 | private static final class SimpleServiceImpl extends SimpleServiceGrpc.SimpleServiceImplBase { |
| 785 | @Override |
no test coverage detected