mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 23:42:06 +01:00
UDP Echo Test
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7029 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
fb89cb289e
commit
e688cefd33
1 changed files with 37 additions and 0 deletions
|
@ -11,6 +11,8 @@ import org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener;
|
||||||
import org.jivesoftware.smackx.jingle.media.PayloadType;
|
import org.jivesoftware.smackx.jingle.media.PayloadType;
|
||||||
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,6 +351,41 @@ public class STUNResolverTest extends SmackTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testEcho() {
|
||||||
|
|
||||||
|
TransportCandidate.Fixed c1 = new TransportCandidate.Fixed("localhost", 22222);
|
||||||
|
TransportCandidate.Fixed c2 = new TransportCandidate.Fixed("localhost", 22444);
|
||||||
|
|
||||||
|
try {
|
||||||
|
c1.addCandidateEcho();
|
||||||
|
c2.addCandidateEcho();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
TransportCandidate.CandidateEcho ce1 = c1.getCandidateEcho();
|
||||||
|
TransportCandidate.CandidateEcho ce2 = c2.getCandidateEcho();
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
assertTrue(ce1.test(InetAddress.getByName("localhost"), 22444,100));
|
||||||
|
assertTrue(ce2.test(InetAddress.getByName("localhost"), 22222,100));
|
||||||
|
System.out.println("Bind OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SocketException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
catch (UnknownHostException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected int getMaxConnections() {
|
protected int getMaxConnections() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue