Intermediat commit on SIP Support (Work in Progress!)

give the user the option not to run online tests (so that they run the rest more often)
cusax-fix
Emil Ivov 20 years ago
parent 37ae553cc8
commit 11076d63d2

@ -28,8 +28,68 @@ accounts.icq.TESTING_IMPL_PWD=
# for the tested account implementation. The value of the CONTACT_LIST property
# must be a space separated string containing elements each of which is in the
# format: GroupName.UIN
#
#
# VERY IMPORTANT!!! All other users in this contact list will be removed and
# the contacts and contact groups enumerated beneath will be added instead
accounts.icq.CONTACT_LIST=
# list of icq accounts to notify during testing (optional)
# accounts.reporting.ICQ_REPORT_LIST=
# if for some reasone you want not to run online icq tests (e.g. because they
# take an awful lot to complete). set this property to true (optional)
# accounts.icq.DISABLE_ONLINE_TESTING
#
# SIP PROPERTIES
#
# ACCOUNT 1
# The user id needed to log onto the server specified in the SERVER_ADDRESS
# property.
accounts.sip.account1.USER_ID=
# The password (in plain text) needed to log the user specified in USER_ID
# on the server specified in SERVER_ADDRESS.
accounts.sip.account1.PASSWORD=
# The address of the server that this account belongs to (Use '[', ']' for IPv6)
accounts.sip.account1.SERVER_ADDRESS=
# A port numer to use when connecting to the proxy specified in SERVER_ADDRESS
# (Optional)
accounts.sip.account1.SERVER_PORT=
# The address of the SIP Proxy to use with this account(Use '[', ']' for IPv6)
# (Optional)
accounts.sip.account1.PROXY_ADDRESS=
# A port numer to use when connecting to the proxy specified in PROXY_ADDRESS
# (Optional)
accounts.sip.account1.PROXY_PORT=
# ACCOUNT 2
# The user id needed to log onto the server specified in the SERVER_ADDRESS
# property.
accounts.sip.account2.USER_ID=
# The password (in plain text) needed to log the user specified in USER_ID
# on the server specified in SERVER_ADDRESS.
accounts.sip.account2.PASSWORD=
# The address of the server that this account belongs to (Use '[', ']' for IPv6)
accounts.sip.account2.SERVER_ADDRESS=
# A port numer to use when connecting to the proxy specified in SERVER_ADDRESS
# (Optional)
accounts.sip.account2.SERVER_PORT=
# The address of the SIP Proxy to use with this account(Use '[', ']' for IPv6)
# (Optional)
accounts.sip.account2.PROXY_ADDRESS=
# A port numer to use when connecting to the proxy specified in PROXY_ADDRESS
# (Optional)
accounts.sip.account2.PROXY_PORT=

@ -49,6 +49,13 @@ public class IcqProtocolProviderSlick
public static final String CONTACT_LIST_PROPERTY_NAME
= "accounts.icq.CONTACT_LIST";
/**
* 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.icq.DISABLE_ONLINE_TESTING";
/**
* Start the ICQ Sevice Leveraging Implementation Compatibility Kit.
*
@ -64,13 +71,20 @@ public void start(BundleContext bundleContext) throws Exception
//store the bundle cache reference for usage by other others
IcqSlickFixture.bc = bundleContext;
// 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"))
IcqSlickFixture.onlineTestingDisabled = true;
// identify our testing agent on icq - it MUST be defined.
String icqTestAgentName = System.getProperty(
TESTING_IMPL_USER_ID_PROP_NAME, null);
// we can only set up the real icq test suites when the
// accounts.properties file defines the two test accounts
if (icqTestAgentName != null) {
if ( icqTestAgentName != null ) {
//it is defined, so register our testing agent on icq.
IcqSlickFixture.testerAgent =
new IcqTesterAgent(icqTestAgentName);
@ -82,26 +96,30 @@ public void start(BundleContext bundleContext) throws Exception
// .. and try to register the icq test agent (online)
if (IcqSlickFixture.testerAgent.register(icqTestAgentPwd)) {
IcqSlickFixture.testerAgent.setAuthorizationRequired();
//initialize the tested account's contact list so that
//it could be ready when testing starts.
initializeTestedContactList();
if(!IcqSlickFixture.onlineTestingDisabled)
{
IcqSlickFixture.testerAgent.setAuthorizationRequired();
//initialize the tested account's contact list so that
//it could be ready when testing starts.
initializeTestedContactList();
//As Tested account is not registered here we send him a message.
//Message will be delivered offline. receive test is in
// TestOperationSetBasicInstantMessaging.testReceiveOfflineMessages()
String offlineMsgBody =
//As Tested account is not registered here we send him a
//message. Message will be delivered offline. receive test
//is in TestOperationSetBasicInstantMessaging
// .testReceiveOfflineMessages()
String offlineMsgBody =
"This is a Test Message. "
+"Supposed to be delivered as offline message!";
IcqSlickFixture.offlineMsgCollector =
+ "Supposed to be delivered as offline message!";
IcqSlickFixture.offlineMsgCollector =
new IcqSlickFixture.OfflineMsgCollector();
IcqSlickFixture.offlineMsgCollector.setMessageText(offlineMsgBody);
IcqSlickFixture.testerAgent.sendOfflineMessage(
System.getProperty(TESTED_IMPL_USER_ID_PROP_NAME, null),
offlineMsgBody
);
IcqSlickFixture.offlineMsgCollector.setMessageText(
offlineMsgBody);
IcqSlickFixture.testerAgent.sendOfflineMessage(
System.getProperty(TESTED_IMPL_USER_ID_PROP_NAME, null),
offlineMsgBody);
}
//First test account installation so that the service that has
//been installed by it gets tested by the rest of the tests.
@ -113,13 +131,17 @@ public void start(BundleContext bundleContext) throws Exception
addTest(TestOperationSetPresence.suite());
addTest(TestOperationSetPersistentPresence.suite());
//the following should only be run when we want online testing.
if(!IcqSlickFixture.onlineTestingDisabled)
{
addTest(TestOperationSetPersistentPresence.suite());
addTest(TestOperationSetBasicInstantMessaging.suite());
addTest(TestOperationSetBasicInstantMessaging.suite());
addTest(TestOperationSetTypingNotifications.suite());
addTest(TestOperationSetTypingNotifications.suite());
addTest(TestOperationSetServerStoredInfo.suite());
addTest(TestOperationSetServerStoredInfo.suite());
}
//This must remain after all other tests using the accounts
//are done since it tests account uninstallation and the
@ -141,8 +163,8 @@ public void start(BundleContext bundleContext) throws Exception
// accounts.properties file probably missing - it defines the
// two test accounts required for most unit tests
// so install a single test to fail in a meaningful way
addTest(
new TestAccountInvalidNotification("failIcqTesterAgentMissing"));
addTest( new TestAccountInvalidNotification(
"failIcqTesterAgentMissing"));
}
@ -220,10 +242,13 @@ private void initializeTestedContactList()
uinInThisGroup.add(uin);
}
//we don't need to continue if online testing is disabled since
//the following won't be of any use.
if(IcqSlickFixture.onlineTestingDisabled)
return;
//Create a tester agent that would connect with the tested impl account
//and initialize the contact list according to what we just parsed.
IcqTesterAgent cListInitTesterAgent = new IcqTesterAgent(
System.getProperty(TESTED_IMPL_USER_ID_PROP_NAME, null)
);

@ -63,6 +63,12 @@ public class IcqSlickFixture extends TestCase
public static OfflineMsgCollector offlineMsgCollector = null;
/**
* Indicates whether the user has requested for onlline tests not to be run.
* (e.g. due to lack of network connectivity or ... time constraints ;)).
*/
public static boolean onlineTestingDisabled = false;
public void setUp() throws Exception
{
// first obtain a reference to the provider factory
@ -79,7 +85,7 @@ public void setUp() throws Exception
}
assertTrue(
"Failed to find an provider factory service for protocol ICQ",
"Failed to find a provider factory service for protocol ICQ",
serRefs != null || serRefs.length > 0);
//Keep the reference for later usage.

@ -104,7 +104,8 @@ public class IcqTesterAgent
*/
public boolean register(String password)
{
if(registered)
if(registered
|| IcqSlickFixture.onlineTestingDisabled)
return true;
DefaultAppSession session = new DefaultAppSession();

@ -59,10 +59,15 @@ protected void tearDown() throws Exception
public static Test suite()
{
TestSuite suite = new TestSuite();
suite.addTest(
new TestAccountInstallation("testRegisterWrongUsername"));
suite.addTest(
new TestAccountInstallation("testRegisterWrongPassword"));
if (!IcqSlickFixture.onlineTestingDisabled)
{
suite.addTest(
new TestAccountInstallation("testRegisterWrongUsername"));
suite.addTest(
new TestAccountInstallation("testRegisterWrongPassword"));
}
suite.addTest(
new TestAccountInstallation("testInstallAccount"));
@ -90,7 +95,7 @@ public void testRegisterWrongUsername()
}
assertTrue(
"Failed to find an provider factory service for protocol ICQ",
"Failed to find a provider factory service for protocol ICQ",
serRefs != null || serRefs.length > 0);
//Keep the reference for later usage.
@ -212,7 +217,7 @@ public void testRegisterWrongPassword()
}
assertTrue(
"Failed to find an provider factory service for protocol ICQ",
"Failed to find a provider factory service for protocol ICQ",
serRefs != null || serRefs.length > 0);
//Keep the reference for later usage.
@ -328,7 +333,7 @@ public void testInstallAccount()
}
assertTrue(
"Failed to find an provider factory service for protocol ICQ",
"Failed to find a provider factory service for protocol ICQ",
serRefs != null || serRefs.length > 0);
//Keep the reference for later usage.

@ -64,6 +64,8 @@ protected void tearDown() throws Exception
public static Test suite()
{
TestSuite suite = new TestSuite();
if(! IcqSlickFixture.onlineTestingDisabled)
suite.addTest(
new TestAccountUninstallation("testMultipleLogins"));
suite.addTest(

@ -92,6 +92,18 @@ protected void tearDown() throws Exception
*/
public static Test suite()
{
//return an (almost) empty suite if we're running in offline mode.
if(IcqSlickFixture.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(TestOperationSetPresence.class);
//the following 2 need to be run in the specified order.

@ -49,17 +49,29 @@ public class TestProtocolProviderServiceIcqImpl extends TestCase
public RegistrationEventCollector regEvtCollector
= 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 TestProtocolProviderServiceIcqImpl(String name)
{
super(name);
}
/**
* Initializes the fixture.
* @throws Exception if super.setUp() throws one.
*/
protected void setUp() throws Exception
{
super.setUp();
fixture.setUp();
}
/**
* Tears the fixture down.
* @throws Exception if fixture.tearDown() fails.
*/
protected void tearDown() throws Exception
{
fixture.tearDown();
@ -77,15 +89,18 @@ protected void tearDown() throws Exception
public static Test suite()
{
TestSuite suite = new TestSuite();
suite.addTest(
new TestProtocolProviderServiceIcqImpl("testRegister"));
suite.addTest(
new TestProtocolProviderServiceIcqImpl("testIsRegistered"));
suite.addTest(
new TestProtocolProviderServiceIcqImpl("testGetRegistrationState"));
suite.addTest(
new TestProtocolProviderServiceIcqImpl("testOperationSetTypes"));
if(!IcqSlickFixture.onlineTestingDisabled)
{
suite.addTest(
new TestProtocolProviderServiceIcqImpl("testRegister"));
suite.addTest(
new TestProtocolProviderServiceIcqImpl("testIsRegistered"));
suite.addTest(
new TestProtocolProviderServiceIcqImpl("testGetRegistrationState"));
suite.addTest(
new TestProtocolProviderServiceIcqImpl("testOperationSetTypes"));
}
return suite;
}

Loading…
Cancel
Save