Skip to content

Commit

Permalink
Fixed test assumption.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbordet committed Jan 9, 2015
1 parent bb2872b commit fd13361
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.eclipse.jetty.client;

import java.io.IOException;
import java.net.Socket;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -63,14 +62,7 @@ public void testExternalSite() throws Exception
int port = 80;

// Verify that we have connectivity
try
{
new Socket(host, port).close();
}
catch (IOException x)
{
Assume.assumeNoException(x);
}
assumeCanConnectTo(host, port);

final CountDownLatch latch1 = new CountDownLatch(1);
client.newRequest(host, port).send(new Response.CompleteListener()
Expand Down Expand Up @@ -110,14 +102,7 @@ public void testExternalSSLSite() throws Exception
int port = 443;

// Verify that we have connectivity
try
{
new Socket(host, port).close();
}
catch (IOException x)
{
Assume.assumeNoException(x);
}
assumeCanConnectTo(host, port);

final CountDownLatch latch = new CountDownLatch(1);
client.newRequest(host, port).scheme("https").path("/nvp").send(new Response.CompleteListener()
Expand All @@ -139,14 +124,7 @@ public void testExternalSiteWrongProtocol() throws Exception
int port = 22; // SSH port

// Verify that we have connectivity
try
{
new Socket(host, port).close();
}
catch (IOException x)
{
Assume.assumeNoException(x);
}
assumeCanConnectTo(host, port);

for (int i = 0; i < 2; ++i)
{
Expand Down Expand Up @@ -186,19 +164,24 @@ public void testExternalSiteRedirect() throws Exception
int port = 443;

// Verify that we have connectivity
assumeCanConnectTo(host, port);

ContentResponse response = client.newRequest(host, port)
.scheme(HttpScheme.HTTPS.asString())
.path("/twitter")
.send();
Assert.assertEquals(200, response.getStatus());
}

protected void assumeCanConnectTo(String host, int port)
{
try
{
new Socket(host, port).close();
}
catch (IOException x)
catch (Throwable x)
{
Assume.assumeNoException(x);
}

ContentResponse response = client.newRequest(host, port)
.scheme(HttpScheme.HTTPS.asString())
.path("/twitter")
.send();
Assert.assertEquals(200, response.getStatus());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public void testExternalProxy() throws Exception
{
new Socket(proxyHost, proxyPort).close();
}
catch (IOException x)
catch (Throwable x)
{
Assume.assumeNoException(x);
}
Expand Down

0 comments on commit fd13361

Please sign in to comment.