Refactored property names and added javadocs

cusax-fix
Emil Ivov 20 years ago
parent abe91873c1
commit 6ce433df0c

@ -68,7 +68,7 @@ public static Test suite()
public void testRegisterWrongUsername() public void testRegisterWrongUsername()
{ {
ServiceReference[] serRefs = null; ServiceReference[] serRefs = null;
String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL_PROPERTY_NAME String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL
+ "="+ProtocolNames.ICQ+")"; + "="+ProtocolNames.ICQ+")";
try{ try{
serRefs = IcqSlickFixture.bc.getServiceReferences( serRefs = IcqSlickFixture.bc.getServiceReferences(
@ -92,16 +92,16 @@ public void testRegisterWrongUsername()
String passwd = System.getProperty( IcqProtocolProviderSlick String passwd = System.getProperty( IcqProtocolProviderSlick
.TESTED_IMPL_PWD_PROP_NAME, null ); .TESTED_IMPL_PWD_PROP_NAME, null );
String uin = System.getProperty( IcqProtocolProviderSlick String uin = System.getProperty( IcqProtocolProviderSlick
.TESTED_IMPL_ACCOUNT_ID_PROP_NAME, null); .TESTED_IMPL_USER_ID_PROP_NAME, null);
// make this uin an invalid one // make this uin an invalid one
uin = uin + "1234"; uin = uin + "1234";
Hashtable icqAccountProperties = new Hashtable(); Hashtable icqAccountProperties = new Hashtable();
icqAccountProperties.put(AccountProperties.PASSWORD, passwd); icqAccountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
AccountID icqAccountID = icqProviderFactory.installAccount( AccountID icqAccountID = icqProviderFactory.installAccount(
IcqSlickFixture.bc, uin, icqAccountProperties); uin, icqAccountProperties);
//find the protocol provider service //find the protocol provider service
ServiceReference[] icqProviderRefs = null; ServiceReference[] icqProviderRefs = null;
@ -111,14 +111,15 @@ public void testRegisterWrongUsername()
= IcqSlickFixture.bc.getServiceReferences( = IcqSlickFixture.bc.getServiceReferences(
ProtocolProviderService.class.getName(), ProtocolProviderService.class.getName(),
"(&" "(&"
+ "(" + ProtocolProviderFactory.PROTOCOL_PROPERTY_NAME + "=" + + "(" + ProtocolProviderFactory.PROTOCOL + "=" +
ProtocolNames.ICQ + ")" ProtocolNames.ICQ + ")"
+ "(" + ProtocolProviderFactory.ACCOUNT_ID_PROPERTY_NAME + "=" + "(" + ProtocolProviderFactory.USER_ID + "="
+ uin + ")" + uin + ")"
+ ")"); + ")");
} }
catch(InvalidSyntaxException ex1) catch(InvalidSyntaxException ex)
{ {
logger.debug("Our filter seems to be messed up.", ex);
} }
//make sure we found a service //make sure we found a service
@ -189,7 +190,7 @@ public void testRegisterWrongUsername()
public void testRegisterWrongPassword() public void testRegisterWrongPassword()
{ {
ServiceReference[] serRefs = null; ServiceReference[] serRefs = null;
String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL_PROPERTY_NAME String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL
+ "="+ProtocolNames.ICQ+")"; + "="+ProtocolNames.ICQ+")";
try{ try{
serRefs = IcqSlickFixture.bc.getServiceReferences( serRefs = IcqSlickFixture.bc.getServiceReferences(
@ -213,15 +214,15 @@ public void testRegisterWrongPassword()
String passwd = System.getProperty( IcqProtocolProviderSlick String passwd = System.getProperty( IcqProtocolProviderSlick
.TESTED_IMPL_PWD_PROP_NAME, null ); .TESTED_IMPL_PWD_PROP_NAME, null );
String uin = System.getProperty( IcqProtocolProviderSlick String uin = System.getProperty( IcqProtocolProviderSlick
.TESTED_IMPL_ACCOUNT_ID_PROP_NAME, null); .TESTED_IMPL_USER_ID_PROP_NAME, null);
passwd += "1234"; passwd += "1234";
Hashtable icqAccountProperties = new Hashtable(); Hashtable icqAccountProperties = new Hashtable();
icqAccountProperties.put(AccountProperties.PASSWORD, passwd); icqAccountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
AccountID icqAccountID = icqProviderFactory.installAccount( AccountID icqAccountID = icqProviderFactory.installAccount(
IcqSlickFixture.bc, uin, icqAccountProperties); uin, icqAccountProperties);
//find the protocol provider service //find the protocol provider service
ServiceReference[] icqProviderRefs = null; ServiceReference[] icqProviderRefs = null;
@ -231,10 +232,10 @@ public void testRegisterWrongPassword()
= IcqSlickFixture.bc.getServiceReferences( = IcqSlickFixture.bc.getServiceReferences(
ProtocolProviderService.class.getName(), ProtocolProviderService.class.getName(),
"(&" "(&"
+ "(" + ProtocolProviderFactory.PROTOCOL_PROPERTY_NAME + "=" + + "(" + ProtocolProviderFactory.PROTOCOL + "=" +
ProtocolNames.ICQ + ")" ProtocolNames.ICQ + ")"
+ "(" + ProtocolProviderFactory.ACCOUNT_ID_PROPERTY_NAME + "=" + "(" + ProtocolProviderFactory.USER_ID + "="
+ icqAccountID.getAccountUserID() + ")" + icqAccountID.getUserID() + ")"
+ ")"); + ")");
} }
catch(InvalidSyntaxException ex1) catch(InvalidSyntaxException ex1)
@ -305,7 +306,7 @@ public void testInstallAccount()
{ {
// first obtain a reference to the provider factory // first obtain a reference to the provider factory
ServiceReference[] serRefs = null; ServiceReference[] serRefs = null;
String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL_PROPERTY_NAME String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL
+ "="+ProtocolNames.ICQ+")"; + "="+ProtocolNames.ICQ+")";
try{ try{
serRefs = IcqSlickFixture.bc.getServiceReferences( serRefs = IcqSlickFixture.bc.getServiceReferences(
@ -335,10 +336,10 @@ public void testInstallAccount()
String passwd = System.getProperty( IcqProtocolProviderSlick String passwd = System.getProperty( IcqProtocolProviderSlick
.TESTED_IMPL_PWD_PROP_NAME, null ); .TESTED_IMPL_PWD_PROP_NAME, null );
String uin = System.getProperty( IcqProtocolProviderSlick String uin = System.getProperty( IcqProtocolProviderSlick
.TESTED_IMPL_ACCOUNT_ID_PROP_NAME, null); .TESTED_IMPL_USER_ID_PROP_NAME, null);
assertNotNull( assertNotNull(
"In the " + IcqProtocolProviderSlick.TESTED_IMPL_ACCOUNT_ID_PROP_NAME "In the " + IcqProtocolProviderSlick.TESTED_IMPL_USER_ID_PROP_NAME
+" system property, you need to provide a valid icq UIN for the " +" system property, you need to provide a valid icq UIN for the "
+" slick to use when signing on icq. It's passwd must be set in " +" slick to use when signing on icq. It's passwd must be set in "
@ -352,21 +353,12 @@ public void testInstallAccount()
Hashtable icqAccountProperties = new Hashtable(); Hashtable icqAccountProperties = new Hashtable();
icqAccountProperties.put(AccountProperties.PASSWORD, passwd); icqAccountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
//try to install an account with a null bundle context
try{
icqProviderFactory.installAccount( null, uin, icqAccountProperties);
fail("installing an account with a null BundleContext must result "
+"in a NullPointerException");
}catch(NullPointerException exc){
//that's what had to happen
}
//try to install an account with a null account id //try to install an account with a null account id
try{ try{
icqProviderFactory.installAccount( icqProviderFactory.installAccount(
IcqSlickFixture.bc, null, icqAccountProperties); null, icqAccountProperties);
fail("installing an account with a null account id must result " fail("installing an account with a null account id must result "
+"in a NullPointerException"); +"in a NullPointerException");
}catch(NullPointerException exc){ }catch(NullPointerException exc){
@ -375,13 +367,13 @@ public void testInstallAccount()
//now really install the account //now really install the account
IcqSlickFixture.icqAccountID = icqProviderFactory.installAccount( IcqSlickFixture.icqAccountID = icqProviderFactory.installAccount(
IcqSlickFixture.bc, uin, icqAccountProperties); uin, icqAccountProperties);
//try to install the account one more time and verify that an excepion //try to install the account one more time and verify that an excepion
//is thrown. //is thrown.
try{ try{
IcqSlickFixture.icqAccountID = icqProviderFactory.installAccount( IcqSlickFixture.icqAccountID = icqProviderFactory.installAccount(
IcqSlickFixture.bc, uin, icqAccountProperties); uin, icqAccountProperties);
fail("An IllegalStateException must be thrown when trying to "+ fail("An IllegalStateException must be thrown when trying to "+
"install a duplicate account"); "install a duplicate account");
@ -400,9 +392,9 @@ public void testInstallAccount()
//been properly registered with the osgi framework. //been properly registered with the osgi framework.
osgiFilter = osgiFilter =
"(&("+ProtocolProviderFactory.PROTOCOL_PROPERTY_NAME +"="+ProtocolNames.ICQ+")" "(&("+ProtocolProviderFactory.PROTOCOL +"="+ProtocolNames.ICQ+")"
+"(" + ProtocolProviderFactory.ACCOUNT_ID_PROPERTY_NAME +"(" + ProtocolProviderFactory.USER_ID
+ "=" + IcqSlickFixture.icqAccountID.getAccountUserID() + "))"; + "=" + IcqSlickFixture.icqAccountID.getUserID() + "))";
try try
{ {
@ -428,6 +420,10 @@ public void testInstallAccount()
,icqProtocolProvider instanceof ProtocolProviderService); ,icqProtocolProvider instanceof ProtocolProviderService);
} }
/**
* A blocking registration listener that would allow us to wait until
* registration is completed.
*/
public class RegistrationFailedEventCollector public class RegistrationFailedEventCollector
implements RegistrationStateChangeListener implements RegistrationStateChangeListener
{ {
@ -436,6 +432,11 @@ public class RegistrationFailedEventCollector
public int failedCode; public int failedCode;
public String failedReason = null; public String failedReason = null;
/**
* Notifies the registration lock once a new
* RegistrationStateChangeEvent is received.
* @param evt the RegistrationStateChangeEvent that we'll have to store.
*/
public void registrationStateChanged(RegistrationStateChangeEvent evt) public void registrationStateChanged(RegistrationStateChangeEvent evt)
{ {
collectedNewStates.add(evt.getNewState()); collectedNewStates.add(evt.getNewState());

Loading…
Cancel
Save