use of com.linkedin.r2.sample.echo.rest.RestEchoClient in project rest.li by linkedin.
the class TestHttpsEcho method testHttpEcho.
/**
* Test that https-enabled server and client can speak plain HTTP as well.
*/
@Test
public void testHttpEcho() throws Exception {
final EchoService client = new RestEchoClient(Bootstrap.createURI(SslContextUtil.getHttpPortFromHttps(_port), Bootstrap.getEchoURI(), false), createClient());
final String msg = "This is a simple http echo message";
final FutureCallback<String> callback = new FutureCallback<>();
client.echo(msg, callback);
Assert.assertEquals(callback.get(), msg);
}
use of com.linkedin.r2.sample.echo.rest.RestEchoClient in project rest.li by linkedin.
the class TestAlpnUpgradePromise method testAlpnFailure.
public void testAlpnFailure() throws Exception {
final EchoService client = new RestEchoClient(Bootstrap.createURI(_port, Bootstrap.getEchoURI(), _serverProvider.isSsl()), _client);
final String msg = "This is a simple http echo message";
final FutureCallback<String> callback = new FutureCallback<>();
try {
client.echo(msg, callback);
Assert.assertEquals(callback.get(), msg);
Assert.fail("Should not have reached here !");
} catch (Exception ex) {
Throwable throwable = ExceptionUtils.getRootCause(ex);
Assert.assertTrue(throwable instanceof IllegalStateException);
Assert.assertEquals(throwable.getMessage(), "Unsupported protocol 'http/1.1' is negotiated.");
}
}
use of com.linkedin.r2.sample.echo.rest.RestEchoClient in project rest.li by linkedin.
the class TestAlpnUpgradePromise method testClientMessageEcho.
public void testClientMessageEcho() throws Exception {
final EchoService client = new RestEchoClient(Bootstrap.createURI(_port, Bootstrap.getEchoURI(), _serverProvider.isSsl()), _client);
final String msg = "This is a simple http echo message";
final FutureCallback<String> callback = new FutureCallback<>();
client.echo(msg, callback);
Assert.assertEquals(callback.get(), msg);
}
use of com.linkedin.r2.sample.echo.rest.RestEchoClient in project rest.li by linkedin.
the class TestHttpsCheckCertificate method testHttpsEchoWithSessionValidator.
private void testHttpsEchoWithSessionValidator(SslSessionValidator sslSessionValidator) throws Exception {
final RestEchoClient client = getEchoClient(_client, Bootstrap.getEchoURI());
final String msg = "This is a simple echo message";
final FutureCallback<String> callback = new FutureCallback<>();
RequestContext requestContext = new RequestContext();
requestContext.putLocalAttr(R2Constants.REQUESTED_SSL_SESSION_VALIDATOR, sslSessionValidator);
client.echo(msg, requestContext, callback);
String actual = callback.get(20, TimeUnit.SECONDS);
Assert.assertEquals(actual, msg);
}
Aggregations