aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-03-11 22:15:03 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-03-11 22:15:03 +0100
commit85901329b0794b136b96bf745f4ab1572806fc89 (patch)
treef23da7e97cae727f39d825f0fef8348cffb238e4 /test
parent3db2e44f186c59429901b2c899e139ea60117a55 (diff)
parentcf5da997da8820b4050f5b87ee9440a0ede36d1f (diff)
downloadjitsi-master.zip
jitsi-master.tar.gz
jitsi-master.tar.bz2
Merge commit 'cf5da99'HEADmaster
Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Diffstat (limited to 'test')
-rw-r--r--test/net/java/sip/communicator/slick/configuration/ConfigurationServiceLick.java2
-rw-r--r--test/net/java/sip/communicator/slick/popupmessagehandler/PopupMessageHandlerSLick.java104
-rw-r--r--test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetAdHocMultiUserChat.java7
-rw-r--r--test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java3
-rw-r--r--test/net/java/sip/communicator/slick/protocol/icq/icq.provider.slick.manifest.mf1
-rw-r--r--test/net/java/sip/communicator/slick/protocol/sip/SipProtocolProviderServiceLick.java2
-rw-r--r--test/net/java/sip/communicator/slick/protocol/sip/TestAutoProxyDetection.java970
-rw-r--r--test/net/java/sip/communicator/slick/protocol/sip/TestProtocolProviderServiceSipImpl.java25
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountInstallation.java233
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallation.java287
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallationPersistence.java113
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetAdHocMultiUserChatYahooImpl.java182
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetBasicInstantMessaging.java537
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetFileTransferImpl.java253
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPersistentPresence.java582
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPresence.java1003
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetTypingNotifications.java318
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/TestProtocolProviderServiceYahooImpl.java262
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/YahooProtocolProviderServiceLick.java129
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/YahooSlickFixture.java144
-rw-r--r--test/net/java/sip/communicator/slick/protocol/yahoo/yahoo.provider.slick.manifest.mf17
21 files changed, 565 insertions, 4609 deletions
diff --git a/test/net/java/sip/communicator/slick/configuration/ConfigurationServiceLick.java b/test/net/java/sip/communicator/slick/configuration/ConfigurationServiceLick.java
index 175f9ab..f56e755 100644
--- a/test/net/java/sip/communicator/slick/configuration/ConfigurationServiceLick.java
+++ b/test/net/java/sip/communicator/slick/configuration/ConfigurationServiceLick.java
@@ -52,7 +52,7 @@ public class ConfigurationServiceLick
properties.put("service.pid", getName());
addTestSuite(TestConfigurationService.class);
- addTestSuite(TestConfigurationServicePersistency.class);
+ //addTestSuite(TestConfigurationServicePersistency.class);
addTestSuite(TestConfigurationSlickFinalizer.class);
bundleContext.registerService(getClass().getName(), this, properties);
diff --git a/test/net/java/sip/communicator/slick/popupmessagehandler/PopupMessageHandlerSLick.java b/test/net/java/sip/communicator/slick/popupmessagehandler/PopupMessageHandlerSLick.java
index 10a89bc..0cc63a8 100644
--- a/test/net/java/sip/communicator/slick/popupmessagehandler/PopupMessageHandlerSLick.java
+++ b/test/net/java/sip/communicator/slick/popupmessagehandler/PopupMessageHandlerSLick.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,54 +15,54 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.slick.popupmessagehandler;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.systray.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- *
- * @author Symphorien Wanko
- */
-public class PopupMessageHandlerSLick extends TestSuite implements BundleActivator
-{
- /** Logger for this class */
- private static Logger logger =
- Logger.getLogger(PopupMessageHandlerSLick.class);
-
- /** our bundle context */
- protected static BundleContext bundleContext = null;
-
- /** implements BundleActivator.start() */
- public void start(BundleContext bc) throws Exception
- {
- logger.info("starting popup message test ");
-
- bundleContext = bc;
-
- setName("PopupMessageHandlerSLick");
-
- Hashtable<String, String> properties = new Hashtable<String, String>();
-
- properties.put("service.pid", getName());
-
- // we maybe are running on machine without WM and systray
- // (test server machine), skip tests
- if(ServiceUtils.getService(bc, SystrayService.class) != null)
- {
- addTest(TestPopupMessageHandler.suite());
- }
-
- bundleContext.registerService(getClass().getName(), this, properties);
- }
-
- /** implements BundleActivator.stop() */
- public void stop(BundleContext bc) throws Exception
- {}
-
-}
+package net.java.sip.communicator.slick.popupmessagehandler;
+
+import java.util.*;
+
+import junit.framework.*;
+import net.java.sip.communicator.service.systray.*;
+import net.java.sip.communicator.util.*;
+
+import org.osgi.framework.*;
+
+/**
+ *
+ * @author Symphorien Wanko
+ */
+public class PopupMessageHandlerSLick extends TestSuite implements BundleActivator
+{
+ /** Logger for this class */
+ private static Logger logger =
+ Logger.getLogger(PopupMessageHandlerSLick.class);
+
+ /** our bundle context */
+ protected static BundleContext bundleContext = null;
+
+ /** implements BundleActivator.start() */
+ public void start(BundleContext bc) throws Exception
+ {
+ logger.info("starting popup message test ");
+
+ bundleContext = bc;
+
+ setName("PopupMessageHandlerSLick");
+
+ Hashtable<String, String> properties = new Hashtable<String, String>();
+
+ properties.put("service.pid", getName());
+
+ // we maybe are running on machine without WM and systray
+ // (test server machine), skip tests
+ if(ServiceUtils.getService(bc, SystrayService.class) != null)
+ {
+ addTest(TestPopupMessageHandler.suite());
+ }
+
+ bundleContext.registerService(getClass().getName(), this, properties);
+ }
+
+ /** implements BundleActivator.stop() */
+ public void stop(BundleContext bc) throws Exception
+ {}
+
+}
diff --git a/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetAdHocMultiUserChat.java b/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetAdHocMultiUserChat.java
index 13e5092..1f7db0f 100644
--- a/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetAdHocMultiUserChat.java
+++ b/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetAdHocMultiUserChat.java
@@ -138,10 +138,6 @@ public abstract class TestOperationSetAdHocMultiUserChat extends TestCase
* -Then they will leave the room. They will be invited again in another
* test.
*
- * NOTE that this test will be especially used by Yahoo! protocol because of
- * the fact that creating a conference chat with this protocol fails if any
- * participants are given to the dedicated constructor of the library.
- *
* @throws OperationNotSupportedException
* @throws OperationFailedException
*/
@@ -160,7 +156,6 @@ public abstract class TestOperationSetAdHocMultiUserChat extends TestCase
opSetAHMUC3, AHMUCEventCollector.INVITATION_EVENT);
// We create the room with the given contacts:
- // (NOTE that in Yahoo! adHocChatRoomName won't be considered!)
AdHocChatRoom room = opSetAHMUC1.createAdHocChatRoom(
adHocChatRoomName, contacts, invitationReason);
@@ -440,7 +435,7 @@ public abstract class TestOperationSetAdHocMultiUserChat extends TestCase
/**
* Make sure that invitations have been received on both side (user2 and
* user3). Note that it only make sense to use this method with protocol
- * who support invitations (Yahoo! and ICQ).
+ * who support invitations (ICQ).
*
* We will first test that after having accept an invitation the concerned
* user joins the room and be a part of participants.
diff --git a/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java b/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java
index e123bd3..d29092d 100644
--- a/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java
+++ b/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java
@@ -605,9 +605,8 @@ public abstract class TestOperationSetFileTransfer
,FileTransferStatusChangeEvent.PREPARING
,stat1.getNewStatus());
- // now wait if some protocol filres inProgress
+ // now wait if some protocol fires inProgress
// jabber doesn't fire inProgress here
- // yahoo fires it
receiverStatusListener.waitForEvent(14000);
// wait in_progress
diff --git a/test/net/java/sip/communicator/slick/protocol/icq/icq.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/icq/icq.provider.slick.manifest.mf
index 68d09e2..d1420bd 100644
--- a/test/net/java/sip/communicator/slick/protocol/icq/icq.provider.slick.manifest.mf
+++ b/test/net/java/sip/communicator/slick/protocol/icq/icq.provider.slick.manifest.mf
@@ -12,6 +12,5 @@ Import-Package: junit.framework,
net.java.sip.communicator.service.dns,
net.java.sip.communicator.service.protocol,
net.java.sip.communicator.service.protocol.icqconstants,
- net.java.sip.communicator.service.protocol.aimconstants,
net.java.sip.communicator.service.protocol.event,
org.jitsi.service.fileaccess
diff --git a/test/net/java/sip/communicator/slick/protocol/sip/SipProtocolProviderServiceLick.java b/test/net/java/sip/communicator/slick/protocol/sip/SipProtocolProviderServiceLick.java
index 9d192fe..d599b80 100644
--- a/test/net/java/sip/communicator/slick/protocol/sip/SipProtocolProviderServiceLick.java
+++ b/test/net/java/sip/communicator/slick/protocol/sip/SipProtocolProviderServiceLick.java
@@ -120,7 +120,7 @@ public class SipProtocolProviderServiceLick
addTest(TestOperationSetPersistentPresence.suite());
//IM test
- addTest(TestOperationSetBasicInstantMessaging.suite());
+ //addTest(TestOperationSetBasicInstantMessaging.suite());
// telephony
addTestSuite(TestOperationSetBasicTelephonySipImpl.class);
diff --git a/test/net/java/sip/communicator/slick/protocol/sip/TestAutoProxyDetection.java b/test/net/java/sip/communicator/slick/protocol/sip/TestAutoProxyDetection.java
index 948dd9d..e5e9511 100644
--- a/test/net/java/sip/communicator/slick/protocol/sip/TestAutoProxyDetection.java
+++ b/test/net/java/sip/communicator/slick/protocol/sip/TestAutoProxyDetection.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,487 +15,487 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.slick.protocol.sip;
-
-import static net.java.sip.communicator.service.protocol.ProtocolProviderFactory.USER_ID;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import java.net.*;
-import java.text.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.impl.protocol.sip.*;
-import net.java.sip.communicator.impl.protocol.sip.net.*;
-import net.java.sip.communicator.service.dns.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Tests all variations of automatic proxy detection through (simulated) DNS.
- *
- * @author Ingo Bauersachs
- */
-public class TestAutoProxyDetection
- extends TestCase
-{
- private static class TestedAutoProxyDetection extends AutoProxyConnection
- {
- public TestedAutoProxyDetection(SipAccountIDImpl account,
- String defaultTransport)
- {
- super(account, defaultTransport);
- }
-
- @Override
- public void setNetworkUtils(LocalNetworkUtils nu)
- {
- super.setNetworkUtils(nu);
- }
-
- public static class NetworkUtils extends LocalNetworkUtils
- {
- }
- }
-
- private SipAccountIDImpl account;
- private TestedAutoProxyDetection.NetworkUtils nu;
- private SRVRecord srv1;
- private SRVRecord srv2;
- private SRVRecord srv3;
- private InetSocketAddress a1;
- private InetSocketAddress a2;
- private InetSocketAddress a3;
- private InetSocketAddress a4;
- private final static String DOMAIN = "example.com";
- private InetAddress ia1;
- private InetAddress ia2;
- private InetAddress ia3;
- private InetAddress ia4;
- private TestedAutoProxyDetection apd;
-
- @Override
- public void setUp()
- {
- account = createMock(SipAccountIDImpl.class);
- expect(account.getAccountPropertyString(USER_ID))
- .andReturn("unit@" + DOMAIN);
- replay(account);
-
- nu = createMock(TestedAutoProxyDetection.NetworkUtils.class);
- apd = new TestedAutoProxyDetection(account, "UDP");
- apd.setNetworkUtils(nu);
-
- srv1 = createMock(SRVRecord.class);
- expect(srv1.getTarget()).andReturn("proxy1."+DOMAIN);
- expect(srv1.getPort()).andReturn(5060);
- srv2 = createMock(SRVRecord.class);
- expect(srv2.getTarget()).andReturn("proxy2."+DOMAIN);
- expect(srv2.getPort()).andReturn(5061);
- srv3 = createMock(SRVRecord.class);
- expect(srv3.getTarget()).andReturn("proxy3."+DOMAIN);
- expect(srv3.getPort()).andReturn(5062);
- try
- {
- ia1 = InetAddress.getByAddress("proxy1." + DOMAIN,
- new byte[]{0x7f,0,0,1});
- ia2 = InetAddress.getByAddress("proxy2." + DOMAIN,
- new byte[]{0x7f,0,0,2});
- ia3 = InetAddress.getByAddress("proxy3." + DOMAIN,
- new byte[]{0x7f,0,0,3});
- ia4 = InetAddress.getByAddress("proxy4." + DOMAIN,
- new byte[]{0x7f,0,0,4});
- }
- catch (UnknownHostException e)
- {
- fail("unable to initialize: " + e.getMessage());
- }
- a1 = new InetSocketAddress(ia1, 5060);
- a2 = new InetSocketAddress(ia2, 5061);
- a3 = new InetSocketAddress(ia3, 5062);
- a4 = new InetSocketAddress(ia4, 5063);
- }
-
- private void prepareOneNaptrOneSrv() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
- {"0", "udp", "_sip._udp." + DOMAIN}
- });
- expect(nu.getSRVRecords("_sip._udp."+DOMAIN))
- .andReturn(new SRVRecord[]{ srv1 });
- }
-
- private void prepareOneNaptrTwoSrv() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
- {"0", "udp", "_sip._udp." + DOMAIN}
- });
- expect(nu.getSRVRecords("_sip._udp."+DOMAIN))
- .andReturn(new SRVRecord[]{ srv1, srv2 });
- }
-
- public void testOneNaptrNoSrv() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
- {"0", "udp", "_sip._udp." + DOMAIN}
- });
- expect(nu.getSRVRecords("_sip._udp." + DOMAIN)).andReturn(null);
- replay(nu);
-
- assertFalse(apd.getNextAddress());
- verify(account, nu);
- }
-
- public void testOneNaptrOneSrvOneA() throws ParseException, DnssecException
- {
- prepareOneNaptrOneSrv();
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
- replay(nu, srv1);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1);
- }
-
- public void testOneNaptrOneSrvTwoA() throws ParseException, DnssecException
- {
- prepareOneNaptrOneSrv();
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1, a2});
- replay(nu, srv1);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
- assertTrue(apd.getNextAddress());
- assertEquals(a2, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1);
- }
-
- //-----------------------
-
- public void testOneNaptrTwoSrvOneA() throws ParseException, DnssecException
- {
- prepareOneNaptrTwoSrv();
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
- expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
- .andReturn(new InetSocketAddress[]{a2});
- replay(nu, srv1, srv2);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
- assertTrue(apd.getNextAddress());
- assertEquals(a2, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1, srv2);
- }
-
- public void testOneNaptrTwoSrvTwoA() throws ParseException, DnssecException
- {
- prepareOneNaptrTwoSrv();
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1, a2});
- expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
- .andReturn(new InetSocketAddress[]{a3, a4});
- replay(nu, srv1, srv2);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertTrue(apd.getNextAddress());
- assertEquals(a2, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertTrue(apd.getNextAddress());
- assertEquals(a3, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertTrue(apd.getNextAddress());
- assertEquals(a4, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1, srv2);
- }
-
- //-------------------
-
- public void testThreeNaptrOneSrvEachOneAEach()
- throws ParseException,
- DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
- {"0", "udp", "_sip._udp." + DOMAIN},
- {"0", "tcp", "_sip._tcp." + DOMAIN},
- {"0", "tls", "_sips._tcp." + DOMAIN}
- });
- expect(nu.getSRVRecords("_sip._udp."+DOMAIN))
- .andReturn(new SRVRecord[]{ srv1 });
- expect(nu.getSRVRecords("_sip._tcp."+DOMAIN))
- .andReturn(new SRVRecord[]{ srv2 });
- expect(nu.getSRVRecords("_sips._tcp."+DOMAIN))
- .andReturn(new SRVRecord[]{ srv3 });
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
- expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
- .andReturn(new InetSocketAddress[]{a1});
- expect(nu.getAandAAAARecords("proxy3." + DOMAIN, 5062))
- .andReturn(new InetSocketAddress[]{a1});
-
- replay(nu, srv1, srv2, srv3);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("TCP", apd.getTransport());
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("TLS", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1, srv2, srv3);
- }
-
- //-----------------------
-
- public void testNoSrvOneA() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
- expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
- expect(nu.getAandAAAARecords(DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
-
- replay(nu);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu);
- }
-
- public void testOneSrvNoA() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
- expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "UDP", DOMAIN))
- .andReturn(new SRVRecord[]{srv1});
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(null);
-
- replay(nu, srv1);
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1);
- }
-
- public void testOneSrvOneA() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
- expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "UDP", DOMAIN))
- .andReturn(new SRVRecord[]{srv1});
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
-
- replay(nu, srv1);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1);
- }
-
- public void testOneSrvTwoA() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
- expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "UDP", DOMAIN))
- .andReturn(new SRVRecord[]{srv1});
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1, a2});
-
- replay(nu, srv1);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertTrue(apd.getNextAddress());
- assertEquals(a2, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1);
- }
-
- public void testTwoSrvOneA() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
- expect(nu.getSRVRecords("sips", "TCP", DOMAIN))
- .andReturn(new SRVRecord[]{srv2});
- expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "UDP", DOMAIN))
- .andReturn(new SRVRecord[]{srv1});
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
- expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
- .andReturn(new InetSocketAddress[]{a2});
-
- replay(nu, srv1, srv2);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a2, apd.getAddress());
- assertEquals("TLS", apd.getTransport());
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1, srv2);
- }
-
- public void testTwoSameSrvOneA() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
- expect(nu.getSRVRecords("sips", "TCP", DOMAIN))
- .andReturn(new SRVRecord[]{srv1, srv2});
- expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
- expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
- .andReturn(new InetSocketAddress[]{a2});
-
- replay(nu, srv1, srv2);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("TLS", apd.getTransport());
- assertEquals(5060, apd.getAddress().getPort());
-
- assertTrue(apd.getNextAddress());
- assertEquals(a2, apd.getAddress());
- assertEquals("TLS", apd.getTransport());
- assertEquals(5061, apd.getAddress().getPort());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1, srv2);
- }
-
- //----------------------
-
- public void testNoA() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
- expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
- expect(nu.getAandAAAARecords(DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{});
-
- replay(nu);
-
- assertFalse(apd.getNextAddress());
- verify(account, nu);
- }
-
- public void testOneA() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
- expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
- expect(nu.getAandAAAARecords(DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
-
- replay(nu);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu);
- }
-
- public void testTwoA() throws ParseException, DnssecException
- {
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
- expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
- expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
- expect(nu.getAandAAAARecords(DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1, a2});
-
- replay(nu);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertTrue(apd.getNextAddress());
- assertEquals(a2, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu);
- }
-
- public void testNotReturningSameAddressTwice()
- throws ParseException,
- DnssecException
- {
- expect(srv1.getTarget()).andReturn("proxy1."+DOMAIN);
- expect(srv1.getPort()).andReturn(5060);
- expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
- {"0", "udp", "_sip._udp." + DOMAIN},
- {"1", "udp", "_sip._udp." + DOMAIN}
- });
- expect(nu.getSRVRecords("_sip._udp."+DOMAIN)).andReturn(new SRVRecord[]{
- srv1
- });
- expect(nu.getSRVRecords("_sip._udp."+DOMAIN)).andReturn(new SRVRecord[]{
- srv1
- });
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
- expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
- .andReturn(new InetSocketAddress[]{a1});
-
- replay(nu, srv1);
-
- assertTrue(apd.getNextAddress());
- assertEquals(a1, apd.getAddress());
- assertEquals("UDP", apd.getTransport());
-
- assertFalse(apd.getNextAddress());
- verify(account, nu, srv1);
- }
-}
+package net.java.sip.communicator.slick.protocol.sip;
+
+import static net.java.sip.communicator.service.protocol.ProtocolProviderFactory.USER_ID;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import java.net.*;
+import java.text.*;
+
+import junit.framework.*;
+import net.java.sip.communicator.impl.protocol.sip.*;
+import net.java.sip.communicator.impl.protocol.sip.net.*;
+import net.java.sip.communicator.service.dns.*;
+import net.java.sip.communicator.util.*;
+
+/**
+ * Tests all variations of automatic proxy detection through (simulated) DNS.
+ *
+ * @author Ingo Bauersachs
+ */
+public class TestAutoProxyDetection
+ extends TestCase
+{
+ private static class TestedAutoProxyDetection extends AutoProxyConnection
+ {
+ public TestedAutoProxyDetection(SipAccountIDImpl account,
+ String defaultTransport)
+ {
+ super(account, defaultTransport);
+ }
+
+ @Override
+ public void setNetworkUtils(LocalNetworkUtils nu)
+ {
+ super.setNetworkUtils(nu);
+ }
+
+ public static class NetworkUtils extends LocalNetworkUtils
+ {
+ }
+ }
+
+ private SipAccountIDImpl account;
+ private TestedAutoProxyDetection.NetworkUtils nu;
+ private SRVRecord srv1;
+ private SRVRecord srv2;
+ private SRVRecord srv3;
+ private InetSocketAddress a1;
+ private InetSocketAddress a2;
+ private InetSocketAddress a3;
+ private InetSocketAddress a4;
+ private final static String DOMAIN = "example.com";
+ private InetAddress ia1;
+ private InetAddress ia2;
+ private InetAddress ia3;
+ private InetAddress ia4;
+ private TestedAutoProxyDetection apd;
+
+ @Override
+ public void setUp()
+ {
+ account = createMock(SipAccountIDImpl.class);
+ expect(account.getAccountPropertyString(USER_ID))
+ .andReturn("unit@" + DOMAIN);
+ replay(account);
+
+ nu = createMock(TestedAutoProxyDetection.NetworkUtils.class);
+ apd = new TestedAutoProxyDetection(account, "UDP");
+ apd.setNetworkUtils(nu);
+
+ srv1 = createMock(SRVRecord.class);
+ expect(srv1.getTarget()).andReturn("proxy1."+DOMAIN);
+ expect(srv1.getPort()).andReturn(5060);
+ srv2 = createMock(SRVRecord.class);
+ expect(srv2.getTarget()).andReturn("proxy2."+DOMAIN);
+ expect(srv2.getPort()).andReturn(5061);
+ srv3 = createMock(SRVRecord.class);
+ expect(srv3.getTarget()).andReturn("proxy3."+DOMAIN);
+ expect(srv3.getPort()).andReturn(5062);
+ try
+ {
+ ia1 = InetAddress.getByAddress("proxy1." + DOMAIN,
+ new byte[]{0x7f,0,0,1});
+ ia2 = InetAddress.getByAddress("proxy2." + DOMAIN,
+ new byte[]{0x7f,0,0,2});
+ ia3 = InetAddress.getByAddress("proxy3." + DOMAIN,
+ new byte[]{0x7f,0,0,3});
+ ia4 = InetAddress.getByAddress("proxy4." + DOMAIN,
+ new byte[]{0x7f,0,0,4});
+ }
+ catch (UnknownHostException e)
+ {
+ fail("unable to initialize: " + e.getMessage());
+ }
+ a1 = new InetSocketAddress(ia1, 5060);
+ a2 = new InetSocketAddress(ia2, 5061);
+ a3 = new InetSocketAddress(ia3, 5062);
+ a4 = new InetSocketAddress(ia4, 5063);
+ }
+
+ private void prepareOneNaptrOneSrv() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
+ {"0", "udp", "_sip._udp." + DOMAIN}
+ });
+ expect(nu.getSRVRecords("_sip._udp."+DOMAIN))
+ .andReturn(new SRVRecord[]{ srv1 });
+ }
+
+ private void prepareOneNaptrTwoSrv() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
+ {"0", "udp", "_sip._udp." + DOMAIN}
+ });
+ expect(nu.getSRVRecords("_sip._udp."+DOMAIN))
+ .andReturn(new SRVRecord[]{ srv1, srv2 });
+ }
+
+ public void testOneNaptrNoSrv() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
+ {"0", "udp", "_sip._udp." + DOMAIN}
+ });
+ expect(nu.getSRVRecords("_sip._udp." + DOMAIN)).andReturn(null);
+ replay(nu);
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu);
+ }
+
+ public void testOneNaptrOneSrvOneA() throws ParseException, DnssecException
+ {
+ prepareOneNaptrOneSrv();
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+ replay(nu, srv1);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1);
+ }
+
+ public void testOneNaptrOneSrvTwoA() throws ParseException, DnssecException
+ {
+ prepareOneNaptrOneSrv();
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1, a2});
+ replay(nu, srv1);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+ assertTrue(apd.getNextAddress());
+ assertEquals(a2, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1);
+ }
+
+ //-----------------------
+
+ public void testOneNaptrTwoSrvOneA() throws ParseException, DnssecException
+ {
+ prepareOneNaptrTwoSrv();
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+ expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
+ .andReturn(new InetSocketAddress[]{a2});
+ replay(nu, srv1, srv2);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+ assertTrue(apd.getNextAddress());
+ assertEquals(a2, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1, srv2);
+ }
+
+ public void testOneNaptrTwoSrvTwoA() throws ParseException, DnssecException
+ {
+ prepareOneNaptrTwoSrv();
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1, a2});
+ expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
+ .andReturn(new InetSocketAddress[]{a3, a4});
+ replay(nu, srv1, srv2);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a2, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a3, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a4, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1, srv2);
+ }
+
+ //-------------------
+
+ public void testThreeNaptrOneSrvEachOneAEach()
+ throws ParseException,
+ DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
+ {"0", "udp", "_sip._udp." + DOMAIN},
+ {"0", "tcp", "_sip._tcp." + DOMAIN},
+ {"0", "tls", "_sips._tcp." + DOMAIN}
+ });
+ expect(nu.getSRVRecords("_sip._udp."+DOMAIN))
+ .andReturn(new SRVRecord[]{ srv1 });
+ expect(nu.getSRVRecords("_sip._tcp."+DOMAIN))
+ .andReturn(new SRVRecord[]{ srv2 });
+ expect(nu.getSRVRecords("_sips._tcp."+DOMAIN))
+ .andReturn(new SRVRecord[]{ srv3 });
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+ expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
+ .andReturn(new InetSocketAddress[]{a1});
+ expect(nu.getAandAAAARecords("proxy3." + DOMAIN, 5062))
+ .andReturn(new InetSocketAddress[]{a1});
+
+ replay(nu, srv1, srv2, srv3);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("TCP", apd.getTransport());
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("TLS", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1, srv2, srv3);
+ }
+
+ //-----------------------
+
+ public void testNoSrvOneA() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
+ expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
+ expect(nu.getAandAAAARecords(DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+
+ replay(nu);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu);
+ }
+
+ public void testOneSrvNoA() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
+ expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "UDP", DOMAIN))
+ .andReturn(new SRVRecord[]{srv1});
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(null);
+
+ replay(nu, srv1);
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1);
+ }
+
+ public void testOneSrvOneA() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
+ expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "UDP", DOMAIN))
+ .andReturn(new SRVRecord[]{srv1});
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+
+ replay(nu, srv1);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1);
+ }
+
+ public void testOneSrvTwoA() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
+ expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "UDP", DOMAIN))
+ .andReturn(new SRVRecord[]{srv1});
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1, a2});
+
+ replay(nu, srv1);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a2, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1);
+ }
+
+ public void testTwoSrvOneA() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
+ expect(nu.getSRVRecords("sips", "TCP", DOMAIN))
+ .andReturn(new SRVRecord[]{srv2});
+ expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "UDP", DOMAIN))
+ .andReturn(new SRVRecord[]{srv1});
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+ expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
+ .andReturn(new InetSocketAddress[]{a2});
+
+ replay(nu, srv1, srv2);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a2, apd.getAddress());
+ assertEquals("TLS", apd.getTransport());
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1, srv2);
+ }
+
+ public void testTwoSameSrvOneA() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
+ expect(nu.getSRVRecords("sips", "TCP", DOMAIN))
+ .andReturn(new SRVRecord[]{srv1, srv2});
+ expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+ expect(nu.getAandAAAARecords("proxy2." + DOMAIN, 5061))
+ .andReturn(new InetSocketAddress[]{a2});
+
+ replay(nu, srv1, srv2);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("TLS", apd.getTransport());
+ assertEquals(5060, apd.getAddress().getPort());
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a2, apd.getAddress());
+ assertEquals("TLS", apd.getTransport());
+ assertEquals(5061, apd.getAddress().getPort());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1, srv2);
+ }
+
+ //----------------------
+
+ public void testNoA() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
+ expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
+ expect(nu.getAandAAAARecords(DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{});
+
+ replay(nu);
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu);
+ }
+
+ public void testOneA() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
+ expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
+ expect(nu.getAandAAAARecords(DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+
+ replay(nu);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu);
+ }
+
+ public void testTwoA() throws ParseException, DnssecException
+ {
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{});
+ expect(nu.getSRVRecords("sips", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "TCP", DOMAIN)).andReturn(null);
+ expect(nu.getSRVRecords("sip", "UDP", DOMAIN)).andReturn(null);
+ expect(nu.getAandAAAARecords(DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1, a2});
+
+ replay(nu);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a2, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu);
+ }
+
+ public void testNotReturningSameAddressTwice()
+ throws ParseException,
+ DnssecException
+ {
+ expect(srv1.getTarget()).andReturn("proxy1."+DOMAIN);
+ expect(srv1.getPort()).andReturn(5060);
+ expect(nu.getNAPTRRecords(DOMAIN)).andReturn(new String[][]{
+ {"0", "udp", "_sip._udp." + DOMAIN},
+ {"1", "udp", "_sip._udp." + DOMAIN}
+ });
+ expect(nu.getSRVRecords("_sip._udp."+DOMAIN)).andReturn(new SRVRecord[]{
+ srv1
+ });
+ expect(nu.getSRVRecords("_sip._udp."+DOMAIN)).andReturn(new SRVRecord[]{
+ srv1
+ });
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+ expect(nu.getAandAAAARecords("proxy1." + DOMAIN, 5060))
+ .andReturn(new InetSocketAddress[]{a1});
+
+ replay(nu, srv1);
+
+ assertTrue(apd.getNextAddress());
+ assertEquals(a1, apd.getAddress());
+ assertEquals("UDP", apd.getTransport());
+
+ assertFalse(apd.getNextAddress());
+ verify(account, nu, srv1);
+ }
+}
diff --git a/test/net/java/sip/communicator/slick/protocol/sip/TestProtocolProviderServiceSipImpl.java b/test/net/java/sip/communicator/slick/protocol/sip/TestProtocolProviderServiceSipImpl.java
index b475ac9..a799668 100644
--- a/test/net/java/sip/communicator/slick/protocol/sip/TestProtocolProviderServiceSipImpl.java
+++ b/test/net/java/sip/communicator/slick/protocol/sip/TestProtocolProviderServiceSipImpl.java
@@ -19,7 +19,9 @@ package net.java.sip.communicator.slick.protocol.sip;
import java.util.*;
+import javax.sip.address.*;
import junit.framework.*;
+import net.java.sip.communicator.impl.protocol.sip.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
@@ -150,7 +152,7 @@ public class TestProtocolProviderServiceSipImpl
/**
- * Verifies that all operation sets have the type they are declarded to
+ * Verifies that all operation sets have the type they are declared to
* have.
*
* @throws java.lang.Exception if a class indicated in one of the keys
@@ -175,6 +177,27 @@ public class TestProtocolProviderServiceSipImpl
}
/**
+ * Tests the <tt>equals()</tt> implementation of the SIP Contact class
+ */
+ public void testContactSipImpl() throws Exception
+ {
+ ProtocolProviderServiceSipImpl provider =
+ (ProtocolProviderServiceSipImpl) fixture.provider1;
+ Address reference =
+ provider.parseAddressString("sip:User@Host");
+ Contact referenceContact = new ContactSipImpl(reference, provider);
+
+ assertTrue("Cannot find user-only part in a SIP Contact compare",
+ referenceContact.equals("User"));
+ assertTrue("Cannot find SIP Contact using strings",
+ referenceContact.equals("sip:User@Host"));
+ assertTrue("Cannot find SIP Contact when protocol is secure",
+ referenceContact.equals("sips:User@Host"));
+ assertTrue("Cannot find SIP Contact when port is specified",
+ referenceContact.equals("sip:User@Host:5060"));
+ }
+
+ /**
* A class that would plugin as a registration listener to a protocol
* provider and simply record all events that it sees and notifyAll()
* if it sees an event that notifies us of a completed
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountInstallation.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountInstallation.java
deleted file mode 100644
index 0df8b3c..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountInstallation.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-
-import org.osgi.framework.*;
-
-public class TestAccountInstallation
- extends TestCase
-{
-
- /**
- * Creates the test with the specified method name.
- * @param name the name of the method to execute.
- */
- public TestAccountInstallation(String name)
- {
- super(name);
- }
-
- /**
- * JUnit setup method.
- * @throws Exception in case anything goes wrong.
- */
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- /**
- * JUnit teardown method.
- * @throws Exception in case anything goes wrong.
- */
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- /**
- * Installs an account and verifies whether the installation has gone well.
- */
- public void testInstallAccount()
- {
- // first obtain a reference to the provider factory
- ServiceReference[] serRefs = null;
- String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL
- + "="+ProtocolNames.YAHOO+")";
- try{
- serRefs = YahooSlickFixture.bc.getServiceReferences(
- ProtocolProviderFactory.class.getName(), osgiFilter);
- }
- catch (InvalidSyntaxException ex)
- {
- //this really shouldhn't occur as the filter expression is static.
- fail(osgiFilter + " is not a valid osgi filter");
- }
-
- assertTrue(
- "Failed to find a provider factory service for protocol Yahoo",
- serRefs != null && serRefs.length > 0);
-
- //Keep the reference for later usage.
- ProtocolProviderFactory yahooProviderFactory = (ProtocolProviderFactory)
- YahooSlickFixture.bc.getService(serRefs[0]);
-
- //make sure the account is empty
- assertTrue("There was an account registered with the account mananger "
- +"before we've installed any",
- yahooProviderFactory.getRegisteredAccounts().size() == 0);
-
-
- //Prepare the properties of the first yahoo account.
-
- Hashtable<String, String> yahooAccount1Properties = getAccountProperties(
- YahooProtocolProviderServiceLick.ACCOUNT_1_PREFIX);
- Hashtable<String, String> yahooAccount2Properties = getAccountProperties(
- YahooProtocolProviderServiceLick.ACCOUNT_2_PREFIX);
- Hashtable<String, String> yahooAccount3Properties = getAccountProperties(
- YahooProtocolProviderServiceLick.ACCOUNT_3_PREFIX);
-
- //try to install an account with a null account id
- try{
- yahooProviderFactory.installAccount(
- null, yahooAccount1Properties);
- fail("installing an account with a null account id must result "
- +"in a NullPointerException");
- }catch(NullPointerException exc)
- {
- //that's what had to happen
- }
-
- //now really install the accounts
- yahooProviderFactory.installAccount(
- yahooAccount1Properties.get(ProtocolProviderFactory.USER_ID)
- , yahooAccount1Properties);
- yahooProviderFactory.installAccount(
- yahooAccount2Properties.get(ProtocolProviderFactory.USER_ID)
- , yahooAccount2Properties);
- yahooProviderFactory.installAccount(
- yahooAccount3Properties.get(ProtocolProviderFactory.USER_ID)
- , yahooAccount3Properties);
-
-
- //try to install one of the accounts one more time and verify that an
- //excepion is thrown.
- try{
- yahooProviderFactory.installAccount(
- yahooAccount1Properties.get(ProtocolProviderFactory.USER_ID)
- , yahooAccount1Properties);
-
- fail("An IllegalStateException must be thrown when trying to "+
- "install a duplicate account");
-
- }catch(IllegalStateException exc)
- {
- //that's what supposed to happen.
- }
-
- //Verify that the provider factory is aware of our installation
- assertTrue(
- "The newly installed account was not in the acc man's "
- +"registered accounts!",
- yahooProviderFactory.getRegisteredAccounts().size() == 3);
-
- //Verify protocol providers corresponding to the new account have
- //been properly registered with the osgi framework.
-
- osgiFilter =
- "(&("+ProtocolProviderFactory.PROTOCOL +"="+ProtocolNames.YAHOO+")"
- +"(" + ProtocolProviderFactory.USER_ID
- + "=" + yahooAccount1Properties.get(
- ProtocolProviderFactory.USER_ID)
- + "))";
-
- try
- {
- serRefs = YahooSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- osgiFilter);
- }
- catch (InvalidSyntaxException ex)
- {
- //this really shouldhn't occur as the filter expression is static.
- fail(osgiFilter + "is not a valid osgi filter");
- }
-
- assertTrue("An protocol provider was apparently not installed as "
- + "requested."
- , serRefs != null && serRefs.length > 0);
-
- Object yahooProtocolProvider
- = YahooSlickFixture.bc.getService(serRefs[0]);
-
- assertTrue("The installed protocol provider does not implement "
- + "the protocol provider service."
- ,yahooProtocolProvider instanceof ProtocolProviderService);
- }
-
- /**
- * Returns all properties necessary for the intialization of the account
- * with <tt>accountPrefix</tt>.
- * @param accountPrefix the prefix contained by all property names for the
- * the account we'd like to initialized
- * @return a Hashtable that can be used when creating the account in a
- * protocol provider factory.
- */
- private Hashtable<String, String> getAccountProperties(String accountPrefix)
- {
- Hashtable<String, String> table = new Hashtable<String, String>();
-
- String userID = System.getProperty(
- accountPrefix + ProtocolProviderFactory.USER_ID, null);
-
- assertNotNull(
- "The system property named "
- + accountPrefix + ProtocolProviderFactory.USER_ID
- +" has to tontain a valid yahoo address that could be used during "
- +"SIP Communicator's tests."
- , userID);
-
- table.put(ProtocolProviderFactory.USER_ID, userID);
-
- String passwd = System.getProperty(
- accountPrefix + ProtocolProviderFactory.PASSWORD, null );
-
- assertNotNull(
- "The system property named "
- + accountPrefix + ProtocolProviderFactory.PASSWORD
- +" has to contain the password corresponding to the account "
- + "specified in "
- + accountPrefix + ProtocolProviderFactory.USER_ID
- , passwd);
-
- table.put(ProtocolProviderFactory.PASSWORD, passwd);
-
- String serverAddress = System.getProperty(
- accountPrefix + ProtocolProviderFactory.SERVER_ADDRESS, null);
-
- // optional
- if(serverAddress != null)
- table.put(ProtocolProviderFactory.SERVER_ADDRESS, serverAddress);
-
- String serverPort = System.getProperty(
- accountPrefix + ProtocolProviderFactory.SERVER_PORT, null);
-
- // optional
- if(serverPort != null)
- table.put(ProtocolProviderFactory.SERVER_PORT, serverPort);
-
- return table;
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallation.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallation.java
deleted file mode 100644
index 7b04758..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallation.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-
-import org.osgi.framework.*;
-
-/**
- * Tests whether accounts are uninstalled properly. It is important that
- * tests from this class be called last since they will install the accounts
- * that have been used to test the implementations. Apart from uninstallation
- * tests the class also contains tests that remove and reinstall the protocol
- * provider bundle in order to verify that accounts are persistent.
- *
- * @author Emil Ivov
- * @author Valentin Martinet
- */
-public class TestAccountUninstallation
- extends TestCase
-{
- private YahooSlickFixture fixture = new YahooSlickFixture();
-
- /**
- * Constructs a test instance
- * @param name The name of the test.
- */
- public TestAccountUninstallation(String name)
- {
- super(name);
- }
-
- /**
- * JUnit setup method.
- * @throws Exception in case anything goes wrong.
- */
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
- }
-
- /**
- * JUnit teardown method.
- * @throws Exception in case anything goes wrong.
- */
- @Override
- protected void tearDown() throws Exception
- {
- fixture.tearDown();
- super.tearDown();
- }
-
- /**
- * Returns a suite containing tests in this class in the order that we'd
- * like them executed.
- * @return a Test suite containing tests in this class in the order that
- * we'd like them executed.
- */
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(
- new TestAccountUninstallation("testInstallationPersistency"));
- suite.addTest(
- new TestAccountUninstallation("testUninstallAccount"));
-
- return suite;
- }
-
- /**
- * Stops and removes the tested bundle, verifies that it has unregistered
- * its provider, then reloads and restarts the bundle and verifies that
- * the protocol provider is reRegistered in the bundle context.
- *
- * @throws java.lang.Exception if an exception occurs during testing.
- */
- public void testInstallationPersistency() throws Exception
- {
- Bundle providerBundle
- = AdHocMultiUserChatSlickFixture.findProtocolProviderBundle(fixture.provider1);
-
- //set the global providerBundle reference that we will be using
- //in the last series of tests (Account uninstallation persistency)
- YahooSlickFixture.providerBundle = providerBundle;
-
- assertNotNull("Couldn't find a bundle for the tested provider"
- , providerBundle);
-
- providerBundle.stop();
-
- assertTrue("Couldn't stop the protocol provider bundle. State was "
- + providerBundle.getState()
- , Bundle.ACTIVE != providerBundle.getState()
- && Bundle.STOPPING != providerBundle.getState());
-
- providerBundle.uninstall();
-
- assertEquals("Couldn't stop the protocol provider bundle."
- , Bundle.UNINSTALLED, providerBundle.getState());
-
- //verify that the provider is no longer available
- ServiceReference[] yahooProviderRefs = null;
- try
- {
- yahooProviderRefs = AdHocMultiUserChatSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- + "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.YAHOO + ")"
- + "(" + ProtocolProviderFactory.USER_ID
- + "="+ fixture.userID1 + ")"
- + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong: " + ex.getMessage());
- }
-
- //make sure we didn't see a service
- assertTrue("A Protocol Provider Service was still regged as an osgi service "
- +"for yahoo URI:" + fixture.userID1
- + "After it was explicitly uninstalled"
- ,yahooProviderRefs == null || yahooProviderRefs.length == 0);
-
- //verify that the provider factory knows that we have uninstalled the
- //provider.
- assertTrue(
- "The yahoo provider factory kept a reference to the provider we just "
- +"uninstalled (uri="+fixture.userID1+")",
- fixture.providerFactory.getRegisteredAccounts().isEmpty()
- && fixture.providerFactory.getProviderForAccount(
- fixture.provider1.getAccountID())
- == null);
-
- //Now reinstall the bundle
- providerBundle = AdHocMultiUserChatSlickFixture.bc.installBundle(providerBundle.getLocation());
-
- //set the global providerBundle reference that we will be using
- //in the last series of tests (Account uninstallation persistency)
- YahooSlickFixture.providerBundle = providerBundle;
-
- assertEquals("Couldn't re-install protocol provider bundle."
- , Bundle.INSTALLED, providerBundle.getState());
-
- AccountManagerUtils.startBundleAndWaitStoredAccountsLoaded(AdHocMultiUserChatSlickFixture.bc,
- providerBundle, ProtocolNames.YAHOO);
- assertEquals("Couldn't re-start protocol provider bundle."
- , Bundle.ACTIVE, providerBundle.getState());
-
- //Make sure that the provider is there again.
- //verify that the provider is no longer available
- try
- {
- yahooProviderRefs = AdHocMultiUserChatSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- + "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.YAHOO + ")"
- + "(" + ProtocolProviderFactory.USER_ID
- + "="+ fixture.userID1 + ")"
- + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong " + ex.getMessage());
- }
-
- //make sure we didn't see a service
- assertTrue("A Protocol Provider Service was not restored after being"
- +"reinstalled. yahoo URI:" + fixture.userID1
- ,yahooProviderRefs != null && yahooProviderRefs.length > 0);
-
- ServiceReference[] yahooFactoryRefs = null;
- try
- {
- yahooFactoryRefs = AdHocMultiUserChatSlickFixture.bc.getServiceReferences(
- ProtocolProviderFactory.class.getName(),
- "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.YAHOO + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong " + ex.getMessage());
- }
-
- //we're the ones who've reinstalled the factory so it's our
- //responsibility to update the fixture.
- fixture.providerFactory
- = (ProtocolProviderFactory)AdHocMultiUserChatSlickFixture.bc.getService(yahooFactoryRefs[0]);
- fixture.provider1
- = (ProtocolProviderService)AdHocMultiUserChatSlickFixture.bc.getService(yahooProviderRefs[0]);
-
-
- //verify that the provider is also restored in the provider factory
- //itself
- assertTrue(
- "The yahoo provider did not restore its own reference to the provider "
- +"that we just reinstalled (URI="+fixture.userID1+")",
- !fixture.providerFactory.getRegisteredAccounts().isEmpty()
- && fixture.providerFactory.getProviderForAccount(
- fixture.provider1.getAccountID())
- != null);
-
- }
-
- /**
- * Uninstalls our test account and makes sure it really has been removed.
- *
- */
- public void testUninstallAccount()
- {
- assertFalse("No installed accounts found",
- fixture.providerFactory.getRegisteredAccounts().isEmpty());
-
- assertNotNull(
- "Found no provider corresponding to URI " + fixture.userID1
- ,fixture.providerFactory.getProviderForAccount(
- fixture.provider1.getAccountID()));
-
- assertTrue(
- "Failed to remove a provider corresponding to URI "
- + fixture.userID1
- ,fixture.providerFactory.uninstallAccount(
- fixture.provider1.getAccountID()));
- assertTrue(
- "Failed to remove a provider corresponding to URI "
- + fixture.userID2
- ,fixture.providerFactory.uninstallAccount(
- fixture.provider2.getAccountID()));
- assertTrue(
- "Failed to remove a provider corresponding to URI "
- + fixture.userID3
- ,fixture.providerFactory.uninstallAccount(
- fixture.provider3.getAccountID()));
-
- //make sure no providers have remained installed.
- ServiceReference[] yahooProviderRefs = null;
- try
- {
- yahooProviderRefs = AdHocMultiUserChatSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.YAHOO + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong " + ex.getMessage());
- }
-
- //make sure we didn't see a service
- assertTrue("A Protocol Provider Service was still regged as an osgi "
- + "service for yahoo URI:" + fixture.userID1
- + "After it was explicitly uninstalled"
- ,yahooProviderRefs == null || yahooProviderRefs.length == 0);
-
- //verify that the provider factory knows that we have uninstalled the
- //provider.
- assertTrue(
- "The yahoo provider factory kept a reference to the provider we just "
- +"uninstalled (uri="+fixture.userID1+")",
- fixture.providerFactory.getRegisteredAccounts().isEmpty()
- && fixture.providerFactory.getProviderForAccount(
- fixture.provider1.getAccountID())
- == null);
-
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallationPersistence.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallationPersistence.java
deleted file mode 100644
index d87a238..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestAccountUninstallationPersistence.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-
-import org.jitsi.service.configuration.*;
-import org.osgi.framework.*;
-
-/**
- * Contains tests verifying persistence of account uninstallation. In other
- * words we try to make sure that once uninstalled an account remains
- * uninstalled.
- *
- * @author Emil Ivov
- */
-public class TestAccountUninstallationPersistence
- extends TestCase
-{
- /**
- * Creates a new test instance wrapper around the test with the specified
- * name.
- * @param testName the name of the test that we will be executing.
- */
- public TestAccountUninstallationPersistence(String testName)
- {
- super(testName);
- }
-
- /**
- * Retrieves a reference to the yahoo bundle, stops it and uninstalls it and
- * then reinstalls it in order to make sure that accounts are not reloaded
- * once removed.
- *
- * @throws java.lang.Exception if something goes wrong while manipulating
- * the bundles.
- */
- public void testAccountUninstallationPersistence()
- throws Exception
- {
- Bundle providerBundle = YahooSlickFixture.providerBundle;
-
- providerBundle.stop();
-
- assertTrue("Couldn't stop the protocol provider bundle. State was "
- + providerBundle.getState()
- , Bundle.ACTIVE != providerBundle.getState()
- && Bundle.STOPPING != providerBundle.getState());
-
- providerBundle.uninstall();
-
- assertEquals("Couldn't stop the protocol provider bundle."
- , Bundle.UNINSTALLED, providerBundle.getState());
-
- //Now reinstall the bundle and restart the provider
- providerBundle
- = YahooSlickFixture.bc.installBundle(providerBundle.getLocation());
-
- assertEquals("Couldn't re-install protocol provider bundle."
- , Bundle.INSTALLED, providerBundle.getState());
-
- AccountManagerUtils.startBundleAndWaitStoredAccountsLoaded(
- YahooSlickFixture.bc, providerBundle, ProtocolNames.YAHOO);
- assertEquals("Couldn't re-start protocol provider bundle."
- , Bundle.ACTIVE, providerBundle.getState());
-
-
- //verify that the provider is not reinstalled
- ServiceReference[] yahooProviderRefs = null;
- try
- {
- yahooProviderRefs = YahooSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.YAHOO + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong " + ex.getMessage());
- }
-
- //make sure we didn't retrieve a service
- assertTrue("A yahoo Protocol Provider Service was still regged as an "
- +"osgi service after it was explicitly uninstalled"
- ,yahooProviderRefs == null || yahooProviderRefs.length == 0);
-
- //and a nasty hack at the end - delete the configuration file so that
- //we get a fresh start on next run.
- ServiceReference confReference
- = YahooSlickFixture.bc.getServiceReference(
- ConfigurationService.class.getName());
- ConfigurationService configurationService
- = (ConfigurationService) YahooSlickFixture.bc.getService(confReference);
-
- configurationService.purgeStoredConfiguration();
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetAdHocMultiUserChatYahooImpl.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetAdHocMultiUserChatYahooImpl.java
deleted file mode 100644
index 3f66045..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetAdHocMultiUserChatYahooImpl.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-
-/**
- * Tests for the Yahoo! ad-hoc multi-user chat operation set.
- *
- * @author Valentin Martinet
- */
-public class TestOperationSetAdHocMultiUserChatYahooImpl
-extends TestOperationSetAdHocMultiUserChat
-{
- /**
- * Creates the test with the specified method name.
- *
- * @param name the name of the method to execute.
- */
- public TestOperationSetAdHocMultiUserChatYahooImpl(String name)
- {
- super(name);
- }
-
-
- /**
- * Creates a test suite containing tests of this class in a specific order.
- *
- * @return Test a testsuite containing all tests to execute.
- */
- public static TestSuite suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new TestOperationSetAdHocMultiUserChatYahooImpl(
- "testRegisterAccount3"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatYahooImpl(
- "prepareContactList"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatYahooImpl(
- "testCreateRoomWithParticipants"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatYahooImpl(
- "testInvitations"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatYahooImpl(
- "testSendIM"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatYahooImpl(
- "testPeerLeaved"));
-
- return suite;
- }
-
- /**
- * Register the third testing account.
- *
- * @throws OperationFailedException
- */
- public void testRegisterAccount3() throws OperationFailedException
- {
- fixture.provider3.register(
- new SecurityAuthorityImpl(
- System.getProperty(
- YahooProtocolProviderServiceLick.ACCOUNT_3_PREFIX
- + ProtocolProviderFactory.PASSWORD).toCharArray()));
-
- assertEquals(fixture.provider3.getRegistrationState(),
- RegistrationState.REGISTERED);
- }
-
- /**
- * JUnit setUp method.
- * @throws Exception
- *
- * @throws Exception
- */
- @Override
- public void start() throws Exception
- {
- fixture = new YahooSlickFixture();
- fixture.setUp();
-
- // Supported operation sets by each protocol provider.
- Map<String, OperationSet>
- supportedOpSets1, supportedOpSets2, supportedOpSets3;
-
- supportedOpSets1 = fixture.provider1.getSupportedOperationSets();
- supportedOpSets2 = fixture.provider2.getSupportedOperationSets();
- supportedOpSets3 = fixture.provider3.getSupportedOperationSets();
-
- //
- // Initialization of operation sets for the first testing account:
- //
-
- if (supportedOpSets1 == null || supportedOpSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by " +
- "this implementation. ");
-
- opSetAHMUC1 = (OperationSetAdHocMultiUserChat) supportedOpSets1.get(
- OperationSetAdHocMultiUserChat.class.getName());
-
- if (opSetAHMUC1 == null)
- throw new NullPointerException(
- "No implementation for multi user chat was found");
-
- opSetPresence1 = (OperationSetPresence) supportedOpSets1.get(
- OperationSetPresence.class.getName());
-
- if (opSetPresence1 == null)
- throw new NullPointerException(
- "An implementation of the service must provide an " +
- "implementation of at least one of the PresenceOperationSets");
-
-
- //
- // Initialization of operation sets for the second testing account:
- //
-
- if (supportedOpSets2 == null || supportedOpSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by " +
- "this implementation. ");
-
- opSetAHMUC2 = (OperationSetAdHocMultiUserChat) supportedOpSets2.get(
- OperationSetAdHocMultiUserChat.class.getName());
-
- if (opSetAHMUC2 == null)
- throw new NullPointerException(
- "No implementation for ad hoc multi user chat was found");
-
- opSetPresence2 = (OperationSetPresence) supportedOpSets2.get(
- OperationSetPresence.class.getName());
-
- if (opSetPresence2 == null)
- throw new NullPointerException(
- "An implementation of the service must provide an " +
- "implementation of at least one of the PresenceOperationSets");
-
-
- //
- // Initialization of operation sets for the third testing account:
- //
-
- if (supportedOpSets3 == null || supportedOpSets3.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by " +
- "this implementation. ");
-
- opSetAHMUC3 = (OperationSetAdHocMultiUserChat) supportedOpSets3.get(
- OperationSetAdHocMultiUserChat.class.getName());
-
- if (opSetAHMUC3 == null)
- throw new NullPointerException(
- "No implementation for ad hoc multi user chat was found");
-
- opSetPresence3 = (OperationSetPresence) supportedOpSets3.get(
- OperationSetPresence.class.getName());
-
- if (opSetPresence3 == null)
- throw new NullPointerException(
- "An implementation of the service must provide an " +
- "implementation of at least one of the PresenceOperationSets");
- }
-
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetBasicInstantMessaging.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetBasicInstantMessaging.java
deleted file mode 100644
index 9b8fa7b..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetBasicInstantMessaging.java
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Performs testing of the basic instant messaging operation set. Tests include
- * going over basic functionality such as sending a message from the tested
- * implementation and asserting reception by the tester agent and vice versa.
- * @author Emil Ivov
- */
-public class TestOperationSetBasicInstantMessaging
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetBasicInstantMessaging.class);
-
- private YahooSlickFixture fixture = new YahooSlickFixture();
-
- private OperationSetBasicInstantMessaging opSetBasicIM1 = null;
- private OperationSetBasicInstantMessaging opSetBasicIM2 = null;
-
- private OperationSetPresence opSetPresence1 = null;
- private OperationSetPresence opSetPresence2 = null;
-
- public TestOperationSetBasicInstantMessaging(String name)
- {
- super(name);
- }
-
- /**
- * Get a reference to the basic IM operation set.
- * @throws Exception if this is not a good day.
- */
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- opSetBasicIM1 =
- (OperationSetBasicInstantMessaging)supportedOperationSets1.get(
- OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM1 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
- //we also need the presence op set in order to retrieve contacts.
- opSetPresence1 =
- (OperationSetPresence)supportedOperationSets1.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if ( supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- opSetBasicIM2 =
- (OperationSetBasicInstantMessaging)supportedOperationSets2.get(
- OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM2 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
- opSetPresence2 =
- (OperationSetPresence) supportedOperationSets2.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- fixture.tearDown();
- }
-
- /**
- * Creates a test suite containing tests of this class in a specific order.
- * We'll first execute tests beginning with the "test" prefix and then go to
- * ordered tests.We first execture tests for receiving messagese, so that
- * a volatile contact is created for the sender. we'll then be able to
- * retrieve this volatile contact and send them a message on our turn.
- * We need to do things this way as the contact corresponding to the tester
- * agent has been removed in the previous test and we no longer have it
- * in our contact list.
- *
- * @return Test a testsuite containing all tests to execute.
- */
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new TestOperationSetBasicInstantMessaging(
- "prepareContactList"));
-
- suite.addTestSuite(TestOperationSetBasicInstantMessaging.class);
-
- //the following 2 need to be run in the specified order.
- suite.addTest(new TestOperationSetBasicInstantMessaging(
- "firstTestReceiveMessage"));
- suite.addTest(new TestOperationSetBasicInstantMessaging(
- "thenTestSendMessage"));
-
- return suite;
- }
-
- /**
- * Create the list to be sure that contacts exchanging messages
- * exists in each other lists
- * @throws Exception
- */
- public void prepareContactList()
- throws Exception
- {
- fixture.clearProvidersLists();
-
- Object o = new Object();
- synchronized(o)
- {
- o.wait(2000);
- }
-
- try
- {
- opSetPresence1.subscribe(fixture.userID2);
- }
- catch (OperationFailedException ex)
- {
- // the contact already exist its OK
- }
-
- try
- {
- opSetPresence2.subscribe(fixture.userID1);
- }
- catch (OperationFailedException ex1)
- {
- // the contact already exist its OK
- }
-
- synchronized(o)
- {
- o.wait(2000);
- }
- }
-
- /**
- * Send an instant message from the tested operation set and assert
- * reception by the tester agent.
- */
- public void firstTestReceiveMessage()
- {
- ContactGroup rootGroup
- = ((OperationSetPersistentPresence)opSetPresence2).getServerStoredContactListRoot();
-
- logger.debug("=========== Server Stored Contact List =================");
-
- logger.debug("rootGroup="+rootGroup.getGroupName()
- +" rootGroup.childContacts="+rootGroup.countContacts()
- + "rootGroup.childGroups="+rootGroup.countSubgroups()
- + "Printing rootGroupContents=\n"+rootGroup.toString());
-
- String body = "This is an IM coming from the tester agent"
- + " on " + new Date().toString();
-
- ImEventCollector evtCollector = new ImEventCollector();
-
- //add a msg listener and register to the op set and send an instant
- //msg from the tester agent.
- opSetBasicIM1.addMessageListener(evtCollector);
-
- Contact testerAgentContact
- = opSetPresence2.findContactByID(fixture.userID1);
-
- logger.debug("Will send message " + body + " to: " + testerAgentContact);
-
- opSetBasicIM2.sendInstantMessage(testerAgentContact,
- opSetBasicIM2.createMessage(body));
-
- evtCollector.waitForEvent(10000);
-
- opSetBasicIM1.removeMessageListener(evtCollector);
-
- //assert reception of a message event
- assertTrue( "No events delivered upon a received message"
- , evtCollector.collectedEvents.size() > 0);
-
- //assert event instance of Message Received Evt
- assertTrue( "Received evt was not an instance of "
- + MessageReceivedEvent.class.getName()
- , evtCollector.collectedEvents.get(0)
- instanceof MessageReceivedEvent);
-
- //assert source contact == testAgent.uin
- MessageReceivedEvent evt
- = (MessageReceivedEvent)evtCollector.collectedEvents.get(0);
- assertEquals("message sender "
- , evt.getSourceContact().getAddress()
- , fixture.userID2);
-
- //assert messageBody == body
- assertEquals("message body", body, evt.getSourceMessage().getContent());
- }
-
- /**
- * Send an instant message from the tester agent and assert reception by
- * the tested implementation
- */
- public void thenTestSendMessage()
- {
- String body = "This is an IM coming from the tested implementation"
- + " on " + new Date().toString();
-
- //create the message
- net.java.sip.communicator.service.protocol.Message msg
- = opSetBasicIM1.createMessage(body);
-
- //register a listener in the op set
- ImEventCollector imEvtCollector1 = new ImEventCollector();
- opSetBasicIM1.addMessageListener(imEvtCollector1);
-
- //register a listener in the tester agent
- ImEventCollector imEvtCollector2 = new ImEventCollector();
- opSetBasicIM2.addMessageListener(imEvtCollector2);
-
- Contact testerAgentContact
- = opSetPresence1.findContactByID(fixture.userID2);
-
- opSetBasicIM1.sendInstantMessage(testerAgentContact, msg);
-
- imEvtCollector1.waitForEvent(10000);
- imEvtCollector2.waitForEvent(10000);
-
- opSetBasicIM1.removeMessageListener(imEvtCollector1);
- opSetBasicIM2.removeMessageListener(imEvtCollector2);
-
- //verify that the message delivered event was dispatched
- assertTrue( "No events delivered when sending a message"
- , imEvtCollector1.collectedEvents.size() > 0);
-
- assertTrue( "Received evt was not an instance of "
- + MessageDeliveredEvent.class.getName()
- , imEvtCollector1.collectedEvents.get(0)
- instanceof MessageDeliveredEvent);
-
- MessageDeliveredEvent evt
- = (MessageDeliveredEvent)imEvtCollector1.collectedEvents.get(0);
- assertEquals("message destination "
- , evt.getDestinationContact().getAddress()
- , fixture.userID2);
-
- assertSame("source message", msg, evt.getSourceMessage());
-
-
- //verify that the message has successfully arived at the destination
- assertTrue( "No messages received by the tester agent"
- , imEvtCollector2.collectedEvents.size() > 0);
- String receivedBody =
- ((MessageReceivedEvent)imEvtCollector2.collectedEvents
- .get(0)).getSourceMessage().getContent();
-
- assertEquals("received message body", msg.getContent(), receivedBody);
- }
-
- /**
- * Creates an Message through the simple createMessage() method and inspects
- * its parameters.
- */
- public void testCreateMessage1()
- {
- String body = "This is an IM coming from the tested implementation"
- + " on " + new Date().toString();
- net.java.sip.communicator.service.protocol.Message msg
- = opSetBasicIM1.createMessage(body);
-
- assertEquals("message body", body, msg.getContent());
- assertTrue("message body bytes"
- , Arrays.equals(body.getBytes(), msg.getRawData()));
- assertEquals("message length", body.length(), msg.getSize());
- assertEquals("message content type"
- , OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE
- , msg.getContentType());
-
- assertEquals("message encoding"
- , OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING
- , msg.getEncoding());
-
- assertNotNull("message uid", msg.getMessageUID());
-
- //a further test on message uid.
- net.java.sip.communicator.service.protocol.Message msg2
- = opSetBasicIM1.createMessage(body);
- assertFalse("message uid", msg.getMessageUID().equals(
- msg2.getMessageUID()));
- }
-
- /**
- * Creates an Message through the advance createMessage() method and
- * inspects its parameters.
- */
- public void testCreateMessage2()
- throws UnsupportedEncodingException
- {
- String body = "This is an IM coming from the tested implementation"
- + " on " + new Date().toString();
- String contentType = "text/html";
- String encoding = "UTF-16";
- String subject = "test message";
- net.java.sip.communicator.service.protocol.Message msg =
- opSetBasicIM1.createMessage(body, contentType, encoding, subject);
- byte[] bodyBytes = body.getBytes(encoding);
-
- assertEquals("message body", body, msg.getContent());
- assertTrue("message body bytes"
- , Arrays.equals(bodyBytes, msg.getRawData()));
- assertEquals("message length", bodyBytes.length, msg.getSize());
- assertEquals("message content type", contentType, msg.getContentType());
- assertEquals("message encoding", encoding, msg.getEncoding());
- assertNotNull("message uid", msg.getMessageUID());
-
- //a further test on message uid.
- net.java.sip.communicator.service.protocol.Message msg2
- = opSetBasicIM1.createMessage(body);
- assertFalse("message uid", msg.getMessageUID().equals(
- msg2.getMessageUID()));
- }
-
- /**
- * Collects instant messaging events.
- */
- private class ImEventCollector implements MessageListener
- {
- private List<EventObject> collectedEvents = new LinkedList<EventObject>();
- /**
- * Called when a new incoming <tt>Message</tt> has been received.
- * @param evt the <tt>MessageReceivedEvent</tt> containing the newly
- * received message, its sender and other details.
- */
- public void messageReceived(MessageReceivedEvent evt)
- {
- logger.debug("Received a MessageReceivedEvent: " + evt);
-
- synchronized(this)
- {
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Called to indicated that delivery of a message sent earlier has failed.
- * Reason code and phrase are contained by the <tt>MessageFailedEvent</tt>
- * @param evt the <tt>MessageFailedEvent</tt> containing the ID of the
- * message whose delivery has failed.
- */
- public void messageDeliveryFailed(MessageDeliveryFailedEvent evt)
- {
- logger.debug("Received a MessageDeliveryFailedEvent: " + evt);
-
- synchronized(this)
- {
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
-
- /**
- * Called when the underlying implementation has received an indication
- * that a message, sent earlier has been successfully received by the
- * destination.
- * @param evt the MessageDeliveredEvent containing the id of the message
- * that has caused the event.
- */
- public void messageDelivered(MessageDeliveredEvent evt)
- {
- logger.debug("Received a MessageDeliveredEvent: " + evt);
-
- synchronized(this)
- {
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whichever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this)
- {
-
- if(collectedEvents.size() > 0)
- {
- logger.trace("ImEvent already received. " + collectedEvents);
- return;
- }
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a message evt", ex);
- }
- }
- }
- }
-
- /**
- * A method that would simply send messages to a group of people so that
- * they would get notified that tests are being run.
- */
- public void testSendFunMessages()
- {
- String hostname = "";
-
- try{
- hostname = java.net.InetAddress.getLocalHost().getHostName() + ": ";
- }catch (UnknownHostException ex){}
-
- String message = hostname
- + "Hello this is the SIP Communicator (version "
- + System.getProperty("sip-communicator.version")
- + ") build on: "
- + new Date().toString()
- + ". Have a very nice day!";
-
- String list = System.getProperty("accounts.reporting.YAHOO_REPORT_LIST");
-
- logger.debug("Will send message " + message + " to: " + list);
-
- //if no property is specified - return
- if(list == null || list.trim().length() == 0)
- return;
-
- StringTokenizer tokenizer = new StringTokenizer(list, " ");
-
- while(tokenizer.hasMoreTokens())
- {
- String contactID = tokenizer.nextToken();
- Contact contact
- = opSetPresence2.findContactByID(contactID);
-
- if(contact == null)
- {
- try
- {
- opSetPresence2.subscribe(contactID);
- Object o = new Object();
- synchronized (o)
- {
- o.wait(2000);
- }
- }
- catch (Exception ex1)
- {
- continue;
- }
- }
-
- contact
- = opSetPresence2.findContactByID(contactID);
-
- opSetBasicIM2.sendInstantMessage(contact,
- opSetBasicIM2.createMessage(message));
- }
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetFileTransferImpl.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetFileTransferImpl.java
deleted file mode 100644
index 90a2ff3..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetFileTransferImpl.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * Implementation for generic file transfer.
- * @author Damian Minkov
- */
-public class TestOperationSetFileTransferImpl
- extends TestOperationSetFileTransfer
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetFileTransferImpl.class);
-
- private YahooSlickFixture fixture = new YahooSlickFixture();
-
- private OperationSetPresence opSetPresence1 = null;
- private OperationSetPresence opSetPresence2 = null;
-
- private OperationSetFileTransfer opSetFT1 = null;
- private OperationSetFileTransfer opSetFT2 = null;
-
- private static Contact contact1 = null;
- private static Contact contact2 = null;
-
- @Override
- public Contact getContact1()
- {
- if(contact1 == null)
- {
- contact1 = opSetPresence1.findContactByID(fixture.userID2);
- }
-
- return contact1;
- }
-
- @Override
- public Contact getContact2()
- {
- if(contact2 == null)
- {
- contact2 = opSetPresence2.findContactByID(fixture.userID1);
- }
-
- return contact2;
- }
-
- @Override
- public void start()
- throws Exception
- {
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //we also need the presence op set in order to retrieve contacts.
- opSetPresence1 =
- (OperationSetPresence)supportedOperationSets1.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- opSetFT1 =
- (OperationSetFileTransfer)supportedOperationSets1.get(
- OperationSetFileTransfer.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetFT1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the FileTransferOperationSets");
- }
-
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if ( supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- opSetPresence2 =
- (OperationSetPresence) supportedOperationSets2.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- opSetFT2 =
- (OperationSetFileTransfer)supportedOperationSets2.get(
- OperationSetFileTransfer.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetFT2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the FileTransferOperationSets");
- }
-
- prepareContactList();
- }
-
- @Override
- public void stop()
- throws Exception
- {
- fixture.tearDown();
- }
-
- /**
- * Create the list to be sure that contacts exchanging messages
- * exists in each other lists
- * @throws Exception
- */
- public void prepareContactList()
- throws Exception
- {
- // clear the provider the first time we run a filetransfer list
- if(getContact1() == null && getContact2() == null)
- fixture.clearProvidersLists();
-
- if(getContact1() == null)
- {
- Object o = new Object();
- synchronized(o)
- {
- o.wait(2000);
- }
-
- try
- {
- opSetPresence1.setAuthorizationHandler(new AuthHandler());
- opSetPresence1.subscribe(fixture.userID2);
- }
- catch (OperationFailedException ex)
- {
- // the contact already exist its OK
- }
- }
-
- if(getContact2() == null)
- {
- try
- {
- opSetPresence2.setAuthorizationHandler(new AuthHandler());
- opSetPresence2.subscribe(fixture.userID1);
- }
- catch (OperationFailedException ex1)
- {
- // the contact already exist its OK
- }
-
- logger.info("will wait till the list prepare is completed");
- Object o = new Object();
- synchronized(o)
- {
- o.wait(4000);
- }
- }
- }
-
- @Override
- public OperationSetFileTransfer getOpSetFilTransfer1()
- {
- return opSetFT1;
- }
-
- @Override
- public OperationSetFileTransfer getOpSetFilTransfer2()
- {
- return opSetFT2;
- }
-
- @Override
- public BundleContext getContext()
- {
- return AdHocMultiUserChatSlickFixture.bc;
- }
-
- @Override
- public boolean enableTestSendAndReceive()
- {
- return true;
- }
-
- @Override
- public boolean enableTestSenderCancelBeforeAccepted()
- {
- return true;
- }
-
- @Override
- public boolean enableTestReceiverDecline()
- {
- return true;
- }
-
- @Override
- public boolean enableTestReceiverCancelsWhileTransfering()
- {
- return true;
- }
-
- @Override
- public boolean enableTestSenderCancelsWhileTransfering()
- {
- return true;
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPersistentPresence.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPersistentPresence.java
deleted file mode 100644
index 2ebf0e6..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPersistentPresence.java
+++ /dev/null
@@ -1,582 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * @author Damian Minkov
- */
-public class TestOperationSetPersistentPresence
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetPersistentPresence.class);
-
- private YahooSlickFixture fixture = new YahooSlickFixture();
- private OperationSetPersistentPresence opSetPersPresence1 = null;
- private OperationSetPersistentPresence opSetPersPresence2 = null;
- private static final String testGroupName = "NewGroup";
- private static final String testGroupName2 = "Renamed";
-
- public TestOperationSetPersistentPresence(String name)
- {
- super(name);
- }
-
- /**
- * Creates a test suite containing all tests of this class followed by
- * test methods that we want executed in a specified order.
- * @return the Test suite to run
- */
- public static Test suite()
- {
- TestSuite suite =
- new TestSuite();
-
- //the following 2 need to be run in the specified order.
- //(postTestRemoveGroup() needs the group created from
- //postTestCreateGroup() )
- suite.addTest(
- new TestOperationSetPersistentPresence("postTestCreateGroup"));
-
- //rename
- //suite.addTest( new TestOperationSetPersistentPresence(
- // "postTestRenameGroup"));
-
- suite.addTest(
- new TestOperationSetPersistentPresence("postTestRemoveGroup"));
-
- // create the contact list
- suite.addTest(
- new TestOperationSetPersistentPresence("prepareContactList"));
-
- suite.addTestSuite(TestOperationSetPersistentPresence.class);
-
- return suite;
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this Yahoo implementation. ");
-
- //get the operation set presence here.
- opSetPersPresence1 =
- (OperationSetPersistentPresence)supportedOperationSets1.get(
- OperationSetPersistentPresence.class.getName());
-
- //if still null then the implementation doesn't offer a presence
- //operation set which is unacceptable for yahoo.
- if (opSetPersPresence1 == null)
- throw new NullPointerException(
- "An implementation of the Yahoo service must provide an "
- + "implementation of at least the one of the Presence "
- + "Operation Sets");
-
- // lets do it once again for the second provider
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if (supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- + "this Yahoo implementation. ");
-
- //get the operation set presence here.
- opSetPersPresence2 =
- (OperationSetPersistentPresence) supportedOperationSets2.get(
- OperationSetPersistentPresence.class.getName());
-
- //if still null then the implementation doesn't offer a presence
- //operation set which is unacceptable for yahoo.
- if (opSetPersPresence2 == null)
- throw new NullPointerException(
- "An implementation of the yahoo service must provide an "
- + "implementation of at least the one of the Presence "
- + "Operation Sets");
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- fixture.tearDown();
- super.tearDown();
- }
-
- /**
- * Retrieves a server stored contact list and checks whether it contains
- * all contacts that have been added there during the initialization
- * phase by the testerAgent.
- */
- public void testRetrievingServerStoredContactList()
- {
- ContactGroup rootGroup
- = opSetPersPresence1.getServerStoredContactListRoot();
-
- logger.debug("=========== Server Stored Contact List =================");
-
- logger.debug("rootGroup="+rootGroup.getGroupName()
- +" rootGroup.childContacts="+rootGroup.countContacts()
- + "rootGroup.childGroups="+rootGroup.countSubgroups()
- + "Printing rootGroupContents=\n"+rootGroup.toString());
-
- Hashtable<String, List<String>> expectedContactList
- = AdHocMultiUserChatSlickFixture.preInstalledBuddyList;
-
- logger.debug("============== Expected Contact List ===================");
- logger.debug(expectedContactList);
-
- //Go through the contact list retrieved by the persistence presence set
- //and remove the name of every contact and group that we find there from
- //the expected contct list hashtable.
- Iterator<ContactGroup> groups = rootGroup.subgroups();
- while (groups.hasNext() )
- {
- ContactGroup group = groups.next();
-
- List<String> expectedContactsInGroup
- = expectedContactList.get(group.getGroupName());
-
- // When sending the offline message
- // the sever creates a group NotInContactList,
- // because the buddy we are sending message to is not in
- // the contactlist. So this group must be ignored
- // Also we must ignore the group created by default
- // from the yahoo lib
- if(!group.getGroupName().equals("NotInContactList") &&
- !group.getGroupName().equals("Default group"))
- {
- assertNotNull("Group " + group.getGroupName() +
- " was returned by "
- +
- "the server but was not in the expected contact list."
- , expectedContactsInGroup);
-
- Iterator<Contact> contactsIter = group.contacts();
- while(contactsIter.hasNext())
- {
- String contactID = contactsIter.next().getAddress();
- expectedContactsInGroup.remove(contactID);
- }
-
- //If we've removed all the sub contacts, remove the group too.
- if(expectedContactsInGroup.size() == 0)
- expectedContactList.remove(group.getGroupName());
- }
- }
-
- //whatever we now have in the expected contact list snapshot are groups,
- //that have been added by the testerAgent but that were not retrieved
- //by the persistent presence operation set.
- assertTrue("The following contacts were on the server sidec contact "
- +"list, but were not returned by the pers. pres. op. set"
- + expectedContactList.toString()
- , expectedContactList.isEmpty());
- }
-
- /**
- * Creates a group in the server stored contact list, makes sure that the
- * corresponding event has been generated and verifies that the group is
- * in the list.
- *
- * @throws java.lang.Exception
- */
- public void postTestCreateGroup()
- throws Exception
- {
- // first clear the list
- fixture.clearProvidersLists();
-
- waitFor(5000);
-
- logger.trace("testing creation of server stored groups");
- //first add a listener
- GroupChangeCollector groupChangeCollector = new GroupChangeCollector();
- opSetPersPresence1
- .addServerStoredGroupChangeListener(groupChangeCollector);
-
- //create the group
- opSetPersPresence1.createServerStoredContactGroup(
- opSetPersPresence1.getServerStoredContactListRoot(), testGroupName);
-
- groupChangeCollector.waitForEvent(10000);
-
- opSetPersPresence1
- .removeServerStoredGroupChangeListener(groupChangeCollector);
-
- // check whether we got group created event
- assertEquals("Collected Group Change events: ",
- 1, groupChangeCollector.collectedEvents.size());
-
- assertEquals("Group name.", testGroupName,
- ((ServerStoredGroupEvent)groupChangeCollector.collectedEvents
- .get(0)).getSourceGroup().getGroupName());
-
- // check whether the group is retrievable
- ContactGroup group = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName);
-
- assertNotNull("A newly created group was not in the contact list.",
- group);
-
- assertEquals("New group name", testGroupName, group.getGroupName());
-
- // when opearting with groups . the group must have entries
- // so changes to take effect. Otherwise group will be lost after loggingout
- try
- {
- opSetPersPresence1.subscribe(group, fixture.userID2);
-
- waitFor(1500);
- }
- catch (Exception ex)
- {
- fail("error adding entry to group : " +
- group.getGroupName() + " " +
- ex.getMessage());
- }
- }
-
-
- /**
- * Removes the group created in the server stored contact list by the create
- * group test, makes sure that the corresponding event has been generated
- * and verifies that the group is not in the list any more.
- */
- public void postTestRemoveGroup()
- {
- logger.trace("testing removal of server stored groups");
-
- //first add a listener
- GroupChangeCollector groupChangeCollector = new GroupChangeCollector();
- opSetPersPresence1
- .addServerStoredGroupChangeListener(groupChangeCollector);
-
- try
- {
- //remove the group
- opSetPersPresence1.removeServerStoredContactGroup(
- opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName));
- }
- catch(OperationFailedException ex)
- {
- logger.error("error removing group", ex);
- }
-
- groupChangeCollector.waitForEvent(10000);
-
- opSetPersPresence1
- .removeServerStoredGroupChangeListener(groupChangeCollector);
-
- // check whether we got group created event
- assertEquals("Collected Group Change event",
- 1, groupChangeCollector.collectedEvents.size());
-
- assertEquals("Group name.", testGroupName,
- ((ServerStoredGroupEvent)groupChangeCollector.collectedEvents
- .get(0)).getSourceGroup().getGroupName());
-
- // check whether the group is still on the contact list
- ContactGroup group = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName);
-
- assertNull("A freshly removed group was still on the contact list. - " + group,
- group);
- }
-
- /**
- * Renames our test group and checks whether corresponding events are
- * triggered. Verifies whether the group has really changed its name and
- * whether it is findable by its new name. Also makes sure that it does
- * not exist under its previous name any more.
- */
- public void postTestRenameGroup()
- {
- logger.trace("Testing renaming groups.");
-
- ContactGroup group = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName);
-
- //first add a listener
- GroupChangeCollector groupChangeCollector = new GroupChangeCollector();
- opSetPersPresence1
- .addServerStoredGroupChangeListener(groupChangeCollector);
-
- //change the name and wait for a confirmation event
- opSetPersPresence1.renameServerStoredContactGroup(group, testGroupName2);
-
- groupChangeCollector.waitForEvent(10000);
-
- opSetPersPresence1
- .removeServerStoredGroupChangeListener(groupChangeCollector);
-
- //examine the event
- assertEquals("Collected Group Change event",
- 1, groupChangeCollector.collectedEvents.size());
-
- assertEquals("Group name.", testGroupName2,
- ((ServerStoredGroupEvent)groupChangeCollector.collectedEvents
- .get(0)).getSourceGroup().getGroupName());
-
- // check whether the group is still on the contact list
- ContactGroup oldGroup = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName);
-
- assertNull("A group was still findable by its old name after renaming.",
- oldGroup);
-
- //make sure that we could find the group by its new name.
- ContactGroup newGroup = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName2);
-
- assertNotNull("Could not find a renamed group by its new name.",
- newGroup);
- }
-
- /**
- * Create the contact list. Later will be test to be sure that creating is ok
- * @throws Exception
- */
- public void prepareContactList()
- throws Exception
- {
- logger.trace("prepareContactList");
-
- fixture.clearProvidersLists();
-
- waitFor(3000);
-
- String contactList = System.getProperty(
- YahooProtocolProviderServiceLick.CONTACT_LIST_PROPERTY_NAME, null);
-
- logger.debug("The "
- + YahooProtocolProviderServiceLick.CONTACT_LIST_PROPERTY_NAME
- + " property is set to=" + contactList);
-
- if( contactList == null
- || contactList.trim().length() < 6)//at least 4 for a UIN, 1 for the
- // dot and 1 for the grp name
- throw new IllegalArgumentException(
- "The " +
- YahooProtocolProviderServiceLick.CONTACT_LIST_PROPERTY_NAME +
- " property did not contain a contact list.");
- StringTokenizer tokenizer = new StringTokenizer(contactList, " \n\t");
-
- logger.debug("tokens contained by the CL tokenized="
- +tokenizer.countTokens());
-
- Hashtable<String, List<String>> contactListToCreate = new Hashtable<String, List<String>>();
-
- //go over all group.uin tokens
- while (tokenizer.hasMoreTokens())
- {
- String groupUinToken = tokenizer.nextToken();
- int dotIndex = groupUinToken.indexOf(".");
-
- if ( dotIndex == -1 )
- {
- throw new IllegalArgumentException(groupUinToken
- + " is not a valid Group.UIN token");
- }
-
- String groupName = groupUinToken.substring(0, dotIndex);
- String uin = groupUinToken.substring(dotIndex + 1);
-
- if( groupName.trim().length() < 1
- || uin.trim().length() < 4 )
- {
- throw new IllegalArgumentException(
- groupName + " or " + uin +
- " are not a valid group name or yahoo UIN.");
- }
-
- //check if we've already seen this group and if not - add it
- List<String> uinInThisGroup = contactListToCreate.get(groupName);
- if (uinInThisGroup == null)
- {
- uinInThisGroup = new ArrayList<String>();
- contactListToCreate.put(groupName, uinInThisGroup);
- }
-
- uinInThisGroup.add(uin);
- }
-
- // now init the list
- Enumeration<String> newGroupsEnum = contactListToCreate.keys();
-
- GroupChangeCollector groupChangeCollector = new GroupChangeCollector();
- opSetPersPresence1.addServerStoredGroupChangeListener(groupChangeCollector);
-
- //go over all groups in the contactsToAdd table
- while (newGroupsEnum.hasMoreElements())
- {
- String groupName = newGroupsEnum.nextElement();
- logger.debug("Will add group " + groupName);
-
- opSetPersPresence1.createServerStoredContactGroup(
- opSetPersPresence1.getServerStoredContactListRoot(), groupName);
-
- groupChangeCollector.waitForEvent(3000);
-
- ContactGroup newlyCreatedGroup =
- opSetPersPresence1.getServerStoredContactListRoot().getGroup(groupName);
-
- Iterator<String> contactsToAddToThisGroup
- = contactListToCreate.get(groupName).iterator();
- while (contactsToAddToThisGroup.hasNext())
- {
- String id = contactsToAddToThisGroup.next();
-
- logger.debug("Will add buddy " + id);
- opSetPersPresence1.subscribe(newlyCreatedGroup, id);
- }
- }
-
- waitFor(4000);
-
- //store the created contact list for later reference
- YahooSlickFixture.preInstalledBuddyList = contactListToCreate;
- }
-
- private void waitFor(long time)
- throws Exception
- {
- Object o = new Object();
- synchronized(o)
- {
- o.wait(time);
- }
- }
-
- /**
- * The class would listen for and store received events delivered to
- * <tt>ServerStoredGroupListener</tt>s.
- */
- private class GroupChangeCollector implements ServerStoredGroupListener
- {
- public ArrayList<EventObject> collectedEvents = new ArrayList<EventObject>();
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whicever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this)
- {
- if(collectedEvents.size() > 0)
- return;
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
-
- /**
- * Called whnever an indication is received that a new server stored
- * group is created.
- * @param evt a ServerStoredGroupChangeEvent containing a reference to
- * the newly created group.
- */
- public void groupCreated(ServerStoredGroupEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Called when an indication is received that the name of a server stored
- * contact group has changed.
- * @param evt a ServerStoredGroupChangeEvent containing the details of the
- * name change.
- */
- public void groupNameChanged(ServerStoredGroupEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Called whnever an indication is received that an existing server stored
- * group has been removed.
- * @param evt a ServerStoredGroupChangeEvent containing a reference to the
- * newly created group.
- */
- public void groupRemoved(ServerStoredGroupEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Called whnever an indication is received that an existing server
- * stored group has been resolved.
- * @param evt a ServerStoredGroupChangeEvent containing a reference to
- * the resolved group.
- */
- public void groupResolved(ServerStoredGroupEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPresence.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPresence.java
deleted file mode 100644
index 1413a42..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetPresence.java
+++ /dev/null
@@ -1,1003 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import java.beans.*;
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.service.protocol.yahooconstants.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Tests yahoo implementations of a Presence Operation Set. Tests in this class
- * verify functionality such as: Changing local (our own) status and
- * corresponding event dispatching; Querying status of contacts, Subscribing
- * for presence notifications upong status changes of specific contacts.
- * <p>
- * Using a custom suite() method, we make sure that apart from standard test
- * methods (those with a <tt>test</tt> prefix) we also execute those that
- * we want run in a specific order like for example - postTestSubscribe() and
- * postTestUnsubscribe().
- * <p>
- * @author Damian Minkov
- */
-public class TestOperationSetPresence
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetPresence.class);
-
- private YahooSlickFixture fixture = new YahooSlickFixture();
- private OperationSetPresence operationSetPresence1 = null;
- private OperationSetPresence operationSetPresence2 = null;
-
- private AuthHandler authHandler1 = null;
- private AuthHandler authHandler2 = null;
-
- public TestOperationSetPresence(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- operationSetPresence1 =
- (OperationSetPresence)supportedOperationSets1.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null then the implementation doesn't offer a presence
- //operation set which is unacceptable for yahoo.
- if (operationSetPresence1 == null)
- {
- throw new NullPointerException(
- "An implementation of the yahoo service must provide an "
- + "implementation of at least the one of the Presence "
- + "Operation Sets");
- }
-
- // do it once again for the second provider
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if ( supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this yahoo implementation. ");
-
- //get the operation set presence here.
- operationSetPresence2 =
- (OperationSetPresence)supportedOperationSets2.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null then the implementation doesn't offer a presence
- //operation set which is unacceptable for yahoo.
- if (operationSetPresence2 == null)
- {
- throw new NullPointerException(
- "An implementation of the yahoo service must provide an "
- + "implementation of at least the one of the Presence "
- + "Operation Sets");
- }
-
- if(authHandler1 == null)
- {
- authHandler1 = new AuthHandler(operationSetPresence1);
- operationSetPresence1.setAuthorizationHandler(authHandler1);
- }
-
- if(authHandler2 == null)
- {
- authHandler2 = new AuthHandler(operationSetPresence2);
- operationSetPresence2.setAuthorizationHandler(authHandler2);
- }
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- fixture.tearDown();
- }
-
- /**
- * Creates a test suite containing all tests of this class followed by
- * test methods that we want executed in a specified order.
- * @return Test
- */
- public static Test suite()
- {
- //return an (almost) empty suite if we're running in offline mode.
- if(YahooSlickFixture.onlineTestingDisabled)
- {
- TestSuite suite = new TestSuite();
- //the only test around here that we could run without net
- //connectivity
- suite.addTest(
- new TestOperationSetPresence(
- "testSupportedStatusSetForCompleteness"));
- return suite;
- }
-
- TestSuite suite = new TestSuite();
-
- // clear the lists before subscribing users
- suite.addTest(new TestOperationSetPresence("clearLists"));
-
- // first postTestSubscribe. to be sure that contacts are in the
- // list so we can further continue and test presences each other
- suite.addTest(new TestOperationSetPresence("postTestSubscribe"));
-
- // add other tests
- suite.addTestSuite(TestOperationSetPresence.class);
-
- // now test unsubscribe
- suite.addTest(new TestOperationSetPresence("postTestUnsubscribe"));
-
- return suite;
- }
-
- /**
- * Verifies that all necessary yahoo test states are supported by the
- * implementation.
- */
- public void testSupportedStatusSetForCompleteness()
- {
- //first create a local list containing the presence status instances
- //supported by the underlying implementation.
- Iterator<PresenceStatus> supportedStatusSetIter =
- operationSetPresence1.getSupportedStatusSet();
-
- List<PresenceStatus> supportedStatusSet
- = new LinkedList<PresenceStatus>();
- while (supportedStatusSetIter.hasNext()){
- supportedStatusSet.add(supportedStatusSetIter.next());
- }
-
- //create a copy of the MUST status set and remove any matching status
- //that is also present in the supported set.
- List<?> requiredStatusSetCopy
- = (List<?>) YahooStatusEnum.yahooStatusSet.clone();
-
- requiredStatusSetCopy.removeAll(supportedStatusSet);
-
- //if we have anything left then the implementation is wrong.
- int unsupported = requiredStatusSetCopy.size();
- assertTrue( "There are " + unsupported + " statuses as follows:"
- + requiredStatusSetCopy,
- unsupported == 0);
- }
-
- /**
- * Verify that changing state to STEPPED_OUT works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToSteppedOut() throws Exception
- {
- subtestStateTransition(YahooStatusEnum.STEPPED_OUT);
- }
-
- /**
- * Verify that changing state to NOT_IN_OFFICE works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToNotInOffice() throws Exception
- {
- subtestStateTransition(YahooStatusEnum.NOT_IN_OFFICE);
- }
-
- /**
- * Verify that changing state to BUSY works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToBusy() throws Exception
- {
- subtestStateTransition(YahooStatusEnum.BUSY);
- }
-
- /**
- * Verify that changing state to FREE_FOR_CHAT works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToIdle() throws Exception
- {
- subtestStateTransition(YahooStatusEnum.IDLE);
- }
-
- /**
- * Verify that changing state to BE_RIGHT_BACK works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToBRB() throws Exception
- {
- subtestStateTransition(YahooStatusEnum.BE_RIGHT_BACK);
- }
-
- /**
- * Verify that changing state to OUT_TO_LUNCH works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToOutToLunch() throws Exception
- {
- subtestStateTransition(YahooStatusEnum.OUT_TO_LUNCH);
- }
-
- /**
- * Verify that changing state to ON_THE_PHONE works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToOnThePhone() throws Exception
- {
- subtestStateTransition(YahooStatusEnum.ON_THE_PHONE);
- }
-
- /**
- * Used by methods testing state transiotions
- *
- * @param newStatus the YahooStatusEnum field corresponding to the status
- * that we'd like the opeation set to enter.
- *
- * @throws Exception in case changing the state causes an exception
- */
- public void subtestStateTransition( YahooStatusEnum newStatus)
- throws Exception
- {
- logger.trace(" --=== beginning state transition test ===--");
-
- PresenceStatus oldStatus = operationSetPresence2.getPresenceStatus();
-
- logger.debug( "old status is=" + oldStatus.getStatusName()
- + " new status=" + newStatus.getStatusName()
- + " for contact : " + fixture.userID2);
-
- //First register a listener to make sure that all corresponding
- //events have been generated.
- PresenceStatusEventCollector statusEventCollector2
- = new PresenceStatusEventCollector();
- ContactPresenceEventCollector statusEventCollector1
- = new ContactPresenceEventCollector(fixture.userID2, newStatus);
- operationSetPresence2.addProviderPresenceStatusListener(
- statusEventCollector2);
- operationSetPresence1.addContactPresenceStatusListener(
- statusEventCollector1);
-
- //change the status
- operationSetPresence2.publishPresenceStatus(newStatus, null);
-
- //test event notification.
- statusEventCollector2.waitForPresEvent(10000);
- statusEventCollector1.waitForEvent(10000);
-
- operationSetPresence2.removeProviderPresenceStatusListener(
- statusEventCollector2);
- operationSetPresence1.removeContactPresenceStatusListener(
- statusEventCollector1);
-
- assertEquals("Events dispatched during an event transition.",
- 1, statusEventCollector2.collectedPresEvents.size());
- assertEquals("A status changed event contained wrong old status.",
- oldStatus,
- ((ProviderPresenceStatusChangeEvent)
- statusEventCollector2.collectedPresEvents.get(0))
- .getOldStatus());
- assertEquals("A status changed event contained wrong new status.",
- newStatus,
- ((ProviderPresenceStatusChangeEvent)
- statusEventCollector2.collectedPresEvents.get(0))
- .getNewStatus());
-
- // verify that the operation set itself is aware of the status change
- assertEquals("opSet.getPresenceStatus() did not return properly.",
- newStatus,
- operationSetPresence2.getPresenceStatus());
-
- YahooStatusEnum actualStatus = (YahooStatusEnum)
- operationSetPresence1.queryContactStatus(fixture.userID2);
-
- assertEquals("The underlying implementation did not switch to the "
- +"requested presence status.",
- newStatus,
- actualStatus);
-
- logger.trace(" --=== finished test ===--");
- }
-
- /**
- * The method would add a subscription for a contact, wait for a
- * subscription event confirming the subscription, then change the status
- * of the newly added contact (which is actually the testerAgent) and
- * make sure that the corresponding notification events have been generated.
- *
- * @throws java.lang.Exception if an exception occurs during testing.
- */
- public void postTestSubscribe()
- throws Exception
- {
- logger.debug("Testing Subscription and Subscription Event Dispatch.");
-
- dumplists();
-
- SubscriptionEventCollector subEvtCollector
- = new SubscriptionEventCollector();
- operationSetPresence1.addSubscriptionListener(subEvtCollector);
-
-
- synchronized (subEvtCollector){
- operationSetPresence1.subscribe(fixture.userID2);
- //we may already have the event, but it won't hurt to check.
- subEvtCollector.waitForEvent(10000);
- operationSetPresence1.removeSubscriptionListener(subEvtCollector);
- }
-
- assertEquals("Subscription event dispatching failed."
- , 1, subEvtCollector.collectedEvents.size());
- SubscriptionEvent subEvt =
- (SubscriptionEvent)subEvtCollector.collectedEvents.get(0);
-
- assertEquals("SubscriptionEvent Source:",
- fixture.userID2,
- ((Contact)subEvt.getSource()).getAddress());
- assertEquals("SubscriptionEvent Source Contact:",
- fixture.userID2,
- subEvt.getSourceContact().getAddress());
- assertSame("SubscriptionEvent Source Provider:",
- fixture.provider1,
- subEvt.getSourceProvider());
-
- subEvtCollector.collectedEvents.clear();
-
- // make the user agent tester change its states and make sure we are
- // notified
- logger.debug("Testing presence notifications.");
- YahooStatusEnum oldStatus
- = (YahooStatusEnum)operationSetPresence2.getPresenceStatus();
-
-
- YahooStatusEnum newStatus = YahooStatusEnum.ON_THE_PHONE;
-
- //in case we are by any chance already in a ON_THE_PHONE status, we'll
- //be changing to something else
- if(oldStatus.equals(newStatus)){
- newStatus = YahooStatusEnum.BUSY;
- }
-
- //now do the actual status notification testing
- ContactPresenceEventCollector contactPresEvtCollector
- = new ContactPresenceEventCollector(
- fixture.userID2, newStatus);
- operationSetPresence1.addContactPresenceStatusListener(
- contactPresEvtCollector);
-
- synchronized (contactPresEvtCollector){
- operationSetPresence2.publishPresenceStatus(newStatus, "new status");
- //we may already have the event, but it won't hurt to check.
- contactPresEvtCollector.waitForEvent(10000);
- operationSetPresence1
- .removeContactPresenceStatusListener(contactPresEvtCollector);
- }
-
- // something happened. the friend is not added correctly will
- // try to remove it and add it again
- if(contactPresEvtCollector.collectedEvents.size() == 0)
- {
- logger.info("ATTENTION: Yahoo friend not added correctly will remove and add him again");
-
- // remove it
- operationSetPresence1.unsubscribe(subEvt.getSourceContact());
-
- // wait remove to be finished
- Object lock = new Object();
- synchronized(lock){
- try{
- lock.wait(3000);
- }catch (Exception e){}
- }
-
- // add it
- operationSetPresence1.addSubscriptionListener(subEvtCollector);
- subEvtCollector.collectedEvents.clear();
- synchronized (subEvtCollector){
- operationSetPresence1.subscribe(fixture.userID2);
- //we may already have the event, but it won't hurt to check.
- subEvtCollector.waitForEvent(10000);
- operationSetPresence1.removeSubscriptionListener(subEvtCollector);
- }
- subEvtCollector.collectedEvents.clear();
-
- if(newStatus.equals(YahooStatusEnum.BUSY)){
- newStatus = YahooStatusEnum.OUT_TO_LUNCH;
- }
- else
- newStatus = YahooStatusEnum.BUSY;
-
- // query it again for the status
- contactPresEvtCollector = new ContactPresenceEventCollector(
- fixture.userID2, newStatus);
- operationSetPresence1.addContactPresenceStatusListener(
- contactPresEvtCollector);
-
- synchronized (contactPresEvtCollector){
-// operationSetPresence2.publishPresenceStatus(newStatus, "new status");
- operationSetPresence2.publishPresenceStatus(newStatus, null);
- //we may already have the event, but it won't hurt to check.
- contactPresEvtCollector.waitForEvent(10000);
- operationSetPresence1
- .removeContactPresenceStatusListener(contactPresEvtCollector);
- }
- }
-
- assertEquals("Presence Notif. event dispatching failed."
- , 1, contactPresEvtCollector.collectedEvents.size());
- ContactPresenceStatusChangeEvent presEvt =
- (ContactPresenceStatusChangeEvent)
- contactPresEvtCollector.collectedEvents.get(0);
-
- assertEquals("Presence Notif. event Source:",
- fixture.userID2,
- ((Contact)presEvt.getSource()).getAddress());
- assertEquals("Presence Notif. event Source Contact:",
- fixture.userID2,
- presEvt.getSourceContact().getAddress());
- assertSame("Presence Notif. event Source Provider:",
- fixture.provider1,
- presEvt.getSourceProvider());
-
- PresenceStatus reportedNewStatus = presEvt.getNewStatus();
- PresenceStatus reportedOldStatus = presEvt.getOldStatus();
-
- assertEquals( "Reported new PresenceStatus: ",
- newStatus, reportedNewStatus );
-
- //don't require equality between the reported old PresenceStatus and
- //the actual presence status of the tester agent because a first
- //notification is not supposed to have the old status as it really was.
- assertNotNull( "Reported old PresenceStatus: ", reportedOldStatus );
-
- try
- {
- // add the the user to the reverse side needed for status tests
- subEvtCollector.collectedEvents.clear();
- operationSetPresence2.addSubscriptionListener(subEvtCollector);
-
- synchronized (subEvtCollector)
- {
- operationSetPresence2.subscribe(fixture.userID1);
- //we may already have the event, but it won't hurt to check.
- subEvtCollector.waitForEvent(10000);
- operationSetPresence2.removeSubscriptionListener(
- subEvtCollector);
- }
- }
- catch (OperationFailedException ex)
- {
- // happens if the user is already subscribed
- }
- }
-
- /**
- * We unsubscribe from presence notification deliveries concerning
- * testerAgent's presence status and verify that we receive the
- * subscription removed event. We then make the tester agent change status
- * and make sure that no notifications are delivered.
- *
- * @throws java.lang.Exception in case unsubscribing fails.
- */
- public void postTestUnsubscribe()
- throws Exception
- {
- logger.debug("Testing Unsubscribe and unsubscription event dispatch.");
-
- // First create a subscription and verify that it really gets created.
- SubscriptionEventCollector subEvtCollector
- = new SubscriptionEventCollector();
- operationSetPresence1.addSubscriptionListener(subEvtCollector);
-
- Contact yahooTesterAgentContact = operationSetPresence1
- .findContactByID(fixture.userID2);
-
- assertNotNull(
- "Failed to find an existing subscription for the tester agent"
- , yahooTesterAgentContact);
-
- synchronized(subEvtCollector){
- operationSetPresence1.unsubscribe(yahooTesterAgentContact);
- subEvtCollector.waitForEvent(10000);
- //don't want any more events
- operationSetPresence1.removeSubscriptionListener(subEvtCollector);
- }
-
- assertEquals("Subscription event dispatching failed."
- , 1, subEvtCollector.collectedEvents.size());
- SubscriptionEvent subEvt =
- (SubscriptionEvent)subEvtCollector.collectedEvents.get(0);
-
- assertEquals("SubscriptionEvent Source:",
- yahooTesterAgentContact, subEvt.getSource());
-
- assertEquals("SubscriptionEvent Source Contact:",
- yahooTesterAgentContact, subEvt.getSourceContact());
-
- assertSame("SubscriptionEvent Source Provider:",
- fixture.provider1,
- subEvt.getSourceProvider());
-
- subEvtCollector.collectedEvents.clear();
-
- // make the user agent tester change its states and make sure we don't
- // get notifications as we're now unsubscribed.
- logger.debug("Testing (lack of) presence notifications.");
- YahooStatusEnum oldStatus
- = (YahooStatusEnum)operationSetPresence2.getPresenceStatus();
- YahooStatusEnum newStatus = YahooStatusEnum.ON_THE_PHONE;
-
- //in case we are by any chance already in a ON_THE_PHONE status, we'll
- //be changing to something else
- if(oldStatus.equals(newStatus)){
- newStatus = YahooStatusEnum.BUSY;
- }
-
- //now do the actual status notification testing
- ContactPresenceEventCollector contactPresEvtCollector
- = new ContactPresenceEventCollector(fixture.userID2, null);
- operationSetPresence1.addContactPresenceStatusListener(
- contactPresEvtCollector);
-
- synchronized (contactPresEvtCollector){
- operationSetPresence2.publishPresenceStatus(newStatus, "new status");
-
- //we may already have the event, but it won't hurt to check.
- contactPresEvtCollector.waitForEvent(10000);
- operationSetPresence1
- .removeContactPresenceStatusListener(contactPresEvtCollector);
- }
-
- assertEquals("Presence Notifications were received after unsubscibing."
- , 0, contactPresEvtCollector.collectedEvents.size());
- }
-
- public void clearLists()
- throws Exception
- {
- logger.debug("Clear the two lists before tests");
-
- // wait a moment if any event hes left from the previous tests
- Object o = new Object();
- synchronized(o)
- {
- o.wait(2000);
- }
-
- // wait for a moment
- // give time the impl to get the lists
- logger.debug("start clearing");
- fixture.clearProvidersLists();
-
- synchronized(o)
- {
- o.wait(3000);
- }
- }
-
- /**
- * An event collector that would collect all events generated by a
- * provider after a status change. The collector would also do a notidyAll
- * every time it receives an event.
- */
- private class PresenceStatusEventCollector
- implements ProviderPresenceStatusListener
- {
- public ArrayList<EventObject> collectedPresEvents = new ArrayList<EventObject>();
- public ArrayList<EventObject> collectedStatMsgEvents = new ArrayList<EventObject>();
-
- public void providerStatusChanged(ProviderPresenceStatusChangeEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedPresEvents.size()+")= "+evt);
- collectedPresEvents.add(evt);
- notifyAll();
- }
- }
-
- public void providerStatusMessageChanged(PropertyChangeEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected stat.msg. evt("
- +collectedPresEvents.size()+")= "+evt);
- collectedStatMsgEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whicever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForPresEvent(long waitFor)
- {
- logger.trace("Waiting for a change in provider status.");
- synchronized(this)
- {
- if(collectedPresEvents.size() > 0){
- logger.trace("Change already received. " + collectedPresEvents);
- return;
- }
-
- try{
- wait(waitFor);
- if(collectedPresEvents.size() > 0)
- logger.trace("Received a change in provider status.");
- else
- logger.trace("No change received for "+waitFor+"ms.");
- }
- catch (InterruptedException ex){
- logger.debug("Interrupted while waiting for a provider evt"
- , ex);
- }
- }
- }
-
- /**
- * Blocks until at least one staus message event is received or until
- * waitFor miliseconds pass (whichever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for a status message event before simply bailing out.
- */
- public void waitForStatMsgEvent(long waitFor)
- {
- logger.trace("Waiting for a provider status message event.");
- synchronized(this)
- {
- if(collectedStatMsgEvents.size() > 0){
- logger.trace("Stat msg. evt already received. "
- + collectedStatMsgEvents);
- return;
- }
-
- try{
- wait(waitFor);
- if(collectedStatMsgEvents.size() > 0)
- logger.trace("Received a prov. stat. msg. evt.");
- else
- logger.trace("No prov. stat msg. received for "
- +waitFor+"ms.");
- }
- catch (InterruptedException ex){
- logger.debug("Interrupted while waiting for a status msg evt"
- , ex);
- }
- }
- }
- }
-
- /**
- * The class would listen for and store received subscription modification
- * events.
- */
- private class SubscriptionEventCollector implements SubscriptionListener
- {
- public ArrayList<EventObject> collectedEvents = new ArrayList<EventObject>();
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whicever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this)
- {
- if(collectedEvents.size() > 0)
- {
- logger.trace("Event already received. " + collectedEvents);
- return;
- }
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionCreated(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionRemoved(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void contactModified(ContactPropertyChangeEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionMoved(SubscriptionMovedEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionFailed(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionResolved(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- }
-
- /**
- * The class would listen for and store received events caused by changes
- * in contact presence states.
- */
- private class ContactPresenceEventCollector
- implements ContactPresenceStatusListener
- {
- public ArrayList<EventObject> collectedEvents = new ArrayList<EventObject>();
- private String trackedScreenName = null;
- private YahooStatusEnum status = null;
-
- ContactPresenceEventCollector(String screenname,
- YahooStatusEnum wantedStatus)
- {
- this.trackedScreenName = screenname;
- this.status = wantedStatus;
- }
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whicever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this)
- {
- if(collectedEvents.size() > 0)
- return;
-
- try{
- wait(waitFor);
- if(collectedEvents.size() > 0)
- logger.trace("Received a change in contact status.");
- else
- logger.trace("No change received for "+waitFor+"ms.");
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
-
- /**
- * Stores the received status change event and notifies all waiting on
- * this object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void contactPresenceStatusChanged(
- ContactPresenceStatusChangeEvent evt)
- {
- synchronized(this)
- {
- //if the user has specified event details and the received
- //event does not match - then ignore it.
- if( this.trackedScreenName != null
- && !evt.getSourceContact().getAddress()
- .equals(trackedScreenName))
- return;
- if( status != null
- && status != evt.getNewStatus())
- return;
-
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
- }
-
- /**
- * AuthorizationHandler which accepts all requests!
- */
- private class AuthHandler
- implements AuthorizationHandler
- {
- private OperationSetPresence opset = null;
- AuthHandler(OperationSetPresence opset)
- {
- this.opset = opset;
- }
-
- public AuthorizationResponse processAuthorisationRequest(
- AuthorizationRequest req, Contact sourceContact)
- {
-// try{
-// opset.subscribe(sourceContact.getAddress());
-// }catch(Exception ex){}
-
- return
- new AuthorizationResponse(AuthorizationResponse.ACCEPT, "");
- }
- public AuthorizationRequest createAuthorizationRequest(Contact contact )
- {
- return new AuthorizationRequest();
- }
- public void processAuthorizationResponse(
- AuthorizationResponse response, Contact sourceContact){}
- }
-
- private void dumplists()
- {
- // just wait a little all modification events to be received
- Object o = new Object();
- synchronized(o)
- {
- try{o.wait(3000);}catch (InterruptedException ex){}
- }
-
- OperationSetPersistentPresence op1 = (OperationSetPersistentPresence)operationSetPresence1;
- OperationSetPersistentPresence op2 = (OperationSetPersistentPresence)operationSetPresence2;
-
- logger.info("------------ START DUMP LIST " + fixture.userID1 + " ------------");
- ContactGroup rootGroup = op1.getServerStoredContactListRoot();
- Iterator<ContactGroup> groups = rootGroup.subgroups();
- while (groups.hasNext() )
- {
- ContactGroup group = groups.next();
- logger.info("group " + group.getGroupName());
-
- Iterator<Contact> contactsIter = group.contacts();
- while(contactsIter.hasNext())
- {
- logger.info("\tcontact " + contactsIter.next());
- }
- }
- logger.info("------------ END DUMP LIST " + fixture.userID1 + " ------------");
-
-
- logger.info("------------ START DUMP LIST " + fixture.userID2 + " ------------");
- rootGroup = op2.getServerStoredContactListRoot();
- groups = rootGroup.subgroups();
- while (groups.hasNext() )
- {
- ContactGroup group = groups.next();
- logger.info("group " + group.getGroupName());
-
- Iterator<Contact> contactsIter = group.contacts();
- while(contactsIter.hasNext())
- {
- logger.info("\tcontact " + contactsIter.next());
- }
- }
- logger.info("------------ END DUMP LIST " + fixture.userID2 + " ------------");
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetTypingNotifications.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetTypingNotifications.java
deleted file mode 100644
index 5138fed..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestOperationSetTypingNotifications.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Tests functionality of the typing notifications operation set.
- *
- * @author Damian Minkov
- */
-public class TestOperationSetTypingNotifications
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetTypingNotifications.class);
-
- private YahooSlickFixture fixture = new YahooSlickFixture();
- private OperationSetTypingNotifications opSetTypingNotifs1 = null;
- private OperationSetPresence opSetPresence1 = null;
- private OperationSetTypingNotifications opSetTypingNotifs2 = null;
- private OperationSetPresence opSetPresence2 = null;
-
- private OperationSetBasicInstantMessaging opSetBasicIM1 = null;
- private OperationSetBasicInstantMessaging opSetBasicIM2 = null;
-
-
- public TestOperationSetTypingNotifications(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- opSetTypingNotifs1 =
- (OperationSetTypingNotifications)supportedOperationSets1.get(
- OperationSetTypingNotifications.class.getName());
-
- //if the op set is null then the implementation doesn't offer a typing.n
- //operation set which is unacceptable.
- if (opSetTypingNotifs1 == null)
- {
- throw new NullPointerException(
- "No implementation for typing notifications was found");
- }
-
- opSetBasicIM1 =
- (OperationSetBasicInstantMessaging)supportedOperationSets1.get(
- OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM1 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
-
- //we also need the presence op set in order to retrieve contacts.
- opSetPresence1 =
- (OperationSetPresence)supportedOperationSets1.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if ( supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- opSetTypingNotifs2 =
- (OperationSetTypingNotifications)supportedOperationSets2.get(
- OperationSetTypingNotifications.class.getName());
-
- //if the op set is null then the implementation doesn't offer a typing.n
- //operation set which is unacceptable for.
- if (opSetTypingNotifs2 == null)
- {
- throw new NullPointerException(
- "No implementation for typing notifications was found");
- }
-
- opSetBasicIM2 =
- (OperationSetBasicInstantMessaging)supportedOperationSets2.get(
- OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM2 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
-
- //we also need the presence op set in order to retrieve contacts.
- opSetPresence2 =
- (OperationSetPresence)supportedOperationSets2.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
- }
-
- /**
- * Create the list to be sure that contacts exchanging messages
- * exists in each other lists
- * @throws Exception
- */
- public void prepareContactList() throws Exception
- {
- // be sure that contacts are in their lists
- try{
- opSetPresence1.subscribe(fixture.userID2);
- }
- catch (OperationFailedException ex){
- // the contact already exist its OK
- }
-
- try{
- opSetPresence2.subscribe(fixture.userID1);
- }
- catch (OperationFailedException ex1){
- // the contact already exist its OK
- }
-
- Object o = new Object();
- synchronized (o)
- {
- o.wait(2000);
- }
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- fixture.tearDown();
- }
-
- /**
- * Creates a test suite containing tests of this class in a specific order.
- * We'll first execute a test where we receive a typing notification, and
- * a volatile contact is created for the sender. we'll then be able to
- * retrieve this volatile contact and them a notification on our turn.
- * We need to do things this way as the contact corresponding to the tester
- * agent has been removed in the previous test and we no longer have it
- * in our contact list.
- *
- * @return Test a testsuite containing all tests to execute.
- */
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new TestOperationSetTypingNotifications(
- "prepareContactList"));
-
- //the following 2 need to be run in the specified order.
- suite.addTest(new TestOperationSetTypingNotifications(
- "testTypingNotificationsEventDelivery"));
- return suite;
- }
-
- /**
- * Sends a typing notification and verifies
- * whether it is properly received by the tested implementation
- */
- public void testTypingNotificationsEventDelivery()
- {
- TypingEventCollector evtCollector = new TypingEventCollector();
-
- // send message so request for receiving notifications also to be set
- Contact notifingContact =
- opSetPresence1.findContactByID(fixture.userID2);
- opSetBasicIM1.sendInstantMessage(notifingContact,
- opSetBasicIM1.createMessage("ping"));
-
- opSetTypingNotifs1.addTypingNotificationsListener(evtCollector);
-
- Contact contactToNotify =
- opSetPresence2.findContactByID(fixture.userID1);
-
- opSetBasicIM2.sendInstantMessage(contactToNotify,
- opSetBasicIM2.createMessage("pong"));
-
- Object w = new Object();
- synchronized(w){try {w.wait(500);}catch (Exception e) {}}
-
- opSetTypingNotifs2.sendTypingNotification(
- contactToNotify, OperationSetTypingNotifications.STATE_TYPING);
-
- evtCollector.waitForEvent(10000);
-
- opSetTypingNotifs1.removeTypingNotificationsListener(evtCollector);
-
- //check event dispatching
- assertTrue("Number of typing events received was zero."
- , evtCollector.collectedEvents.size() > 0);
-
- TypingNotificationEvent evt = (TypingNotificationEvent)evtCollector
- .collectedEvents.get(0);
-
- assertEquals("Source of the typing notification event"
- , fixture.userID2
- , evt.getSourceContact().getAddress() );
-
- assertEquals("Source of the typing notification event"
- , OperationSetTypingNotifications.STATE_TYPING
- , evt.getTypingState());
- }
-
- /**
- * Simply collects allre received events and provides a mechanisim for
- * waiting for the next event.
- */
- private class TypingEventCollector implements TypingNotificationsListener
- {
- private List<EventObject> collectedEvents = new LinkedList<EventObject>();
- /**
- * Called to indicate that a remote <tt>Contact</tt> has sent us a typing
- * notification. The method adds the <tt>event</tt> to the list of
- * captured events.
- * @param event a <tt>TypingNotificationEvent</tt> containing the sender
- * of the notification and its type.
- */
- public void typingNotificationReceived(TypingNotificationEvent event)
- {
- logger.debug("Received a typing notification: " + event);
- synchronized (this)
- {
- collectedEvents.add(event);
- notifyAll();
- }
- }
-
- /**
- * Called to indicate that sending typing notification has failed.
- *
- * @param event a <tt>TypingNotificationEvent</tt> containing the sender
- * of the notification and its type.
- */
- public void typingNotificationDeliveryFailed(TypingNotificationEvent event)
- {}
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whicever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this){
-
- if(collectedEvents.size() > 0)
- return;
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex){
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/TestProtocolProviderServiceYahooImpl.java b/test/net/java/sip/communicator/slick/protocol/yahoo/TestProtocolProviderServiceYahooImpl.java
deleted file mode 100644
index 87c07f3..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/TestProtocolProviderServiceYahooImpl.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Performs testing on protocol provider methods.
- * @todo add more detailed docs once the tests are written.
- * @author Damian Minkov
- */
-public class TestProtocolProviderServiceYahooImpl
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestProtocolProviderServiceYahooImpl.class);
-
- private YahooSlickFixture fixture = new YahooSlickFixture();
-
- /**
- * An event adapter that would collec registation state change events
- */
- public RegistrationEventCollector regEvtCollector1
- = new RegistrationEventCollector();
-
- /**
- * An event adapter that would collec registation state change events
- */
- public RegistrationEventCollector regEvtCollector2
- = new RegistrationEventCollector();
-
- /**
- * An event adapter that would collec registation state change events
- */
- public RegistrationEventCollector regEvtCollector3
- = new RegistrationEventCollector();
-
- /**
- * Creates a test encapsulator for the method with the specified name.
- * @param name the name of the method this test should run.
- */
- public TestProtocolProviderServiceYahooImpl(String name)
- {
- super(name);
- }
-
- /**
- * Initializes the fixture.
- * @throws Exception if super.setUp() throws one.
- */
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
- }
-
- /**
- * Tears the fixture down.
- * @throws Exception if fixture.tearDown() fails.
- */
- @Override
- protected void tearDown() throws Exception
- {
- fixture.tearDown();
- super.tearDown();
- }
-
- /**
- * Makes sure that the instance of the Yahoo protocol provider that we're
- * going to use for testing is properly initialized and registered with
- * a Yahoo registrar. This MUST be called before any other online testing
- * of the Yahoo provider so that we won't have to reregister for every single
- * test.
- * <p>
- * The method also verifies that a registration event is fired upon
- * succesful registration and collected by our event collector.
- *
- * @throws OperationFailedException if provider.register() fails.
- */
- public void testRegister()
- throws OperationFailedException
- {
- //add an event collector that will collect all events during the
- //registration and allow us to later inspect them and make sure
- //they were properly dispatched.
- fixture.provider1.addRegistrationStateChangeListener(regEvtCollector1);
- fixture.provider2.addRegistrationStateChangeListener(regEvtCollector2);
-
- //register our three providers
- fixture.provider1.register(new SecurityAuthorityImpl(
- System.getProperty(YahooProtocolProviderServiceLick.ACCOUNT_1_PREFIX
- + ProtocolProviderFactory.PASSWORD).toCharArray()));
- fixture.provider2.register(new SecurityAuthorityImpl(
- System.getProperty(YahooProtocolProviderServiceLick.ACCOUNT_2_PREFIX
- + ProtocolProviderFactory.PASSWORD).toCharArray()));
-
- //give it enough time to register. We won't really have to wait all this
- //time since the registration event collector would notify us the moment
- //we get signed on.
- logger.debug("Waiting for registration to complete ...");
-
- regEvtCollector1.waitForEvent(15000);
- regEvtCollector2.waitForEvent(40000);
-
- //make sure that the registration process trigerred the corresponding
- //events.
- assertTrue(
- "No events were dispatched during the registration process."
- ,regEvtCollector1.collectedNewStates.size() > 0);
-
- assertTrue(
- "No registration event notifying of registration was dispatched. "
- +"All events were: " + regEvtCollector1.collectedNewStates
- ,regEvtCollector1.collectedNewStates
- .contains(RegistrationState.REGISTERED));
-
- //now the same for provider 2
- assertTrue(
- "No events were dispatched during the registration process "
- +"of provider2."
- ,regEvtCollector2.collectedNewStates.size() > 0);
-
- assertTrue(
- "No registration event notifying of registration was dispatched. "
- +"All events were: " + regEvtCollector2.collectedNewStates
- ,regEvtCollector2.collectedNewStates
- .contains(RegistrationState.REGISTERED));
-
- fixture.provider1
- .removeRegistrationStateChangeListener(regEvtCollector1);
- fixture.provider2
- .removeRegistrationStateChangeListener(regEvtCollector2);
- }
-
-
- /**
- * Verifies that all operation sets have the type they are declarded to
- * have.
- *
- * @throws java.lang.Exception if a class indicated in one of the keys
- * could not be forName()ed.
- */
- public void testOperationSetTypes() throws Exception
- {
- Map<String, OperationSet> supportedOperationSets =
- fixture.provider1.getSupportedOperationSets();
-
- // make sure that keys (which are supposed to be class names) correspond
- // what the class of the values recorded against them.
- for (Map.Entry<String, OperationSet> entry : supportedOperationSets
- .entrySet())
- {
- String setName = entry.getKey();
- Object opSet = entry.getValue();
-
- assertTrue(opSet + " was not an instance of " + setName
- + " as declared", Class.forName(setName).isInstance(opSet));
- }
- }
-
- /**
- * A class that would plugin as a registration listener to a protocol
- * provider and simply record all events that it sees and notifyAll()
- * if it sees an event that notifies us of a completed
- * registration.
- */
- public class RegistrationEventCollector
- implements RegistrationStateChangeListener
- {
- public List<RegistrationState> collectedNewStates = new LinkedList<RegistrationState>();
-
- /**
- * The method would simply register all received events so that they
- * could be available for later inspection by the unit tests. In the
- * case where a registraiton event notifying us of a completed
- * registration is seen, the method would call notifyAll().
- *
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- logger.debug("Received a RegistrationStateChangeEvent: " + evt);
-
- collectedNewStates.add(evt.getNewState());
-
- if (evt.getNewState().equals(RegistrationState.REGISTERED))
- {
- logger.debug("We're registered and will notify those who wait");
- synchronized (this)
- {
- notifyAll();
- }
- }
- }
-
- /**
- * Blocks until an event notifying us of the awaited state change is
- * received or until waitFor miliseconds pass (whichever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- logger.trace("Waiting for a RegistrationStateChangeEvent ");
-
- synchronized (this)
- {
- if (collectedNewStates.contains(RegistrationState.REGISTERED))
- {
- logger.trace("Event already received. "
- + collectedNewStates);
- return;
- }
-
- try
- {
- wait(waitFor);
-
- if (collectedNewStates.size() > 0)
- logger.trace(
- "Received a RegistrationStateChangeEvent.");
- else
- logger.trace(
- "No RegistrationStateChangeEvent received for "
- + waitFor + "ms.");
-
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a "
- +"RegistrationStateChangeEvent"
- , ex);
- }
- }
- }
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/YahooProtocolProviderServiceLick.java b/test/net/java/sip/communicator/slick/protocol/yahoo/YahooProtocolProviderServiceLick.java
deleted file mode 100644
index a9dc75d..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/YahooProtocolProviderServiceLick.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import java.util.*;
-
-import junit.framework.*;
-
-import org.osgi.framework.*;
-
-/**
- * Yahoo specific testing for a Yahoo Protocol Provider Service implementation.
- * The test suite registers three accounts for
- *
- * @author Damian Minkov
- * @author Valentin Martinet
- */
-public class YahooProtocolProviderServiceLick
- extends TestSuite
- implements BundleActivator
-{
- /**
- * The prefix used for property names containing settings for our first
- * testing account.
- */
- public static final String ACCOUNT_1_PREFIX
- = "accounts.yahoo.account1.";
-
- /**
- * The prefix used for property names containing settings for our second
- * testing account.
- */
- public static final String ACCOUNT_2_PREFIX
- = "accounts.yahoo.account2.";
-
- /**
- * The prefix used for property names containing settings for our third
- * testing account.
- */
- public static final String ACCOUNT_3_PREFIX
- = "accounts.yahoo.account3.";
-
- /**
- * The name of the property that indicates whether the user would like to
- * only run the offline tests.
- */
- public static final String DISABLE_ONLINE_TESTS_PROPERTY_NAME
- = "accounts.yahoo.DISABLE_ONLINE_TESTING";
-
- /**
- * The name of the property the value of which is a formatted string that
- * contains the contact list that.
- */
- public static final String CONTACT_LIST_PROPERTY_NAME
- = "accounts.yahoo.CONTACT_LIST";
-
- /**
- * Initializes and registers all tests that we'll run as a part of this
- * slick.
- *
- * @param context a currently valid bundle context.
- */
- public void start(BundleContext context)
- {
- setName("YahooProtocolProviderSlick");
-
- Hashtable<String, String> properties = new Hashtable<String, String>();
- properties.put("service.pid", getName());
-
- YahooSlickFixture.bc = context;
-
- // verify whether the user wants to avoid online testing
- String offlineMode = System.getProperty(
- DISABLE_ONLINE_TESTS_PROPERTY_NAME, null);
-
- if (offlineMode != null && offlineMode.equalsIgnoreCase("true"))
- YahooSlickFixture.onlineTestingDisabled = true;
-
-
- addTestSuite(TestAccountInstallation.class);
- addTestSuite(TestProtocolProviderServiceYahooImpl.class);
-
- addTest(TestOperationSetPresence.suite());
-
- //the following should only be run when we want online testing.
- if(!YahooSlickFixture.onlineTestingDisabled)
- {
- addTest(TestOperationSetPersistentPresence.suite());
-
- addTest(TestOperationSetBasicInstantMessaging.suite());
-
- addTest(TestOperationSetTypingNotifications.suite());
-
- addTestSuite(TestOperationSetFileTransferImpl.class);
-
- //addTest(TestOperationSetAdHocMultiUserChatYahooImpl.suite());
- }
-
- addTest(TestAccountUninstallation.suite());
- addTestSuite(TestAccountUninstallationPersistence.class);
-
- context.registerService(getClass().getName(), this, properties);
- }
-
- /**
- * Prepares the slick for shutdown.
- *
- * @param context a currently valid bundle context.
- */
- public void stop(BundleContext context)
- {
-
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/YahooSlickFixture.java b/test/net/java/sip/communicator/slick/protocol/yahoo/YahooSlickFixture.java
deleted file mode 100644
index 88d36f5..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/YahooSlickFixture.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * 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.
- */
-package net.java.sip.communicator.slick.protocol.yahoo;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-
-import org.osgi.framework.*;
-
-/**
- * Contains fields and methods used by most or all tests in the yahoo slick.
- *
- * @author Damian Minkov
- * @author Valentin Martinet
- */
-public class YahooSlickFixture
- extends AdHocMultiUserChatSlickFixture
-{
- /**
- * Constructor
- */
- public YahooSlickFixture()
- {
- super();
- }
-
- /**
- * Initializes protocol provider references and whatever else there is to
- * initialize.
- *
- * @throws InvalidSyntaxException in case we meet problems while retrieving
- * protocol providers through OSGI
- */
- @Override
- public void setUp() throws InvalidSyntaxException
- {
- // first obtain a reference to the provider factory
- ServiceReference[] serRefs = null;
- String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL
- + "="+ProtocolNames.YAHOO+")";
- try{
- serRefs = bc.getServiceReferences(
- ProtocolProviderFactory.class.getName(), osgiFilter);
- }
- catch (InvalidSyntaxException ex){
- //this really shouldhn't occur as the filter expression is static.
- fail(osgiFilter + " is not a valid osgi filter");
- }
-
- assertTrue(
- "Failed to find a provider factory service for protocol yahoo",
- (serRefs != null) && (serRefs.length > 0));
-
- //Keep the reference for later usage.
- providerFactory = (ProtocolProviderFactory)bc.getService(serRefs[0]);
-
- userID1 =
- System.getProperty(
- YahooProtocolProviderServiceLick.ACCOUNT_1_PREFIX
- + ProtocolProviderFactory.USER_ID);
-
- userID2 =
- System.getProperty(
- YahooProtocolProviderServiceLick.ACCOUNT_2_PREFIX
- + ProtocolProviderFactory.USER_ID);
-
- userID3 =
- System.getProperty(
- YahooProtocolProviderServiceLick.ACCOUNT_3_PREFIX
- + ProtocolProviderFactory.USER_ID);
-
- //find the protocol providers exported for the three accounts
- ServiceReference[] yahooProvider1Refs
- = bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- +"("+ProtocolProviderFactory.PROTOCOL+"="+ProtocolNames.YAHOO+")"
- +"("+ProtocolProviderFactory.USER_ID+"="
- + userID1 +")"
- +")");
-
- //make sure we found a service
- assertNotNull("No Protocol Provider was found for yahoo account1:"
- + userID1
- , yahooProvider1Refs);
- assertTrue("No Protocol Provider was found for yahoo account1:"+userID1,
- yahooProvider1Refs.length > 0);
-
- ServiceReference[] yahooProvider2Refs
- = bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- +"("+ProtocolProviderFactory.PROTOCOL+"="+ProtocolNames.YAHOO+")"
- +"("+ProtocolProviderFactory.USER_ID+"="
- + userID2 +")"
- +")");
-
- //again make sure we found a service.
- assertNotNull("No Protocol Provider was found for yahoo account2:"
- + userID2
- , yahooProvider2Refs);
- assertTrue("No Protocol Provider was found for yahoo account2:"+userID2,
- yahooProvider2Refs.length > 0);
-
- ServiceReference[] yahooProvider3Refs
- = bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- +"("+ProtocolProviderFactory.PROTOCOL+"="+ProtocolNames.YAHOO+")"
- +"("+ProtocolProviderFactory.USER_ID+"="
- + userID3 +")"
- +")");
-
- //again make sure we found a service.
- assertNotNull("No Protocol Provider was found for yahoo account3:"
- + userID3
- , yahooProvider3Refs);
- assertTrue("No Protocol Provider was found for yahoo account2:"+userID3,
- yahooProvider3Refs.length > 0);
-
- //save the service for other tests to use.
- provider1ServiceRef = yahooProvider1Refs[0];
- provider1 = (ProtocolProviderService)bc.getService(provider1ServiceRef);
- provider2ServiceRef = yahooProvider2Refs[0];
- provider2 = (ProtocolProviderService)bc.getService(provider2ServiceRef);
- provider3ServiceRef = yahooProvider3Refs[0];
- provider3 = (ProtocolProviderService)bc.getService(provider3ServiceRef);
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/yahoo/yahoo.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/yahoo/yahoo.provider.slick.manifest.mf
deleted file mode 100644
index e57e344..0000000
--- a/test/net/java/sip/communicator/slick/protocol/yahoo/yahoo.provider.slick.manifest.mf
+++ /dev/null
@@ -1,17 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.slick.protocol.yahoo.YahooProtocolProviderServiceLick
-Bundle-Name: Yahoo Protocol Provider Service Leveraging Implementation Compatibility Kit
-Bundle-Description: A Service Leveraging Implementation Compatibility Kit for the Yahoo implementation of the ProtocolProvider Service
-Bundle-Vendor: sip-communicator.org
-Bundle-Version: 0.0.1
-System-Bundle: yes
-Import-Package: org.jitsi.service.configuration,
- junit.framework,
- org.osgi.framework,
- javax.net.ssl,
- javax.xml.parsers,
- net.java.sip.communicator.util,
- net.java.sip.communicator.service.dns,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.yahooconstants,
- net.java.sip.communicator.service.protocol.event,
- org.jitsi.service.fileaccess