From 84def0e74a20bac675fe6221f845decfdaceabdd Mon Sep 17 00:00:00 2001 From: Thiago Camargo Date: Thu, 15 Mar 2007 22:11:15 +0000 Subject: [PATCH] Test Case Added git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7564 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jingle/nat/BridgedResolverTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/BridgedResolverTest.java b/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/BridgedResolverTest.java index 620652241..6ce55c5e0 100644 --- a/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/BridgedResolverTest.java +++ b/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/BridgedResolverTest.java @@ -12,6 +12,9 @@ import org.jivesoftware.smackx.jingle.media.JingleMediaManager; import org.jivesoftware.smackx.jingle.media.JingleMediaSession; import org.jivesoftware.smackx.jingle.media.PayloadType; +import java.net.InetAddress; +import java.net.UnknownHostException; + public class BridgedResolverTest extends SmackTestCase { private int counter; @@ -65,6 +68,46 @@ public class BridgedResolverTest extends SmackTestCase { assertTrue(valCounter() == 3); } + public void testGetPublicIp() { + + resetCounter(); + + String publicIp = RTPBridge.getPublicIP(getConnection(0)); + + System.out.println(publicIp + " local:" + getConnection(0).getLocalNetworkAddress().getHostAddress()); + + if (publicIp != null) { + incCounter(); + } + + try { + InetAddress localaddr = InetAddress.getLocalHost(); + System.out.println("main Local IP Address : " + localaddr.getHostAddress()); + System.out.println("main Local hostname : " + localaddr.getHostName()); + + InetAddress[] localaddrs = InetAddress.getAllByName("localhost"); + for (int i = 0; i < localaddrs.length; i++) { + if (!localaddrs[i].equals(localaddr)) { + System.out.println("alt Local IP Address : " + localaddrs[i].getHostAddress()); + System.out.println("alt Local hostname : " + localaddrs[i].getHostName()); + System.out.println(); + } + } + } + catch (UnknownHostException e) { + System.err.println("Can't detect localhost : " + e); + } + + try { + Thread.sleep(1000); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + assertTrue(valCounter() == 1); + } + protected int getMaxConnections() { return 1; }