2013-02-07 15:19:47 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2007-01-04 18:25:30 +01:00
|
|
|
package org.jivesoftware.smackx.jingle.nat;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
2007-01-30 00:45:13 +01:00
|
|
|
|
2007-01-04 18:25:30 +01:00
|
|
|
import org.jivesoftware.smack.test.SmackTestCase;
|
|
|
|
|
|
|
|
public class TransportCandidateTest extends SmackTestCase {
|
|
|
|
|
2007-01-30 00:45:13 +01:00
|
|
|
public TransportCandidateTest(final String arg0) {
|
|
|
|
super(arg0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for equals()
|
|
|
|
*/
|
|
|
|
public void testEqualsObject() {
|
2007-02-22 20:14:18 +01:00
|
|
|
TransportCandidate cand1 = new ICECandidate("192.168.2.1", 1, 2,
|
2007-04-16 17:44:55 +02:00
|
|
|
"password", 3468, "username", 25, ICECandidate.Type.prflx);
|
2007-02-22 20:14:18 +01:00
|
|
|
TransportCandidate cand2 = new ICECandidate("192.168.2.1", 1, 2,
|
2007-04-16 17:44:55 +02:00
|
|
|
"password", 3468, "username", 25, ICECandidate.Type.prflx);
|
2007-02-22 20:14:18 +01:00
|
|
|
TransportCandidate cand3 = new ICECandidate("192.168.2.1", 1, 2,
|
2007-04-16 17:44:55 +02:00
|
|
|
"password", 3469, "username", 25, ICECandidate.Type.prflx);
|
2007-01-30 00:45:13 +01:00
|
|
|
|
|
|
|
assertEquals(cand1, cand2);
|
|
|
|
assertFalse(cand1.equals(cand3));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for compareTo()
|
|
|
|
*/
|
|
|
|
public void testCompareTo() {
|
|
|
|
int highestPref = 100;
|
|
|
|
|
2012-10-26 12:47:55 +02:00
|
|
|
ICECandidate cand1 = new ICECandidate("192.168.2.1", 3, 2,
|
2007-04-16 17:44:55 +02:00
|
|
|
"password", 3468, "username", 1, ICECandidate.Type.prflx);
|
2012-10-26 12:47:55 +02:00
|
|
|
ICECandidate cand2 = new ICECandidate("192.168.5.1", 2, 10,
|
2007-04-16 17:44:55 +02:00
|
|
|
"password", 3469, "username", 15,ICECandidate.Type.prflx);
|
2012-10-26 12:47:55 +02:00
|
|
|
ICECandidate candH = new ICECandidate("192.168.2.1", 1, 2,
|
2007-04-16 17:44:55 +02:00
|
|
|
"password", 3468, "username", highestPref, ICECandidate.Type.prflx);
|
2012-10-26 12:47:55 +02:00
|
|
|
ICECandidate cand3 = new ICECandidate("192.168.2.10", 2, 10,
|
2007-04-16 17:44:55 +02:00
|
|
|
"password", 3469, "username", 2, ICECandidate.Type.prflx);
|
2012-10-26 12:47:55 +02:00
|
|
|
ICECandidate cand4 = new ICECandidate("192.168.4.1", 3, 2,
|
2007-04-16 17:44:55 +02:00
|
|
|
"password", 3468, "username", 78, ICECandidate.Type.prflx);
|
2007-01-30 00:45:13 +01:00
|
|
|
|
2012-10-26 12:47:55 +02:00
|
|
|
ArrayList<ICECandidate> candList = new ArrayList<ICECandidate>();
|
2007-01-30 00:45:13 +01:00
|
|
|
candList.add(cand1);
|
|
|
|
candList.add(cand2);
|
|
|
|
candList.add(candH);
|
|
|
|
candList.add(cand3);
|
|
|
|
candList.add(cand4);
|
|
|
|
|
|
|
|
Collections.sort(candList);
|
|
|
|
assertEquals(candList.get(candList.size() - 1), candH);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected int getMaxConnections() {
|
|
|
|
return 0;
|
|
|
|
}
|
2007-01-04 18:25:30 +01:00
|
|
|
}
|