summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorTiberiu Breana <tiberiu.a.breana@intel.com>2014-11-18 18:28:38 +0200
committerMihai Serban <mihai.serban@intel.com>2015-06-04 12:27:15 +0300
commitb66e876c96fbc9c789d4159d4ab7647faea255e4 (patch)
tree3affa13e9fa7ded99c069f4c556c970a21772d56 /luni
parent27ef0eb26e179b7750b9cb72018da9fab3a0bbb0 (diff)
downloadlibcore-b66e876c96fbc9c789d4159d4ab7647faea255e4.zip
libcore-b66e876c96fbc9c789d4159d4ab7647faea255e4.tar.gz
libcore-b66e876c96fbc9c789d4159d4ab7647faea255e4.tar.bz2
Add exceptions for test_connectLjava_net_SocketAddressI
OldSocketTest's test_connectLjava_net_SocketAddressI would sometimes fail on certain networks. The connection attempt to the 'non-reachable' IP would be reset by a local router before the expected timeout occured, thus causing the test to fail. This change adds additional catch clauses for cases like this, looking for ECONNREFUSED messages. Bug: 18143878 Change-Id: I99a500d5c95cc25aa52ef231e6de43233f3e5316 Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com> (cherry picked from commit d3ba3eb7a3fa67c1de2cb7a5ba999dcf91c13a91)
Diffstat (limited to 'luni')
-rw-r--r--luni/src/test/java/libcore/java/net/OldSocketTest.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/java/net/OldSocketTest.java b/luni/src/test/java/libcore/java/net/OldSocketTest.java
index 80bee69..7973965 100644
--- a/luni/src/test/java/libcore/java/net/OldSocketTest.java
+++ b/luni/src/test/java/libcore/java/net/OldSocketTest.java
@@ -1251,6 +1251,12 @@ public class OldSocketTest extends OldSocketTestCase {
theSocket.connect(nonReachableAddress, 200);
theSocket.close();
fail("No interrupted exception when connecting to address nobody listening on with short timeout 200: ");
+ } catch (ConnectException ce) {
+ // some networks will quickly reset the TCP connection attempt to this fake IP
+ assertTrue(
+ "Wrong exception when connecting to address nobody listening on with short timeout 200: "
+ + ce.toString(),
+ (ce.getMessage() != null && ce.getMessage().contains("ECONNREFUSED")));
} catch (Exception e) {
assertTrue(
"Wrong exception when connecting to address nobody listening on with short timeout 200: "
@@ -1266,6 +1272,12 @@ public class OldSocketTest extends OldSocketTestCase {
theSocket.connect(nonReachableAddress, 40);
theSocket.close();
fail("No interrupted exception when connecting to address nobody listening on with short timeout 40: ");
+ } catch (ConnectException ce) {
+ // some networks will quickly reset the TCP connection attempt to this fake IP
+ assertTrue(
+ "Wrong exception when connecting to address nobody listening on with short timeout 40: "
+ + ce.toString(),
+ (ce.getMessage() != null && ce.getMessage().contains("ECONNREFUSED")));
} catch (Exception e) {
assertTrue(
"Wrong exception when connecting to address nobody listening on with short timeout 40: "