From 73939293c318a03be876b3d0c0835880f08c3fdf Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Mon, 17 Jul 2006 21:37:17 +0000 Subject: [PATCH] Added java doc comments --- ...tionSetServerStoredContactInfoIcqImpl.java | 34 +++- .../icq/message/usrinfo/FullInfoAck.java | 19 ++ .../icq/message/usrinfo/FullInfoCmd.java | 183 +++++++++++++++++- .../slick/protocol/icq/FullUserInfoCmd.java | 161 ++++++++++++++- .../icq/TestOperationSetServerStoredInfo.java | 31 ++- 5 files changed, 403 insertions(+), 25 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetServerStoredContactInfoIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetServerStoredContactInfoIcqImpl.java index 61f113847..54230de2a 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetServerStoredContactInfoIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetServerStoredContactInfoIcqImpl.java @@ -23,17 +23,41 @@ public class OperationSetServerStoredContactInfoIcqImpl { this.infoRetreiver = infoRetreiver; } - - public Iterator getDetailsAndDescendants(Contact contat, Class detailClass) + /** + * returns the user details from the specified class or its descendants + * the class is one from the + * net.java.sip.communicator.service.protocol.ServerStoredDetails + * or implemented one in the operation set for the user info + * + * @param contact Contact + * @param detailClass Class + * @return Iterator + */ + public Iterator getDetailsAndDescendants(Contact contact, Class detailClass) { - return infoRetreiver.getDetailsAndDescendants(contat.getAddress(), detailClass); + return infoRetreiver.getDetailsAndDescendants(contact.getAddress(), detailClass); } - public Iterator getDetails(Contact contat, Class detailClass) + /** + * returns the user details from the specified class + * exactly that class not its descendants + * + * @param contact Contact + * @param detailClass Class + * @return Iterator + */ + public Iterator getDetails(Contact contact, Class detailClass) { - return infoRetreiver.getDetails(contat.getAddress(), detailClass); + return infoRetreiver.getDetails(contact.getAddress(), detailClass); } + /** + * request the full info for the given uin + * waits and return this details + * + * @param contact Contact + * @return Iterator + */ public Iterator getAllDetailsForContact(Contact contact) { return infoRetreiver.getContactDetails(contact.getAddress()).iterator(); diff --git a/src/net/java/sip/communicator/impl/protocol/icq/message/usrinfo/FullInfoAck.java b/src/net/java/sip/communicator/impl/protocol/icq/message/usrinfo/FullInfoAck.java index 501c17e4b..5564828a6 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/message/usrinfo/FullInfoAck.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/message/usrinfo/FullInfoAck.java @@ -27,6 +27,12 @@ public class FullInfoAck private boolean isSuccess = false; + /** + * Constructs incoming Command + * and extracts data from it + * + * @param packet FromIcqCmd + */ public FullInfoAck(FromIcqCmd packet) { super(21, 3); @@ -40,11 +46,24 @@ public FullInfoAck(FromIcqCmd packet) } } + /** + * Do nothing as this packet is received only + * + * @param out OutputStream + * @throws IOException + */ public void writeData(OutputStream out) throws IOException { // nothing to write } + /** + * Return the data from this command + * whether the command which this packet is reply to + * is succesful or not + * + * @return boolean + */ public boolean isCommandSuccesful() { return isSuccess; diff --git a/src/net/java/sip/communicator/impl/protocol/icq/message/usrinfo/FullInfoCmd.java b/src/net/java/sip/communicator/impl/protocol/icq/message/usrinfo/FullInfoCmd.java index 172c3f68e..516bc189e 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/message/usrinfo/FullInfoCmd.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/message/usrinfo/FullInfoCmd.java @@ -514,6 +514,10 @@ public class FullInfoCmd supportedTypes.put(ServerStoredDetails.TimeZoneDetail.class, new int[]{1, 0x0316}); } + /** + * Construct incoming command from server + * @param packet FromIcqCmd + */ public FullInfoCmd(FromIcqCmd packet) { super(21, 3); @@ -557,6 +561,13 @@ public FullInfoCmd(FromIcqCmd packet) } } + /** + * Constructs command send to server + * @param senderUin String the uin of the sender + * @param changedData List the data to be changed + * @param toBeCleared List the data to be cleared, + * if no such data null can be passed + */ public FullInfoCmd(String senderUin, List changedData, List toBeCleared) { super(21,2); @@ -604,6 +615,11 @@ public FullInfoCmd(String senderUin, List changedData, List toBeCleared) } } + /** + * Data writen to the sever corresponding the changes passed to the constructor + * @param out OutputStream + * @throws IOException + */ public void writeData(OutputStream out) throws IOException { ByteArrayOutputStream icqout = new ByteArrayOutputStream(); @@ -638,6 +654,12 @@ public void writeData(OutputStream out) throws IOException new Tlv(TYPE_ICQ_DATA, ByteBlock.wrap(icqout.toByteArray())).write(out); } + /** + * Converts ServerStoredDetails to Tlv which later is converted to bytes + * and send to server + * @param detail GenericDetail the detail + * @return DetailTlv + */ private DetailTlv getTlvForChange(ServerStoredDetails.GenericDetail detail) { int typeOfDetail = ((int[])supportedTypes.get(detail.getClass()))[1]; @@ -668,6 +690,12 @@ private DetailTlv getTlvForChange(ServerStoredDetails.GenericDetail detail) return result; } + /** + * Correspondig the type of ServerStoredDetails returns empty Tlv or Tlv + * with default value + * @param detail GenericDetail + * @return DetailTlv + */ private DetailTlv getClearTlv(ServerStoredDetails.GenericDetail detail) { int typeOfDetail = ((int[])supportedTypes.get(detail.getClass()))[1]; @@ -704,7 +732,11 @@ private DetailTlv getClearTlv(ServerStoredDetails.GenericDetail detail) return result; } - + /** + * Writes the corresponding index for Language from ServerStoredDetails to the tlv + * @param detail LocaleDetail + * @param tlv DetailTlv + */ private void writeLanguageCode(ServerStoredDetails.LocaleDetail detail, DetailTlv tlv) { Locale newLang = detail.getLocale(); @@ -729,6 +761,11 @@ private void writeLanguageCode(ServerStoredDetails.LocaleDetail detail, DetailTl } } + /** + * Writes the corresponding index for Gender from ServerStoredDetails to the tlv + * @param detail GenderDetail + * @param tlv DetailTlv + */ private void writeGenderCode(ServerStoredDetails.GenderDetail detail, DetailTlv tlv) { int gender = 0; @@ -741,6 +778,11 @@ else if(detail.equals(ServerStoredDetails.GenderDetail.MALE)) tlv.writeUByte(gender); } + /** + * Writes the corresponding index for Calendar(BirthDate) from ServerStoredDetails to the tlv + * @param detail CalendarDetail + * @param tlv DetailTlv + */ private void writeCalendarCode(ServerStoredDetails.CalendarDetail detail, DetailTlv tlv) { Calendar calendar = detail.getCalendar(); @@ -750,6 +792,11 @@ private void writeCalendarCode(ServerStoredDetails.CalendarDetail detail, Detail tlv.writeUShort(calendar.get(Calendar.DAY_OF_MONTH)); } + /** + * Writes the corresponding index for Occupation from ServerStoredDetails to the tlv + * @param detail WorkOcupationDetail + * @param tlv DetailTlv + */ private void writeOccupationCode(WorkOcupationDetail detail, DetailTlv tlv) { for(int i = 0; i < occupations.length; i++) @@ -759,6 +806,11 @@ private void writeOccupationCode(WorkOcupationDetail detail, DetailTlv tlv) } } + /** + * Writes the corresponding index for Interests from ServerStoredDetails to the tlv + * @param detail InterestDetail + * @param tlv DetailTlv + */ private void writeInterestCode(InterestDetail detail, DetailTlv tlv) { String category = detail.getCategory(); @@ -780,6 +832,11 @@ private void writeInterestCode(InterestDetail detail, DetailTlv tlv) tlv.writeString(detail.getInterest()); } + /** + * Writes the corresponding value for ServerStoredDetails to the tlv + * @param detail GenericDetail + * @param tlv DetailTlv + */ private void writeGenericDetail(ServerStoredDetails.GenericDetail detail, DetailTlv tlv) { if(detail instanceof ServerStoredDetails.StringDetail) @@ -795,7 +852,12 @@ private void writeGenericDetail(ServerStoredDetails.GenericDetail detail, Detai } } - // START method for parsing incoming data + /** + * Method for parsing incoming data + * Read data in BasicUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readBasicUserInfo(ByteBlock block, int requestID) { List infoData = getInfoForRequest(requestID); @@ -847,6 +909,12 @@ private void readBasicUserInfo(ByteBlock block, int requestID) infoData.add(new ServerStoredDetails.PostalCodeDetail(bscInfo[10])); } + /** + * Method for parsing incoming data + * Read data in MoreUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readMoreUserInfo(ByteBlock block, int requestID) { List infoData = getInfoForRequest(requestID); @@ -944,6 +1012,12 @@ private void readMoreUserInfo(ByteBlock block, int requestID) infoData.add(new ServerStoredDetails.TimeZoneDetail("GMT Offest", userTimeZone)); } + /** + * Method for parsing incoming data + * Read data in EmailUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readEmailUserInfo(ByteBlock block, int requestID) { List infoData = getInfoForRequest(requestID); @@ -968,6 +1042,12 @@ private void readEmailUserInfo(ByteBlock block, int requestID) } } + /** + * Method for parsing incoming data + * Read data in HomePageUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readHomePageUserInfo(ByteBlock block, int requestID) { List infoData = getInfoForRequest(requestID); @@ -993,6 +1073,12 @@ private void readHomePageUserInfo(ByteBlock block, int requestID) {} } + /** + * Method for parsing incoming data + * Read data in WorkUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readWorkUserInfo(ByteBlock block, int requestID) { List infoData = getInfoForRequest(requestID); @@ -1048,6 +1134,12 @@ private void readWorkUserInfo(ByteBlock block, int requestID) {} } + /** + * Method for parsing incoming data + * Read data in UserAboutInfo command + * @param block ByteBlock + * @param requestID int + */ private void readUserAboutInfo(ByteBlock block, int requestID) { List infoData = getInfoForRequest(requestID); @@ -1060,6 +1152,12 @@ private void readUserAboutInfo(ByteBlock block, int requestID) infoData.add(new NotesDetail(tmp[0])); } + /** + * Method for parsing incoming data + * Read data in InterestsUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readInterestsUserInfo(ByteBlock block, int requestID) { List infoData = getInfoForRequest(requestID); @@ -1137,8 +1235,11 @@ private void readAffilationsUserInfo(ByteBlock block, int requestID) lastOfSequences = true; } - // END method for parsing incoming data - + /** + * Checks the type of the current command + * @param type IcqType + * @return boolean + */ public static boolean isOfType(IcqType type) { switch (type.getSecondary()) @@ -1164,21 +1265,39 @@ public static boolean isOfType(IcqType type) } } + /** + * Whether this command is last of the sequence + * @return boolean + */ public boolean isLastOfSequences() { return lastOfSequences; } + /** + * The request id of the current command + * @return int + */ public int getRequestID() { return requestID; } + /** + * Return the retreived info from the last received request + * @return List + */ public List getInfo() { return getInfoForRequest(getRequestID()); } + /** + * Returns the stored info so far on the specified request + * + * @param requestID int + * @return List + */ protected List getInfoForRequest(int requestID) { List res = (List) retreivedInfo.get(new Integer(requestID)); @@ -1196,6 +1315,15 @@ protected List getInfoForRequest(int requestID) return res; } + /** + * Extracts String from the given byte block + * starting from the specified position + * + * @param block ByteBlock + * @param result String[] the result strings + * @param offset int + * @return int + */ private static int readStrings(ByteBlock block, String[] result, int offset) { for (int i = 0; i < result.length; i++) @@ -1215,6 +1343,12 @@ private static int readStrings(ByteBlock block, String[] result, int offset) return offset; } + /** + * Returns the Locale corresponding the index coming from icq server + * + * @param code int + * @return Locale + */ private static Locale getCountry(int code) { if(code == 0 || code == 9999) // not specified or other @@ -1229,6 +1363,11 @@ private static Locale getCountry(int code) return new Locale("", cryStr); } + /** + * Returns the index stored on the server corresponding the given locale + * @param cLocale Locale + * @return int + */ private static int getCountryCode(Locale cLocale) { if(cLocale == null) @@ -1247,6 +1386,11 @@ private static int getCountryCode(Locale cLocale) return 0; // not specified } + /** + * Returns the Locale corresponding the index coming from icq server + * @param code int + * @return Locale + */ private static Locale getSpokenLanguage(int code) { if(code == 0 || code == 255) // not specified or other @@ -1255,7 +1399,9 @@ private static Locale getSpokenLanguage(int code) return spokenLanguages[code]; } - + /** + * Origin City of user + */ public static class OriginCityDetail extends ServerStoredDetails.CityDetail { public OriginCityDetail(String cityName) @@ -1264,6 +1410,9 @@ public OriginCityDetail(String cityName) } } + /** + * Origin Province of User + */ public static class OriginProvinceDetail extends ServerStoredDetails.ProvinceDetail { @@ -1273,6 +1422,9 @@ public OriginProvinceDetail(String workProvince) } } + /** + * Origin Postal Code of user + */ public static class OriginPostalCodeDetail extends ServerStoredDetails.PostalCodeDetail { @@ -1282,6 +1434,9 @@ public OriginPostalCodeDetail(String postalCode) } } + /** + * Fax at work + */ public static class WorkFaxDetail extends ServerStoredDetails.PhoneNumberDetail { @@ -1292,6 +1447,9 @@ public WorkFaxDetail(String number) } } + /** + * Work department + */ public static class WorkDepartmentNameDetail extends ServerStoredDetails.NameDetail { @@ -1301,6 +1459,9 @@ public WorkDepartmentNameDetail(String workDepartmentName) } } + /** + * User position name at work + */ public static class WorkPositionNameDetail extends ServerStoredDetails.StringDetail { @@ -1310,6 +1471,9 @@ public WorkPositionNameDetail(String workPos) } } + /** + * User ocupation at work + */ public static class WorkOcupationDetail extends ServerStoredDetails.StringDetail { @@ -1319,6 +1483,9 @@ public WorkOcupationDetail(String value) } } + /** + * User notes + */ public static class NotesDetail extends ServerStoredDetails.StringDetail { @@ -1328,6 +1495,9 @@ public NotesDetail (String value) } } + /** + * User interests + */ public static class InterestDetail extends ServerStoredDetails.InterestDetail { private String category = null; @@ -1344,6 +1514,9 @@ public String getCategory() } } + /** + * Origin country Code of user + */ public static class OriginCountryDetail extends ServerStoredDetails.CountryDetail { diff --git a/test/net/java/sip/communicator/slick/protocol/icq/FullUserInfoCmd.java b/test/net/java/sip/communicator/slick/protocol/icq/FullUserInfoCmd.java index 11336ec7d..814202312 100644 --- a/test/net/java/sip/communicator/slick/protocol/icq/FullUserInfoCmd.java +++ b/test/net/java/sip/communicator/slick/protocol/icq/FullUserInfoCmd.java @@ -98,6 +98,11 @@ public FullUserInfoCmd(SnacPacket packet) } } + /** + * Process the data in the received packet + * + * @param icqData ByteBlock + */ private void processICQData(ByteBlock icqData) { switch (secondaryType) @@ -153,6 +158,12 @@ public void writeData(OutputStream out) new Tlv(TYPE_ICQ_DATA, ByteBlock.wrap(icqout.toByteArray())).write(out); } + /** + * Returns the stored info so far on the specified request + * + * @param requestID int + * @return Hashtable + */ private Hashtable getInfoForRequest(int requestID) { Hashtable res = (Hashtable) retreivedInfo.get(new Integer(requestID)); @@ -170,12 +181,21 @@ private Hashtable getInfoForRequest(int requestID) return res; } + /** + * Return the retreived info from the last received request + * @return Hashtable + */ public Hashtable getInfo() { return getInfoForRequest(requestID); } - // START method for parsing incoming data + /** + * Method for parsing incoming data + * Read data in BasicUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readBasicUserInfo(ByteBlock block, int requestID) { Hashtable infoData = getInfoForRequest(requestID); @@ -221,6 +241,12 @@ private void readBasicUserInfo(ByteBlock block, int requestID) // infoData.add(new ServerStoredDetails.PostalCodeDetail(bscInfo[10])); } + /** + * Method for parsing incoming data + * Read data in MoreUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readMoreUserInfo(ByteBlock block, int requestID) { Hashtable infoData = getInfoForRequest(requestID); @@ -315,6 +341,12 @@ private void readMoreUserInfo(ByteBlock block, int requestID) // infoData.add(new ServerStoredDetails.TimeZoneDetail("GMT Offest", userTimeZone)); } + /** + * Method for parsing incoming data + * Read data in EmailUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readEmailUserInfo(ByteBlock block, int requestID) { // Vector infoData = getInfoForRequest(requestID); @@ -340,6 +372,12 @@ private void readEmailUserInfo(ByteBlock block, int requestID) // } } + /** + * Method for parsing incoming data + * Read data in HomePageUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readHomePageUserInfo(ByteBlock block, int requestID) { // Vector infoData = getInfoForRequest(requestID); @@ -364,6 +402,12 @@ private void readHomePageUserInfo(ByteBlock block, int requestID) // {} } + /** + * Method for parsing incoming data + * Read data in WorkUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readWorkUserInfo(ByteBlock block, int requestID) { // Vector infoData = getInfoForRequest(requestID); @@ -408,6 +452,12 @@ private void readWorkUserInfo(ByteBlock block, int requestID) // {} } + /** + * Method for parsing incoming data + * Read data in UserAboutInfo command + * @param block ByteBlock + * @param requestID int + */ private void readUserAboutInfo(ByteBlock block, int requestID) { // Vector infoData = getInfoForRequest(requestID); @@ -419,6 +469,12 @@ private void readUserAboutInfo(ByteBlock block, int requestID) // infoData.add(new NotesDetail(tmp[0])); } + /** + * Method for parsing incoming data + * Read data in InterestsUserInfo command + * @param block ByteBlock + * @param requestID int + */ private void readInterestsUserInfo(ByteBlock block, int requestID) { // Vector infoData = getInfoForRequest(requestID); @@ -496,9 +552,12 @@ private void readAffilationsUserInfo(ByteBlock block, int requestID) lastOfSequences = true; } - // END method for parsing incoming data - - + /** + * Writes Byte data to the icqDataOut + * which is send to the server + * @param dataType int the data type used in the Tlv + * @param value int + */ protected void writeOutByte(int dataType, int value) { try @@ -511,6 +570,12 @@ protected void writeOutByte(int dataType, int value) {} } + /** + * Writes Short data to the icqDataOut + * which is send to the server + * @param dataType int the data type used in the Tlv + * @param value int + */ protected void writeOutShort(int dataType, int value) { try @@ -523,7 +588,12 @@ protected void writeOutShort(int dataType, int value) {} } - + /** + * Writes String data to the icqDataOut + * which is send to the server + * @param dataType int the data type used in the Tlv + * @param value String + */ protected void writeOutString(int dataType, String value) { try @@ -538,7 +608,13 @@ protected void writeOutString(int dataType, String value) {} } - + /** + * Writes Int data to the icqDataOut + * which is send to the server + * @param out OutputStream + * @param number long the data type used in the Tlv + * @throws IOException + */ private static void writeUInt(final OutputStream out, final long number) throws IOException { @@ -550,6 +626,12 @@ private static void writeUInt(final OutputStream out, final long number) }); } + /** + * Writes Short data to the stream + * @param out OutputStream + * @param number int + * @throws IOException + */ private static void writeUShort(OutputStream out, int number) throws IOException { @@ -560,12 +642,25 @@ private static void writeUShort(OutputStream out, int number) }); } + /** + * Writes Byte data to the stream + * @param out OutputStream + * @param number int + * @throws IOException + */ private static void writeUByte(OutputStream out, int number) throws IOException { out.write(new byte[]{(byte) (number & 0xff)}); } + /** + * Extracts Int from the given byte block + * starting from the specified position + * @param data ByteBlock + * @param pos int + * @return long + */ private static long getUInt(final ByteBlock data, final int pos) { if (data.getLength() - pos < 4) @@ -579,6 +674,13 @@ private static long getUInt(final ByteBlock data, final int pos) | ( (long) data.get(pos) & 0xffL); } + /** + * Extracts Short from the given byte block + * starting from the specified position + * @param data ByteBlock + * @param pos int + * @return int + */ private static int getUShort(final ByteBlock data, final int pos) { if (data.getLength() - pos < 2) @@ -589,6 +691,13 @@ private static int getUShort(final ByteBlock data, final int pos) return ( (data.get(pos + 1) & 0xff) << 8) | (data.get(pos) & 0xff); } + /** + * Extracts Byte from the given byte block + * starting from the specified position + * @param data ByteBlock + * @param pos int + * @return short + */ public static short getUByte(final ByteBlock data, final int pos) { if (data.getLength() - pos < 1) @@ -599,6 +708,15 @@ public static short getUByte(final ByteBlock data, final int pos) return (short) (data.get(pos) & 0xff); } + /** + * Extracts String from the given byte block + * starting from the specified position + * + * @param block ByteBlock + * @param result String[] the result strings + * @param offset int + * @return int + */ private static int readStrings(ByteBlock block, String[] result, int offset) { for (int i = 0; i < result.length; i++) @@ -618,17 +736,31 @@ private static int readStrings(ByteBlock block, String[] result, int offset) return offset; } - + /** + * The factory used to pass incoming commands + * + * @return SnacCmdFactory + */ protected static SnacCmdFactory getCommandFactory() { return commandFactory; } + /** + * Return the command for requesting full user info + * @param senderUIN String the uin of the sender + * @param userInfoUIN String the uin of the requested user info + * @return SnacCommand + */ protected static SnacCommand getFullInfoRequestCommand(String senderUIN, String userInfoUIN) { return new FullInfoRequest(senderUIN, userInfoUIN); } + /** + * Factory used for registering FullUserInfoCmd + * for receiving command + */ private static class CommandFactory implements SnacCmdFactory { @@ -649,12 +781,22 @@ public List getSupportedTypes() } } + /** + * Command used for requestin full user info + */ private static class FullInfoRequest extends SnacCommand { private String senderUIN; private String userInfoUIN; + /** + * Creating request for the specified user info + * from specified sender + * + * @param senderUIN String + * @param userInfoUIN String + */ FullInfoRequest(String senderUIN, String userInfoUIN) { super(21, 2); @@ -663,6 +805,11 @@ private static class FullInfoRequest this.userInfoUIN = userInfoUIN; } + /** + * Writing data to the stream sending it to server + * @param out OutputStream + * @throws IOException + */ public void writeData(OutputStream out) throws IOException { ByteArrayOutputStream icqout = new ByteArrayOutputStream(); diff --git a/test/net/java/sip/communicator/slick/protocol/icq/TestOperationSetServerStoredInfo.java b/test/net/java/sip/communicator/slick/protocol/icq/TestOperationSetServerStoredInfo.java index 614a4625f..1a026032f 100644 --- a/test/net/java/sip/communicator/slick/protocol/icq/TestOperationSetServerStoredInfo.java +++ b/test/net/java/sip/communicator/slick/protocol/icq/TestOperationSetServerStoredInfo.java @@ -103,12 +103,8 @@ protected void tearDown() throws Exception /** * 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. + * ordered tests. We first execute tests for reading info, then writing. + * Then the ordered tests - error handling and finaly for removing details * * @return Test a testsuite containing all tests to execute. */ @@ -191,6 +187,7 @@ public void testReadInfo() Contact testerAgentContact = opSetPresence.findContactByID(fixture.testerAgent.getIcqUIN()); + // Get the last name info Iterator iter = opSetServerStoredContactInfo. getDetails(testerAgentContact, @@ -206,6 +203,7 @@ public void testReadInfo() break; } + // Get phone number info iter = opSetServerStoredContactInfo. getDetails(testerAgentContact, @@ -220,6 +218,7 @@ public void testReadInfo() break; } + // get the spoken languages iter = opSetServerStoredContactInfo. getDetails(testerAgentContact, @@ -244,6 +243,7 @@ public void testReadInfo() assertTrue("Must contain langiage " + spokenLanguages[lang3], spokenLanguagesServer.contains(spokenLanguages[lang3])); + // get home country code detail iter = opSetServerStoredContactInfo. getDetails(testerAgentContact, @@ -277,21 +277,25 @@ public void testWriteInfo() Iterator iterSpokenLangDetails = null; ServerStoredDetails.CountryDetail homeCountryDetail = null; + // Get Last name info detail Iterator iter = opSetServerStoredAccountInfo. getDetails(ServerStoredDetails.LastNameDetail.class); if (iter.hasNext()) lastNameDetail = (ServerStoredDetails.LastNameDetail) iter.next(); + // Get phone number info iter = opSetServerStoredAccountInfo. getDetails(ServerStoredDetails.PhoneNumberDetail.class); if (iter.hasNext()) phoneNumberDetail = (ServerStoredDetails.PhoneNumberDetail) iter.next(); + // Get spoken languages iterSpokenLangDetails = opSetServerStoredAccountInfo. getDetails(ServerStoredDetails.SpokenLanguageDetail.class); + // Get home country code detail iter = opSetServerStoredAccountInfo. getDetails(ServerStoredDetails.CountryDetail.class); if (iter.hasNext()) @@ -505,6 +509,10 @@ public void testWriteInfo() , userInfo.get(FullUserInfoCmd.HOME_COUNTRY)); } + /** + * Checking if the error handling works (all throw clauses in the methods) + * If max number of details is ok. Chacking of details classes. + */ public void errorHandling() { Iterator iter = @@ -565,6 +573,11 @@ public void errorHandling() {} } + /** + * Details used only for class checking when passing it to + * modification methods. As its not in the implementation + * ClassCastException must be thrown + */ private class DummyDetail extends ServerStoredDetails.NameDetail { @@ -641,6 +654,8 @@ public void removingItems() } } + // Indexes of countries as stored in the icq server + // and their corresponding locale strings private static Object[][] countryIndexToLocaleString = { // {new Integer(0),""}, //not specified @@ -891,7 +906,8 @@ public void removingItems() }; - + // the index in the array is the index stored in icq server + // the values are the corresponding locales private static Locale spokenLanguages[] = new Locale[] { @@ -970,5 +986,4 @@ public void removingItems() new Locale("be"), // LC_BELORUSSIAN Belorussian null // LC_OTHER 255 other }; - }