From 40621f0300934703db56cd14196e36c5e185f7c3 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 28 Jan 2013 23:20:38 +0100 Subject: Added test that connects to an external website that exposes a non-HTTP protocol such as SSH. --- .../org/eclipse/jetty/client/ExternalSiteTest.java | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'jetty-client/src/test/java/org/eclipse/jetty/client/ExternalSiteTest.java') diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalSiteTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalSiteTest.java index c5982b4a34..5868eebfb9 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalSiteTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ExternalSiteTest.java @@ -98,4 +98,52 @@ public class ExternalSiteTest }); Assert.assertTrue(latch2.await(10, TimeUnit.SECONDS)); } + + + @Test + public void testExternalSiteWrongProtocol() throws Exception + { + String host = "github.com"; + int port = 22; // SSH port + + // Verify that we have connectivity + try + { + new Socket(host, port); + } + catch (IOException x) + { + Assume.assumeNoException(x); + } + + for (int i = 0; i < 2; ++i) + { + final CountDownLatch latch = new CountDownLatch(3); + client.newRequest(host, port) + .onResponseFailure(new Response.FailureListener() + { + @Override + public void onFailure(Response response, Throwable failure) + { + latch.countDown(); + } + }) + .send(new Response.Listener.Empty() + { + @Override + public void onFailure(Response response, Throwable failure) + { + latch.countDown(); + } + + @Override + public void onComplete(Result result) + { + Assert.assertTrue(result.isFailed()); + latch.countDown(); + } + }); + Assert.assertTrue(latch.await(10, TimeUnit.SECONDS)); + } + } } -- cgit v1.2.3