From e5ce587f68b2c10e7dfdfc7f0a10eafc048288d5 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Wed, 8 Nov 2017 19:01:42 -0500 Subject: [PATCH] Added test to non-existing node --- .../api/android/NodeConnectionTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/graphenej/src/test/java/cy/agorise/graphenej/api/android/NodeConnectionTest.java b/graphenej/src/test/java/cy/agorise/graphenej/api/android/NodeConnectionTest.java index 35da61a..e29db02 100644 --- a/graphenej/src/test/java/cy/agorise/graphenej/api/android/NodeConnectionTest.java +++ b/graphenej/src/test/java/cy/agorise/graphenej/api/android/NodeConnectionTest.java @@ -5,6 +5,8 @@ import com.neovisionaries.ws.client.WebSocket; import com.neovisionaries.ws.client.WebSocketException; import com.neovisionaries.ws.client.WebSocketFactory; +import junit.framework.Assert; + import org.bitcoinj.core.ECKey; import org.junit.Test; @@ -129,6 +131,31 @@ public class NodeConnectionTest { } } + @Test + public void testWrongUrl(){ + System.out.println("** Testing simple node connection with wrong URL **"); + nodeConnection = NodeConnection.getInstance(); + nodeConnection.addNodeUrl("wss://non-existing-host"); + nodeConnection.connect("", "", true, new NodeErrorListener() { + @Override + public void onError(BaseResponse.Error error) { + Assert.assertEquals("Can't connect, ran out of URLs!", error.message); + } + }); + + Timer timer = new Timer(); + timer.schedule(releaseTask, 5000); + + try{ + // Holding this thread while we get update notifications + synchronized (this){ + wait(); + } + }catch(InterruptedException e){ + System.out.println("InterruptedException. Msg: "+e.getMessage()); + } + } + /** * Test for NodeConnection's addNodeUrl and addNodeUrls working together. *