mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-02 17:02:08 +01:00
51fb81926e
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@10407 b35dd754-fafc-0310-a699-88a17e54d16e
70 lines
2.5 KiB
Java
70 lines
2.5 KiB
Java
package org.jivesoftware.smackx.jingle;
|
|
|
|
import org.jivesoftware.smack.test.SmackTestCase;
|
|
import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
|
|
import org.jivesoftware.smackx.jingle.mediaimpl.test.TestMediaManager;
|
|
import org.jivesoftware.smackx.jingle.nat.FixedResolver;
|
|
import org.jivesoftware.smackx.jingle.nat.FixedTransportManager;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class JingleSessionTest extends SmackTestCase {
|
|
|
|
public JingleSessionTest(final String name) {
|
|
super(name);
|
|
}
|
|
|
|
public void testEqualsObject() {
|
|
|
|
FixedResolver tr1 = new FixedResolver("127.0.0.1", 54222);
|
|
FixedTransportManager ftm1 = new FixedTransportManager(tr1);
|
|
TestMediaManager tmm1 = new TestMediaManager(ftm1);
|
|
List<JingleMediaManager> trl1 = new ArrayList<JingleMediaManager>();
|
|
trl1.add(tmm1);
|
|
|
|
JingleSession js1 = new JingleSession(getConnection(0), "res1", null, "10", trl1);
|
|
JingleSession js2 = new JingleSession(getConnection(1), "res1", null, "10", trl1);
|
|
JingleSession js3 = new JingleSession(getConnection(2), "res2", null, "11", trl1);
|
|
|
|
System.out.println(js1.getSid());
|
|
System.out.println(js2.getSid());
|
|
|
|
js1.setInitiator("js1");
|
|
js2.setInitiator("js1");
|
|
js1.setSid("10");
|
|
js2.setSid("10");
|
|
|
|
assertEquals(js1, js2);
|
|
assertEquals(js2, js1);
|
|
|
|
assertFalse(js1.equals(js3));
|
|
}
|
|
|
|
public void testGetInstanceFor() {
|
|
String ini1 = "initiator1";
|
|
String sid1 = "sid1";
|
|
String ini2 = "initiator2";
|
|
String sid2 = "sid2";
|
|
|
|
FixedResolver tr1 = new FixedResolver("127.0.0.1", 54222);
|
|
FixedTransportManager ftm1 = new FixedTransportManager(tr1);
|
|
TestMediaManager tmm1 = new TestMediaManager(ftm1);
|
|
List<JingleMediaManager> trl1 = new ArrayList<JingleMediaManager>();
|
|
trl1.add(tmm1);
|
|
|
|
JingleSession js1 = new JingleSession(getConnection(0), ini1, null, sid1, trl1);
|
|
JingleSession js2 = new JingleSession(getConnection(1), ini2, null, sid2, trl1);
|
|
|
|
// For a packet, we should be able to get a session that handles that...
|
|
assertNotNull(JingleSession.getInstanceFor(getConnection(0)));
|
|
assertNotNull(JingleSession.getInstanceFor(getConnection(1)));
|
|
|
|
assertEquals(JingleSession.getInstanceFor(getConnection(0)), js1);
|
|
assertEquals(JingleSession.getInstanceFor(getConnection(1)), js2);
|
|
}
|
|
|
|
protected int getMaxConnections() {
|
|
return 3;
|
|
}
|
|
}
|