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. *