testing - work in progress

cusax-fix
Emil Ivov 20 years ago
parent 9dae9ae07c
commit 9eca20c536

@ -79,7 +79,7 @@ public Iterator getChildContacts()
* Returns the contact with the specified identifier
*
* @param metaContactID a String identifier obtained through the
* <tt>MetaContact.getMetaContactID()</tt> method. <p>
* <tt>MetaContact.getMetaUID()</tt> method. <p>
* @return the <tt>MetaContact</tt> with the specified idnetifier.
*/
public MetaContact getMetaContact(String metaContactID)
@ -89,7 +89,7 @@ public MetaContact getMetaContact(String metaContactID)
{
MetaContact contact = (MetaContact)contactsIter.next();
if (contact.getMetaContactID().equals(metaContactID))
if (contact.getMetaUID().equals(metaContactID))
return contact;
}

@ -105,7 +105,7 @@ public Contact getDefaultContact()
*
* @return a String uniquely identifying this meta contact.
*/
public String getMetaContactID()
public String getMetaUID()
{
return uid;
}

@ -44,10 +44,10 @@
* Because of its experimental-patch nature, the implementa would only function
* properly if the underlying service providers have already been loaded at the
* time this one gets started.
*
*
* @todo might be a good idea to say that the implementation does not support
* subgroups.
*
*
* @author Emil Ivov
*/
public class MetaContactListServiceImpl
@ -106,7 +106,7 @@ public MetaContactListServiceImpl() {
* protocol provider implementations and perform the same algorithm with
* them.
* <p>
*
*
* @param bc
* the currently valid osgi bundle context.
*/
@ -151,7 +151,7 @@ public void start(BundleContext bc) {
/**
* Adds a listener for <tt>MetaContactListChangeEvent</tt>s posted after
* the tree changes.
*
*
* @param l
* the listener to add
*/
@ -166,7 +166,7 @@ public void addContactListListener(
* First makes the specified protocol provider create the contact as
* indicated by <tt>contactID</tt>, and then associates it to the
* _existing_ <tt>metaContact</tt> given as an argument.
*
*
* @param provider
* the ProtocolProviderService that should create the contact
* indicated by <tt>contactID</tt>.
@ -193,7 +193,7 @@ public void addNewContactToMetaContact(
* corresponding to the specified <tt>contactID</tt>, then creates a new
* MetaContact which will encapsulate the newly crated protocol specific
* contact.
*
*
* @param provider
* a ref to <tt>ProtocolProviderService</tt> instance which
* will create the actual protocol specific contact.
@ -218,7 +218,7 @@ public void createMetaContact(
/**
* Creates a <tt>MetaContactGroup</tt> with the specified group name.
*
*
* @param groupName
* the name of the <tt>MetaContactGroup</tt> to create.
* @throws MetaContactListException
@ -234,7 +234,7 @@ public void createMetaContactGroup(String groupName)
/**
* Returns the root <tt>MetaContactGroup</tt> in this contact list.
*
*
* @return the root <tt>MetaContactGroup</tt> for this contact list.
*/
public MetaContactGroup getRoot() {
@ -244,7 +244,7 @@ public MetaContactGroup getRoot() {
/**
* Makes the specified <tt>contact</tt> a child of the <tt>newParent</tt>
* MetaContact.
*
*
* @param contact
* the <tt>Contact</tt> to move to the
* @param newParent
@ -262,7 +262,7 @@ public void moveContact(Contact contact,
/**
* Moves the specified <tt>MetaContact</tt> to <tt>newGroup</tt>.
*
*
* @param metaContact
* the <tt>MetaContact</tt> to move.
* @param newGroup
@ -284,7 +284,7 @@ public void moveMetaContact(MetaContact metaContact,
* Deletes the specified contact from both the local contact list and (if
* applicable) the server stored contact list if supported by the
* corresponding protocol.
*
*
* @param contact
* the contact to remove.
* @throws MetaContactListException
@ -299,7 +299,7 @@ public void removeContact(Contact contact)
/**
* Removes a listener previously added with <tt>addContactListListener</tt>.
*
*
* @param l
* the listener to remove
*/
@ -313,7 +313,7 @@ public void removeContactListListener(
/**
* Removes the specified <tt>metaContact</tt> as well as all of its
* underlying contacts.
*
*
* @param metaContact
* the metaContact to remove.
* @throws MetaContactListException
@ -330,7 +330,7 @@ public void removeMetaContact(MetaContact metaContact)
/**
* Removes the specified meta contact group, all its corresponding protocol
* specific groups and all their children.
*
*
* @param groupToRemove
* the <tt>MetaContactGroup</tt> to have removed.
* @throws MetaContactListException
@ -346,10 +346,10 @@ public void removeMetaContactGroup(
}
/**
* Returns the MetaContactGroup corresponding to the specified contactGroup
* or null if no such MetaContactGroup was found.
* @return the MetaContactGroup corresponding to the specified contactGroup
* or null if no such MetaContactGroup was found.
* Returns the MetaContactGroup corresponding to the specified contactGroup
* or null if no such MetaContactGroup was found.
* @return the MetaContactGroup corresponding to the specified contactGroup
* or null if no such MetaContactGroup was found.
* @param contactGroup
* the protocol specific <tt>contactGroup</tt> that we're looking
* for.
@ -359,14 +359,14 @@ public void removeMetaContactGroup(
/** @todo implement findMetaContactByContact() */
return null;
}
/**
* Returns the MetaContact containing the specified contact or null if no
* such MetaContact was found. The method can be used when for example we
* need to find the MetaContact that is the author of an incoming message
* and the corresponding ProtocolProviderService has only provided a
* <tt>Contact</tt> as its author.
*
*
* @return the MetaContact containing the speicified contact or null if no
* such contact is present in this contact list.
* @param contact
@ -380,7 +380,7 @@ public MetaContact findMetaContactByContact(Contact contact) {
/**
* Returns the MetaContact that corresponds to the specified metaContactID.
*
*
* @param metaContactID
* a String identifier of a meta contact.
* @return the MetaContact with the speicified string identifier or null if
@ -395,7 +395,7 @@ public MetaContact findMetaContactByID(String metaContactID) {
* Goes through the server stored ContactList of the specified operation
* set, retrieves all protocol specific contacts it contains and makes sure
* they are all present in the local contact list.
*
*
* @param presenceOpSet
* the presence operation set whose contact list we'd like to
* synchronize with the local contact list.
@ -445,7 +445,7 @@ private void synchronizeOpSetWithLocalContactList(
/** @todo this shouldn't be that simple */
newMetaContact.setDisplayName(contact
.getAlias());
.getDisplayName());
newMetaGroup.addMetaContact(newMetaContact);
}
@ -466,7 +466,7 @@ private void synchronizeOpSetWithLocalContactList(
newMetaContact.addProtoContact(contact);
/** @todo this shouldn't be that simple */
newMetaContact.setDisplayName(contact.getAlias());
newMetaContact.setDisplayName(contact.getDisplayName());
rootMetaGroup.addMetaContact(newMetaContact);
@ -488,7 +488,7 @@ private void synchronizeOpSetWithLocalContactList(
* extract all contacts and synchronize them with the local contact list.
* Otherwise it would start a process where local contacts would be added on
* the server.
*
*
* @param provider
* the ProtocolProviderService that we've just detected.
*/
@ -518,7 +518,7 @@ private void handleProviderAdded(
/**
* Removes the specified provider from the list of currently known providers
* and ignores all the contacts that it has registered locally.
*
*
* @param provider
* the ProtocolProviderService that has been unregistered.
*/
@ -534,7 +534,7 @@ private void handleProviderRemoved(
* Implements the <tt>ServiceListener</tt> method. Verifies whether the
* passed event concerns a <tt>ProtocolProviderService</tt> and modifies
* the list of registered protocol providers accordingly.
*
*
* @param event
* The <tt>ServiceEvent</tt> object.
*/
@ -589,7 +589,7 @@ public void subscriptionCreated(SubscriptionEvent evt) {
logger.trace("Subscription created: " + evt);
MetaContactGroupImpl parentGroup =
MetaContactGroupImpl parentGroup =
(MetaContactGroupImpl)rootMetaGroup.getMetaContactSubgroup(evt
.getParentGroup().getGroupName());
@ -599,11 +599,11 @@ public void subscriptionCreated(SubscriptionEvent evt) {
.getSourceContact());
newMetaContact.setDisplayName(evt
.getSourceContact().getAlias());
.getSourceContact().getDisplayName());
parentGroup.addMetaContact(newMetaContact);
fireMetaContactEvent(newMetaContact,
fireMetaContactEvent(newMetaContact,
evt.getSourceProvider(),
parentGroup,
MetaContactEvent.METACONTACT_ADDED);
@ -617,15 +617,15 @@ public void subscriptionFailed(SubscriptionEvent evt) {
public void subscriptionRemoved(SubscriptionEvent evt) {
logger.trace("Subscription removed: " + evt);
MetaContact metaContact
MetaContact metaContact
= findMetaContactByContact(evt.getSourceContact());
MetaContactGroup metaContactGroup
= findMetaContactGroupByContactGroup(evt.getParentGroup());
//TODO: remove contact from metacontact
//TODO: remove contact from metacontact
fireMetaContactEvent(metaContact,
evt.getSourceProvider(),
metaContactGroup,
@ -656,14 +656,14 @@ public void groupCreated(ServerStoredGroupEvent evt) {
.contacts();
while (contactsIter.hasNext()) {
Contact contact = (Contact) contactsIter
.next();
.next();
MetaContactImpl newMetaContact = new MetaContactImpl();
newMetaContact.addProtoContact(contact);
newMetaContact.setDisplayName(contact
.getAlias());
.getDisplayName());
newMetaGroup.addMetaContact(newMetaContact);
}
@ -678,14 +678,14 @@ public void groupCreated(ServerStoredGroupEvent evt) {
public void groupRemoved(ServerStoredGroupEvent evt) {
logger.trace("ContactGroup removed: " + evt);
MetaContactGroup metaContactGroup
MetaContactGroup metaContactGroup
= findMetaContactGroupByContactGroup(evt.getSrouceGroup());
if (metaContactGroup != null) {
removeMetaContactGroup(metaContactGroup);
fireMetaContactGroupEvent(metaContactGroup,
evt.getSourceProvider(),
MetaContactGroupEvent.METACONTACT_GROUP_REMOVED);
@ -693,12 +693,12 @@ public void groupRemoved(ServerStoredGroupEvent evt) {
}
public void groupNameChanged(ServerStoredGroupEvent evt) {
logger.trace("ContactGroup renamed: " + evt);
MetaContactGroup metaContactGroup
MetaContactGroup metaContactGroup
= findMetaContactGroupByContactGroup(evt.getSrouceGroup());
//TODO: change the name of the MetaContactGroup
}
}
@ -707,7 +707,7 @@ public void groupNameChanged(ServerStoredGroupEvent evt) {
* Creates the corresponding MetaContact event and notifies all
* <tt>MetaContactListListener</tt>s that a MetaContact is added or
* removed from the MetaContactList.
*
*
* @param source
* the MetaContact instance that is added to the MetaContactList
* @param provider
@ -747,7 +747,7 @@ else if (eventID == MetaContactEvent.METACONTACT_REMOVED)
* Creates the corresponding MetaContactGroup event and notifies all
* <tt>MetaContactListListener</tt>s that a MetaContactGroup is added or
* removed from the MetaContactList.
*
*
* @param source
* the MetaContactGroup instance that is added to the
* MetaContactList

@ -92,7 +92,7 @@ public Iterator getChildContacts()
* Returns the contact with the specified identifier
*
* @param metaContactID a String identifier obtained through the
* <tt>MetaContact.getMetaContactID()</tt> method. <p>
* <tt>MetaContact.getMetaUID()</tt> method. <p>
* @return the <tt>MetaContact</tt> with the specified idnetifier.
*/
public MetaContact getMetaContact(String metaContactID)
@ -102,7 +102,7 @@ public MetaContact getMetaContact(String metaContactID)
{
MetaContact contact = (MetaContact)contactsIter.next();
if (contact.getMetaContactID().equals(metaContactID))
if (contact.getMetaUID().equals(metaContactID))
return contact;
}

@ -149,7 +149,7 @@ public PresenceStatus getPresenceStatus()
* @return a String that can be used for referring to this contact when
* interacting with the user.
*/
public String getAlias()
public String getDisplayName()
{
//temporarily return the uin as we don't have alias support in joust
//sim right now.

@ -28,10 +28,10 @@ public class TestMetaContactList
MclSlickFixture fixture = new MclSlickFixture(getClass().getName());
private static final Logger logger =
Logger.getLogger(TestOperationSetPersistentPresence.class);
Logger.getLogger(TestMetaContactList.class);
private OperationSetPersistentPresence opSetPersPresence;
/**
* Creates a unit test with the specified name.
* @param name the name of one of the test methods in this class.
@ -85,50 +85,79 @@ protected void tearDown() throws Exception
/**
* Verifies that the contacts retrieved by the meta contact list service,
* match those that were in the mock provider.
* matches the one that were in the mock provider.
*/
public void testContactListRetrieving()
{
ContactGroup root
ContactGroup expectedRoot
= opSetPersPresence.getServerStoredContactListRoot();
logger.debug("============== Predefined contact List ==============");
logger.debug("rootGroup="+root.getGroupName()
+" rootGroup.childContacts="+root.countContacts()
+ "rootGroup.childGroups="+root.countSubGroups()
+ "Printing rootGroupContents=\n"+root.toString());
MetaContactGroup expectedRoot = fixture.metaClService.getRoot();
logger.debug("rootGroup="+expectedRoot.getGroupName()
+" rootGroup.childContacts="+expectedRoot.countContacts()
+ "rootGroup.childGroups="+expectedRoot.countSubGroups()
+ " Printing rootGroupContents=\n"+expectedRoot.toString());
MetaContactGroup actualRoot = fixture.metaClService.getRoot();
logger.debug("================ Meta Contact List =================");
logger.debug("rootGroup="+expectedRoot.getGroupName()
+" rootGroup.childContacts="+expectedRoot.countChildContacts()
+ "rootGroup.childGroups="+expectedRoot.countSubgroups()
+ "Printing rootGroupContents=\n"+expectedRoot.toString());
Iterator groups = root.subGroups();
while (groups.hasNext() ){
ContactGroup group = (ContactGroup)groups.next();
MetaContactGroup expectedGroup
= expectedRoot
.getMetaContactSubgroup(group.getGroupName());
assertNotNull("Group " + group.getGroupName() + " was returned by "
+"the server but was not in the expected contact list."
, expectedGroup );
Iterator contactsIter = group.contacts();
while (contactsIter.hasNext()){
String contactID = ((Contact)contactsIter.next()).getAddress();
MetaContact expectedContact
= expectedGroup.getMetaContact(contactID);
assertNotNull("Contact " + contactID + " was returned by "
+"the server but was not in the expected contact list."
, expectedContact );
logger.debug("rootGroup="+actualRoot.getGroupName()
+" rootGroup.childContacts="+actualRoot.countChildContacts()
+ " rootGroup.childGroups="+actualRoot.countSubgroups()
+ " Printing rootGroupContents=\n"+actualRoot.toString());
Iterator expectedSubgroups = expectedRoot.subGroups();
//loop over mock groups and check whether they've all been added
//to the meta contact list.
while (expectedSubgroups.hasNext() ){
ContactGroup expectedGroup = (ContactGroup)expectedSubgroups.next();
MetaContactGroup actualGroup
= actualRoot
.getMetaContactSubgroup(expectedGroup.getGroupName());
assertNotNull("Group " + expectedGroup.getGroupName() + " was "
+ "returned by the MetaContactListService implementation "
+ "but was not in the expected contact list."
, actualGroup );
assertEquals("Group " + expectedGroup.getGroupName()
+ " did not have the expected number of member contacts"
, expectedGroup.countContacts()
, actualGroup.countChildContacts() );
assertEquals("Group " + expectedGroup.getGroupName()
+ " did not have the expected number of member contacts"
, expectedGroup.countContacts()
, actualGroup.countChildContacts() );
assertEquals("Group " + expectedGroup.getGroupName()
+ " did not have the expected number of sub groups"
, expectedGroup.countSubGroups()
, actualGroup.countSubgroups() );
Iterator actualContactsIter = actualGroup.getChildContacts();
//check whether every contact in the meta list exists in the source
//mock provider contact list.
while (actualContactsIter.hasNext()){
MetaContact actualMetaContact
= (MetaContact)actualContactsIter.next();
Contact actualProtoContact
= actualMetaContact.getContactForProvider(
MclSlickFixture.mockProvider);
Contact expectedProtoContact
= expectedGroup.getContact(actualProtoContact.getAddress());
assertNotNull("Contact " + actualMetaContact.getDisplayName()
+ " was returned by "
+ "the MetaContactListService implementation but was "
+ "not in the expected contact list."
, expectedProtoContact );
}
}
}

Loading…
Cancel
Save