From efacd34b2eb7fb0cc8c78531b91491c205745591 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 4 Jan 2013 11:47:53 +0000 Subject: [PATCH] Fix issue with Socks5ProxyTest: The read() method throws an Exception if the socket is closed. Catch this Exception and report the testcase as successful. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13385 b35dd754-fafc-0310-a699-88a17e54d16e --- .../bytestreams/socks5/Socks5ProxyTest.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test-unit/org/jivesoftware/smackx/bytestreams/socks5/Socks5ProxyTest.java b/test-unit/org/jivesoftware/smackx/bytestreams/socks5/Socks5ProxyTest.java index 117621bbc..7d83d4563 100644 --- a/test-unit/org/jivesoftware/smackx/bytestreams/socks5/Socks5ProxyTest.java +++ b/test-unit/org/jivesoftware/smackx/bytestreams/socks5/Socks5ProxyTest.java @@ -13,19 +13,23 @@ */ package org.jivesoftware.smackx.bytestreams.socks5; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; +import java.net.SocketException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import org.jivesoftware.smack.SmackConfiguration; -import org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy; import org.junit.After; import org.junit.Test; @@ -191,7 +195,14 @@ public class Socks5ProxyTest { OutputStream out = socket.getOutputStream(); out.write(new byte[] { 1, 2, 3 }); - assertEquals(-1, socket.getInputStream().read()); + int res; + try { + res = socket.getInputStream().read(); + } catch (SocketException e) { + res = -1; + } + + assertEquals(-1, res); proxy.stop();