Added test that connects to an external website that exposes a non-HTTP protocol such as SSH.

This commit is contained in:
Simone Bordet 2013-01-28 23:20:38 +01:00
parent 9ba1069383
commit 40621f0300
1 changed files with 48 additions and 0 deletions

View File

@ -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));
}
}
}