use of com.linkedin.r2.sample.echo.EchoService in project rest.li by linkedin.
the class TestSslTimingKey method testSslTimingKey.
@Test
public void testSslTimingKey() throws Exception {
if (isHttp2StreamBasedChannel())
return;
final EchoService client = new RestEchoClient(Bootstrap.createURI(_port, Bootstrap.getEchoURI(), true), 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);
RequestContext context = _clientCaptureFilter.getRequestContext();
@SuppressWarnings("unchecked") Map<TimingKey, TimingContext> map = (Map<TimingKey, TimingContext>) context.getLocalAttr("timings");
Assert.assertNotNull(map);
Assert.assertTrue(map.containsKey(SslHandshakeTimingHandler.TIMING_KEY));
TimingContext timingContext = map.get(SslHandshakeTimingHandler.TIMING_KEY);
Assert.assertNotNull(timingContext);
}
use of com.linkedin.r2.sample.echo.EchoService in project rest.li by linkedin.
the class TestAlpnUpgradePromise method testClearTestUpgradeFailure.
private void testClearTestUpgradeFailure() {
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(), "HTTP/2 clear text upgrade failed");
}
}
use of com.linkedin.r2.sample.echo.EchoService in project rest.li by linkedin.
the class TestGeneralEchoServiceTest method testOnExceptionEchoService.
@Test
public void testOnExceptionEchoService() throws Exception {
final EchoService client = getEchoClient(_client, Bootstrap.getOnExceptionEchoURI());
final String msg = "This is a simple echo message";
final FutureCallback<String> callback = new FutureCallback<>();
client.echo(msg, callback);
try {
callback.get();
Assert.fail("Should have thrown an exception");
} catch (ExecutionException e) {
Assert.assertTrue(e.getCause() instanceof RemoteInvocationException);
}
}
use of com.linkedin.r2.sample.echo.EchoService in project rest.li by linkedin.
the class TestGeneralEchoServiceTest method testFilterChain.
@Test
public void testFilterChain() throws Exception {
final EchoService client = getEchoClient(_client, Bootstrap.getEchoURI());
final String msg = "This is a simple echo message";
final FutureCallback<String> callback = new FutureCallback<>();
client.echo(msg, callback);
callback.get();
// Make sure the server got its wire attribute
Assert.assertEquals(_serverCaptureFilter.getRequest().get(_toServerKey), _toServerValue);
Assert.assertEquals(_serverCaptureFilter.getResponse().get(_toClientKey), _toClientValue);
// Make sure the client got its wire attribute, but not the server's wire attribute
Assert.assertEquals(_clientCaptureFilter.getResponse().get(_toClientKey), _toClientValue);
Assert.assertNull(_clientCaptureFilter.getResponse().get(_toServerKey));
}
use of com.linkedin.r2.sample.echo.EchoService in project rest.li by linkedin.
the class AbstractEchoServiceTest method testOnExceptionEchoService.
@Test
public void testOnExceptionEchoService() throws Exception {
final EchoService client = getEchoClient(_client, Bootstrap.getOnExceptionEchoURI());
final String msg = "This is a simple echo message";
final FutureCallback<String> callback = new FutureCallback<String>();
client.echo(msg, callback);
try {
callback.get();
Assert.fail("Should have thrown an exception");
} catch (ExecutionException e) {
Assert.assertTrue(e.getCause() instanceof RemoteInvocationException);
}
}
Aggregations