Added test that connects to an external website that exposes a non-HTTP protocol such as SSH.
This commit is contained in:
parent
9ba1069383
commit
40621f0300
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue