diff options
author | Damian Minkov <damencho@jitsi.org> | 2010-08-10 07:23:45 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2010-08-10 07:23:45 +0000 |
commit | 9c1c17dff9ae4b6a803b48e5203311a0f3f94b08 (patch) | |
tree | 72fdd92f39cd0012ee2312c9596399a5fd2b07b1 /test | |
parent | 411c4d9f013331950967665d41b103be6ebe8cba (diff) | |
download | jitsi-9c1c17dff9ae4b6a803b48e5203311a0f3f94b08.zip jitsi-9c1c17dff9ae4b6a803b48e5203311a0f3f94b08.tar.gz jitsi-9c1c17dff9ae4b6a803b48e5203311a0f3f94b08.tar.bz2 |
Merge changes from branch/gsoc10/xcap and patch sent to dev mailinglist with subject "XCAP tests" which represents the work of Grigorii Balutsel on the "XCAP Support" GSoC 2010 project into trunk.
Diffstat (limited to 'test')
6 files changed, 1075 insertions, 6 deletions
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 0e77da6..12993c4 100644 --- a/test/net/java/sip/communicator/slick/protocol/sip/SipProtocolProviderServiceLick.java +++ b/test/net/java/sip/communicator/slick/protocol/sip/SipProtocolProviderServiceLick.java @@ -41,7 +41,7 @@ public class SipProtocolProviderServiceLick */ public static final String DISABLE_ONLINE_TESTS_PROPERTY_NAME = "accounts.sip.DISABLE_ONLINE_TESTING"; - + /** * The name of the property the value of which is a formatted string that * contains the contact list that. @@ -50,6 +50,11 @@ public class SipProtocolProviderServiceLick = "accounts.sip.CONTACT_LIST"; /** + * The name of the property the value of which is XCAP server uri. + */ + public static final String XCAP_SERVER_PROPERTY_NAME = "XCAP_SERVER"; + + /** * Initializes and registers all tests that we'll run as a part of this * slick. * @@ -70,6 +75,9 @@ public class SipProtocolProviderServiceLick if (offlineMode != null && offlineMode.equalsIgnoreCase("true")) SipSlickFixture.onlineTestingDisabled = true; + + // xcap parsing tests + addTest(TestXCapParse.suite()); //First test account installation so that the service that has //been installed by it gets tested by the rest of the tests. @@ -93,6 +101,9 @@ public class SipProtocolProviderServiceLick // telephony addTestSuite(TestOperationSetBasicTelephonySipImpl.class); + + // Server stored info + addTest(TestOperationSetServerStoredInfo.suite()); } //This must remain after all other tests using the accounts diff --git a/test/net/java/sip/communicator/slick/protocol/sip/TestAccountInstallation.java b/test/net/java/sip/communicator/slick/protocol/sip/TestAccountInstallation.java index 7c9336e..a10aae1 100644 --- a/test/net/java/sip/communicator/slick/protocol/sip/TestAccountInstallation.java +++ b/test/net/java/sip/communicator/slick/protocol/sip/TestAccountInstallation.java @@ -6,11 +6,12 @@ */ package net.java.sip.communicator.slick.protocol.sip; -import java.util.*; - -import org.osgi.framework.*; import junit.framework.*; +import net.java.sip.communicator.impl.protocol.sip.*; import net.java.sip.communicator.service.protocol.*; +import org.osgi.framework.*; + +import java.util.*; public class TestAccountInstallation extends TestCase @@ -241,6 +242,20 @@ public class TestAccountInstallation } } + String xCapServerUri = System.getProperty(accountPrefix + + SipProtocolProviderServiceLick.XCAP_SERVER_PROPERTY_NAME, null); + if (xCapServerUri != null) + { + table.put(ProtocolProviderServiceSipImpl.XCAP_ENABLE, + Boolean.TRUE.toString()); + table.put(ProtocolProviderServiceSipImpl.XCAP_USE_SIP_CREDETIALS, + Boolean.TRUE.toString()); + table.put(ProtocolProviderServiceSipImpl.XCAP_USE_SIP_CREDETIALS, + Boolean.TRUE.toString()); + table.put(ProtocolProviderServiceSipImpl.XCAP_SERVER_URI, + xCapServerUri); + } + table.put(ProtocolProviderFactory.FORCE_P2P_MODE, Boolean.FALSE.toString()); diff --git a/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetServerStoredInfo.java b/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetServerStoredInfo.java new file mode 100644 index 0000000..4aa9631 --- /dev/null +++ b/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetServerStoredInfo.java @@ -0,0 +1,356 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.slick.protocol.sip; + +import junit.framework.*; +import net.java.sip.communicator.util.*; +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.impl.protocol.sip.*; +import net.java.sip.communicator.impl.protocol.sip.xcap.*; +import net.java.sip.communicator.impl.protocol.sip.xcap.model.prescontent.*; + +import java.net.URI; +import java.util.*; + +/** + * Testing of the user and account info. Tests for reading, adding, removing, + * replacing and error handling. + * + * @author Grigorii Balutsel + */ +public class TestOperationSetServerStoredInfo extends TestCase +{ + /** + * Fixture for testing. + */ + private SipSlickFixture fixture = new SipSlickFixture(); + + /** + * Account Info Operation set for testing. + */ + private OperationSetServerStoredAccountInfo + opSetServerStoredAccountInfo = null; + + /** + * XCAP client for testing. + */ + private XCapClient xCapClient; + + /** + * Creates tests under specific name. + * + * @param name the tests name. + */ + public TestOperationSetServerStoredInfo(String name) + { + super(name); + } + + /** + * Get a reference to the account info operation sets. + * + * @throws Exception + */ + protected void setUp() throws Exception + { + super.setUp(); + fixture.setUp(); + Map<String, OperationSet> supportedOperationSets = + fixture.provider1.getSupportedOperationSets(); + if (supportedOperationSets == null || supportedOperationSets.size() < 1) + { + throw new NullPointerException( + "No OperationSet implementations are supported by this " + + "SIP implementation."); + } + opSetServerStoredAccountInfo = (OperationSetServerStoredAccountInfo) + supportedOperationSets.get( + OperationSetServerStoredAccountInfo.class.getName()); + if (opSetServerStoredAccountInfo == null) + { + throw new NullPointerException( + "No implementation for Account Info was found"); + } + if (!opSetServerStoredAccountInfo + .isDetailClassSupported(ServerStoredDetails.ImageDetail.class)) + { + throw new NullPointerException( + "OperationSet does't support avatars"); + } + + // Connect to the XCAP server + xCapClient = createXCapClient(); + if (!xCapClient.isConnected()) + { + throw new NullPointerException("XCAP client is not connected"); + } + if (!xCapClient.isPresContentSupported()) + { + throw new NullPointerException( + "XCAP server doesn't support pres-content"); + } + + // Clean details + List<ServerStoredDetails.GenericDetail> details = + new ArrayList<ServerStoredDetails.GenericDetail>(); + Iterator<ServerStoredDetails.GenericDetail> detailIterator = + opSetServerStoredAccountInfo.getAllAvailableDetails(); + while (detailIterator.hasNext()) + { + details.add(detailIterator.next()); + } + for (ServerStoredDetails.GenericDetail detail : details) + { + opSetServerStoredAccountInfo.removeDetail(detail); + } + } + + protected void tearDown() throws Exception + { + super.tearDown(); + fixture.tearDown(); + xCapClient.dicsonnect(); + } + + /** + * 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 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. + */ + public static Test suite() + { + if(System.getProperty(SipProtocolProviderServiceLick.ACCOUNT_1_PREFIX + + SipProtocolProviderServiceLick.XCAP_SERVER_PROPERTY_NAME) != null) + { + return new TestSuite(TestOperationSetServerStoredInfo.class); + } + return new TestSuite(); + } + + private XCapClient createXCapClient() + throws Exception + { + String userName = System.getProperty( + SipProtocolProviderServiceLick.ACCOUNT_1_PREFIX + + ProtocolProviderFactory.USER_ID); + String password = System.getProperty( + SipProtocolProviderServiceLick.ACCOUNT_1_PREFIX + + ProtocolProviderFactory.PASSWORD); + String xCapServerUri = System.getProperty( + SipProtocolProviderServiceLick.ACCOUNT_1_PREFIX + + SipProtocolProviderServiceLick + .XCAP_SERVER_PROPERTY_NAME); + XCapClient xCapClient = new XCapClientImpl(); + xCapClient.connect(new URI(xCapServerUri), + ((ProtocolProviderServiceSipImpl) fixture.provider1). + parseAddressString(userName), password); + return xCapClient; + } + + /** + * Tests reading info. Puts the image to the server by using XCAP client and + * then gets it by using Sip Communicator interfaces. + * + * @throws Exception if there is some error during test. + */ + public void testReadInfo() throws Exception + { + // Add image + byte[] imageContent = + TestOperationSetServerStoredInfoData.IMAGE_CONTENT_1; + ServerStoredDetails.ImageDetail imageDetail1 = + new ServerStoredDetails.ImageDetail(null, imageContent); + opSetServerStoredAccountInfo.addDetail(imageDetail1); + // Get saved image + Iterator<ServerStoredDetails.GenericDetail> storedDetails = + opSetServerStoredAccountInfo + .getDetails(ServerStoredDetails.ImageDetail.class); + assertNotNull("Stored details cannot be null", storedDetails); + assertTrue("Stored details doesn't have ImageDetail", + storedDetails.hasNext()); + ServerStoredDetails.GenericDetail storedImageDetail = + storedDetails.next(); + assertTrue("Stored details is not ImageDetail", + storedImageDetail instanceof ServerStoredDetails.ImageDetail); + byte[] savedContent = + ((ServerStoredDetails.ImageDetail) storedImageDetail).getBytes(); + assertEquals( + "The ImageDetail we set is not set or not read properly", + imageContent.length, + savedContent.length); + for (int i = 0; i < imageContent.length; i++) + { + assertSame("The ImageDetail we set has not the same content", + imageContent[i], savedContent[i]); + } + // Get pres-content from the server + ContentType presContent = xCapClient.getPresContent( + ProtocolProviderServiceSipImpl.PRES_CONTENT_IMAGE_NAME); + assertNotNull("Pres-content cannot be null", presContent); + assertNotNull("Pres-content data cannot be null", + presContent.getData()); + assertNotNull("Pres-content data value cannot be null", + presContent.getData().getValue()); + byte[] serverContent = Base64.decode(presContent.getData().getValue()); + assertEquals( + "The ImageDetail we set is not set or not read properly", + imageContent.length, serverContent.length); + for (int i = 0; i < imageContent.length; i++) + { + assertSame("The ImageDetail we set has not the same content", + imageContent[i], serverContent[i]); + } + // Create pres-content +// ContentType presContent = new ContentType(); +// ContentType.MimeType mimeType = new ContentType.MimeType(); +// mimeType.setValue(TestOperationSetServerStoredInfoData.IMAGE_TYPE); +// presContent.setMimeType(mimeType); +// ContentType.EncodingType encoding = new ContentType.EncodingType(); +// encoding.setValue("base64"); +// presContent.setEncoding(encoding); +// ContentType.DataType data = new ContentType.DataType(); +// data.setValue(encodedImageContent); +// presContent.setData(data); + // Put pres-content to the server +// xCapClient.putPresContent(presContent, +// ProtocolProviderServiceSipImpl.PRES_CONTENT_IMAGE_NAME); + } + + /** + * Tests writing info. Puts the image to the server by using Sip + * Communicator interfaces and then gets it by using XCAP client. + * + * @throws Exception if there is some error during test. + */ + public void testWriteInfo() throws Exception + { + byte[] imageContent = + TestOperationSetServerStoredInfoData.IMAGE_CONTENT_1; + ServerStoredDetails.ImageDetail imageDetail = + new ServerStoredDetails.ImageDetail(null, imageContent); + opSetServerStoredAccountInfo.addDetail(imageDetail); + // Get pres-content + ContentType presContent = xCapClient.getPresContent( + ProtocolProviderServiceSipImpl.PRES_CONTENT_IMAGE_NAME); + assertNotNull("Pres-content cannot be null", presContent); + assertNotNull("Pres-content data cannot be null", + presContent.getData()); + assertNotNull("Pres-content data value cannot be null", + presContent.getData().getValue()); + byte[] serverContent = Base64.decode(presContent.getData().getValue()); + assertEquals( + "The ImageDetail we set is not set or not read properly", + imageContent.length, serverContent.length); + for (int i = 0; i < imageContent.length; i++) + { + assertSame("The ImageDetail we set has not the same content", + imageContent[i], serverContent[i]); + } + // Remove saved image + opSetServerStoredAccountInfo.removeDetail(imageDetail); + } + + /** + * Tests deleting info. Puts the image to the server by using Sip + * Communicator interfaces, deletes it and then gets it by using XCAP + * client. + * + * @throws Exception if there is some error during test. + */ + public void testRemoveInfo() throws Exception + { + byte[] imageContent = + TestOperationSetServerStoredInfoData.IMAGE_CONTENT_1; + ServerStoredDetails.ImageDetail imageDetail = + new ServerStoredDetails.ImageDetail(null, imageContent); + opSetServerStoredAccountInfo.addDetail(imageDetail); + // Remove saved image + boolean removeResult = + opSetServerStoredAccountInfo.removeDetail(imageDetail); + assertTrue("The result of remove operation cannot be false", + removeResult); + // Get saved image + Iterator<ServerStoredDetails.GenericDetail> storedDetails = + opSetServerStoredAccountInfo + .getDetails(ServerStoredDetails.ImageDetail.class); + assertNotNull("Stored details cannot be null", storedDetails); + assertFalse("Stored details cannot have ImageDetail", + storedDetails.hasNext()); + // Get pres-content + ContentType presContent = xCapClient.getPresContent( + ProtocolProviderServiceSipImpl.PRES_CONTENT_IMAGE_NAME); + assertNull("Pres-content cannot be not null", presContent); + } + + /** + * Tests replacing info. Puts the image to the server by using Sip + * Communicator interfaces, replace it and then gets it by using XCAP + * client. + * + * @throws Exception if there is some error during test. + */ + public void testReplaceInfo() throws Exception + { + byte[] imageContent1 = + TestOperationSetServerStoredInfoData.IMAGE_CONTENT_1; + byte[] imageContent2 = + TestOperationSetServerStoredInfoData.IMAGE_CONTENT_2; + ServerStoredDetails.ImageDetail imageDetail1 = + new ServerStoredDetails.ImageDetail(null, imageContent1); + ServerStoredDetails.ImageDetail imageDetail2 = + new ServerStoredDetails.ImageDetail(null, imageContent2); + opSetServerStoredAccountInfo.addDetail(imageDetail1); + boolean replaceResult = opSetServerStoredAccountInfo + .replaceDetail(imageDetail1, imageDetail2); + assertTrue("The result of replace operation cannot be false", + replaceResult); + // Get saved image + Iterator<ServerStoredDetails.GenericDetail> storedDetails = + opSetServerStoredAccountInfo + .getDetails(ServerStoredDetails.ImageDetail.class); + assertNotNull("Stored details cannot be null", storedDetails); + assertTrue("Stored details doesn't have ImageDetail", + storedDetails.hasNext()); + ServerStoredDetails.GenericDetail imageDetail = + storedDetails.next(); + assertTrue("Stored details is not ImageDetail", + imageDetail instanceof ServerStoredDetails.ImageDetail); + byte[] savedContent = + ((ServerStoredDetails.ImageDetail) imageDetail).getBytes(); + assertEquals( + "The ImageDetail we set is not set or not read properly", + imageContent2.length, + savedContent.length); + for (int i = 0; i < imageContent2.length; i++) + { + assertSame("The ImageDetail we set has not the same content", + imageContent2[i], savedContent[i]); + } + // Get pres-content + ContentType presContent = xCapClient.getPresContent( + ProtocolProviderServiceSipImpl.PRES_CONTENT_IMAGE_NAME); + assertNotNull("Pres-content cannot be null", presContent); + assertNotNull("Pres-content data cannot be null", + presContent.getData()); + assertNotNull("Pres-content data value cannot be null", + presContent.getData().getValue()); + byte[] serverContent = Base64.decode(presContent.getData().getValue()); + assertEquals( + "The ImageDetail we set is not set or not read properly", + imageContent2.length, serverContent.length); + for (int i = 0; i < imageContent2.length; i++) + { + assertSame("The ImageDetail we set has not the same content", + imageContent2[i], serverContent[i]); + } + // Remove saved image + opSetServerStoredAccountInfo.removeDetail(imageDetail2); + } +} diff --git a/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetServerStoredInfoData.java b/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetServerStoredInfoData.java new file mode 100644 index 0000000..794d81b --- /dev/null +++ b/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetServerStoredInfoData.java @@ -0,0 +1,175 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.slick.protocol.sip; + +/** + * Contains data for server stored info tests. + * + * @author Grigorii Balutsel + */ +public class TestOperationSetServerStoredInfoData +{ + /** + * The image content. + */ + public static String IMAGE_TYPE = "image/png"; + + /** + * The image content. + */ + public static byte[] IMAGE_CONTENT_1 = new byte[]{ + -119, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, + 1, 0, 0, 0, 1, 0, 8, 2, 0, 0, 0, -45, 16, 63, 49, 0, 0, 0, 1, 115, + 82, 71, 66, 0, -82, -50, 28, -23, 0, 0, 0, 4, 103, 65, 77, 65, 0, 0, + -79, -113, 11, -4, 97, 5, 0, 0, 0, 32, 99, 72, 82, 77, 0, 0, 122, + 38, 0, 0, -128, -124, 0, 0, -6, 0, 0, 0, -128, -24, 0, 0, 117, 48, + 0, 0, -22, 96, 0, 0, 58, -104, 0, 0, 23, 112, -100, -70, 81, 60, 0, + 0, 3, 114, 73, 68, 65, 84, 120, 94, -19, -48, 49, 1, 0, 0, 0, -62, + -96, -11, 79, -19, 101, 11, -120, 64, 97, -64, -128, 1, 3, 6, 12, + 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, + 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, + 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, + 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, + 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, + -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, + -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, + 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, + 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, + 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, + 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, + 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, + 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, + 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, + -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, + -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, + 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, + 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, + 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, + 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, + 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, + 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, + 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, + -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, + -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, + 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, + 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, + 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, + 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, + 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, + 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, + 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, + -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, + -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, + 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, + 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, + 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, + 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, + 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, + 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, + 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, + -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, + -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, + 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, + 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, + 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, + 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, + 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, + 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, -128, + 1, 3, 6, 12, 24, 48, 96, -64, -128, 1, 3, 6, 12, 24, 48, 96, -64, + -64, 7, 6, 1, 45, 0, 1, 96, 53, 25, 121, 0, 0, 0, 0, 73, 69, 78, 68, + -82, 66, 96, -126 + }; + + /** + * The image content. + */ + public static byte[] IMAGE_CONTENT_2 = new byte[]{ + -119, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, + 1, 0, 0, 0, 1, 0, 8, 2, 0, 0, 0, -45, 16, 63, 49, 0, 0, 0, 4, 103, + 65, 77, 65, 0, 0, -79, -113, 11, -4, 97, 5, 0, 0, 4, -64, 73, 68, + 65, 84, 120, 94, -19, -44, -63, 13, 0, 32, 12, 3, 49, -70, -1, -48, + -64, -85, 75, -100, 17, 11, -60, 106, 50, -9, 120, 4, -62, 2, -65, + 0, 62, -127, -84, -128, -21, 39, -112, 22, 72, -121, -49, -50, -98, + -32, 43, -96, 0, 4, -46, 2, -23, -16, -122, -112, -128, 2, 16, 72, + 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, + 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, + -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, + -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, + 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, + 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, + 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, + 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, + 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, + -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, + 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, + -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, + -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, + -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, + -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, + 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, + 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, + 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, + -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, + -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, + -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, + -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, + -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, + 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, + 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, + 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, + 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, + 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, + -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, + 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, + -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, + -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, + -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, + -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, + 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, + 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, + 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, + -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, + -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, + -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, + -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, + -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, + 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, + 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, + 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, + 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, + 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, + -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, + 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, + -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, + -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, + -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, + -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, + 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, + 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, + 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, + -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, + -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, + -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, + -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, + -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, + 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, + 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, + 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, + 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, + 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, + -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, + 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, + -96, 0, 4, -46, 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, + -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, 111, -1, 8, 40, 0, -127, + -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, 2, -23, -16, -10, -113, + -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, 10, 64, 32, 45, -112, 14, + 111, -1, 8, 40, 0, -127, -76, 64, 58, -68, -3, 35, -96, 0, 4, -46, + 2, -23, -16, -10, -113, -128, 2, 16, 72, 11, -92, -61, -37, 63, 2, + 15, -73, -86, 16, -29, 81, -81, -102, 105, 0, 0, 0, 0, 73, 69, 78, + 68, -82, 66, 96, -126 + }; +} diff --git a/test/net/java/sip/communicator/slick/protocol/sip/TestXCapParse.java b/test/net/java/sip/communicator/slick/protocol/sip/TestXCapParse.java new file mode 100644 index 0000000..da04692 --- /dev/null +++ b/test/net/java/sip/communicator/slick/protocol/sip/TestXCapParse.java @@ -0,0 +1,503 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.slick.protocol.sip; + +import junit.framework.*; +import net.java.sip.communicator.impl.protocol.sip.xcap.model.*; +import net.java.sip.communicator.impl.protocol.sip.xcap.model.xcapcaps.*; +import net.java.sip.communicator.impl.protocol.sip.xcap.model.resourcelists.*; +import net.java.sip.communicator.impl.protocol.sip.xcap.model.prescontent.*; +import net.java.sip.communicator.impl.protocol.sip.xcap.model.xcaperror.*; +import org.w3c.dom.*; + +import javax.xml.namespace.*; + +/** + * Contains tests of parsing xcap-caps, resource-lists, pres-content. + * + * @author Grigorii Balutsel + */ +public class TestXCapParse extends TestCase +{ + /** + * The resource-xml for the tests. + */ + private static String RESOURCE_LISTS_XML = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\"" + + " xmlns:ext=\"extension\"" + + " xmlns:xsi=\"htt//www.w3.org/2001/XMLSchema-instance\">" + + " xsi:schemaLocation=\"resource-lists.xsd \">" + + " <list name=\"list1\" ext:name=\"ext list1\">" + + " <entry uri=\"sip:entry1@example.com\"" + + " ext:uri=\"sip:user1@example.com\">" + + " <display-name>Entry1</display-name>" + + " <ext:display-name>Ext:Entry1</ext:display-name>" + + " </entry>" + + " <entry uri=\"sip:entry2@example.com\">" + + " <display-name xml:lang=\"en-US\">Entry2</display-name>" + + " </entry>" + + " <list name=\"sub_group1\"/>" + + " <external anchor=\"anchor_uri\">" + + " <display-name xml:lang=\"en-US\">External</display-name>" + + " </external>" + + " <entry-ref ref=\"ref_uri\">" + + " <display-name xml:lang=\"en-US\">Entry1</display-name>" + + " </entry-ref>" + + " <ext:entry uri=\"sip:user1@example.com\" " + + " ext:uri=\"sip:user1@example.com\"/>" + + " </list>" + + " <list name=\"list2\">" + + " <display-name xml:lang=\"en-US\">List2</display-name>" + + " </list>" + + "</resource-lists>"; + + /** + * The resource-xml for the tests. + */ + private static String XCAP_CAPS_XML = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<xcap-caps xmlns=\"urn:ietf:params:xml:ns:xcap-caps\"" + + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + + " xsi:schemaLocation=\"xcap-caps.xsd \">" + + " <auids>" + + " <auid>resource-lists</auid>" + + " <auid>rls-services</auid>" + + " </auids>" + + " <extensions>" + + " <!-- No extensions defined -->" + + " </extensions>" + + " <namespaces>" + + " <namespace>urn:ietf:params:xml:ns:xcap-caps</namespace>" + + " <namespace>urn:ietf:params:xml:ns:xcap-error</namespace>" + + " <namespace>urn:ietf:params:xml:ns:resource-lists</namespace>" + + " </namespaces>" + + "</xcap-caps>"; + + /** + * The pres-content for the tests. + */ + private static String PRES_CONTENT_XML = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<content xmlns=\"urn:oma:xml:prs:pres-content\">" + + " <mime-type>image/png</mime-type>" + + " <encoding>base64</encoding>" + + " <description>Description</description>" + + " <description xml:lang=\"en-US\">Description</description>" + + " <data>Data</data>" + + "</content>"; + + /** + * The xcap-error uniqueness-failure for the tests. + */ + private static String XCAP_ERROR_CANNOT_DELETE_XML = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<xcap-error xmlns=\"urn:ietf:params:xml:ns:xcap-error\">" + + " <cannot-delete phrase=\"Cannot Delete\"/>" + + "</xcap-error>"; + + /** + * The xcap-error uniqueness-failure for the tests. + */ + private static String XCAP_ERROR_UNIQUENESS_FAILURE_XML = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<xcap-error xmlns=\"urn:ietf:params:xml:ns:xcap-error\">" + + " <uniqueness-failure>" + + " <exists field=\"field\">" + + " <alt-value>sip:entry@example.com</alt-value>" + + " </exists>" + + " </uniqueness-failure>" + + "</xcap-error>"; + + /** + * 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 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. + */ + public static Test suite() + { + return new TestSuite(TestXCapParse.class); + } + + /** + * Tests resource-lists parsing. + * + * @throws Exception if there is some error during test. + */ + public static void testResourceListsParse() throws Exception + { + ResourceListsType originalResourceLists = + ResourceListsParser.fromXml(RESOURCE_LISTS_XML); + validateResourceLists(originalResourceLists); + String xml = ResourceListsParser.toXml(originalResourceLists); + ResourceListsType storedResourceLists = + ResourceListsParser.fromXml(xml); + validateResourceLists(storedResourceLists); + } + + /** + * Tests xcap-caps parsing. + * + * @throws Exception if there is some error during test. + */ + public static void testXCapCapsParse() throws Exception + { + XCapCapsType originalXCapCaps = + XCapCapsParser.fromXml(XCAP_CAPS_XML); + validateXCapCaps(originalXCapCaps); + } + + /** + * Tests pres-content parsing. + * + * @throws Exception if there is some error during test. + */ + public static void testPresContentParse() throws Exception + { + ContentType originalContent = + PresContentParser.fromXml(PRES_CONTENT_XML); + validatePresContent(originalContent); + String xml = PresContentParser.toXml(originalContent); + ContentType storedContent = PresContentParser.fromXml(xml); + validatePresContent(storedContent); + } + + /** + * Tests xcap-error parsing. + * + * @throws Exception if there is some error during test. + */ + public static void testXCapErrorParse() throws Exception + { + XCapErrorType cannotDelete = + XCapErrorParser.fromXml(XCAP_ERROR_CANNOT_DELETE_XML); + validateXCapErrorConnotDelete(cannotDelete); + + XCapErrorType uniquenessFailure = + XCapErrorParser.fromXml(XCAP_ERROR_UNIQUENESS_FAILURE_XML); + validateXCapErrorUniquenessFailure(uniquenessFailure); + } + + /** + * Validates uniqueness-failure with the original XML. + * + * @param xCapError the xcap-error to analyze. + */ + private static void validateXCapErrorUniquenessFailure( + XCapErrorType xCapError) + { + assertNotNull("xcap-error cannot be null", xCapError); + assertNotNull("uniqueness-failure cannot be null", + xCapError.getError()); + assertTrue( + "The uniqueness-failure elements we set is not read properly", + xCapError.getError() instanceof UniquenessFailureType); + UniquenessFailureType uniquenessFailure = (UniquenessFailureType) + xCapError.getError(); + assertNull("The phrase we set is not read properly", + uniquenessFailure.getPhrase()); + assertTrue("The exists elements we set is not read properly", + uniquenessFailure.getExists().size() == 1); + UniquenessFailureType.ExistsType exists1 = + uniquenessFailure.getExists().get(0); + assertEquals("The exists[0] element we set is not read properly", + exists1.getField(), "field"); + assertTrue("The exists[0]altValue we set is not read properly", + exists1.getAltValue().size() == 1); + assertEquals("The exists[0]altValue[0] we set is not read properly", + exists1.getAltValue().get(0), "sip:entry@example.com"); + } + + /** + * Validates cannot-delete with the original XML. + * + * @param xCapError the xcap-error to analyze. + */ + private static void validateXCapErrorConnotDelete( + XCapErrorType xCapError) + { + assertNotNull("xcap-error cannot be null", xCapError); + assertNotNull("cannot-delete cannot be null", + xCapError.getError()); + assertTrue( + "The cannot-delete elements we set is not read properly", + xCapError.getError() instanceof CannotDeleteType); + CannotDeleteType cannotDelete = (CannotDeleteType) + xCapError.getError(); + assertEquals("The phrase we set is not read properly", + cannotDelete.getPhrase(), "Cannot Delete"); + } + + /** + * Validates resource-lists with the original XML. + * + * @param resourceLists the resource-lists to analyze. + */ + private static void validateResourceLists(ResourceListsType resourceLists) + { + assertNotNull("resource-lists cannot be null", resourceLists); + assertTrue("The first level lists we set is not read properly", + resourceLists.getList().size() == 2); + // list1 + ListType list1 = resourceLists.getList().get(0); + assertEquals( + "The lists[1] name we set is not read properly", + list1.getName(), "list1"); + assertEquals( + "The lists[1] name we set is not read properly", + list1.getName(), "list1"); + assertNull("The lists[1] display-name we set is not read properly", + list1.getDisplayName()); + assertTrue("The lists[1] entries we set is not read properly", + list1.getEntries().size() == 2); + assertTrue("The lists[1] lists we set is not read properly", + list1.getLists().size() == 1); + assertTrue("The lists[1] externals we set is not read properly", + list1.getExternals().size() == 1); + assertTrue("The lists[1] entryRefs we set is not read properly", + list1.getEntryRefs().size() == 1); + assertTrue("The lists[1] custom attriutes we set is not read properly", + list1.getAnyAttributes().size() == 1); + assertTrue("The lists[1] custom elements we set is not read properly", + list1.getAnyAttributes().size() == 1); + + String list1ExtAttribute = list1.getAnyAttributes().get( + new QName("extension", "name", "ext")); + assertNotNull( + "The lists[1]ext:display-name attribute we set is not read " + + "properly", + list1ExtAttribute); + assertEquals( + "The lists[1]ext:display-name attribute we set is not read " + + "properly", + list1ExtAttribute, "ext list1"); + + Element list1ExtElement = list1.getAny().get(0); + assertEquals( + "The lists[1]ext:entry attribute we set is not read " + + "properly", + list1ExtElement.getLocalName(), "entry"); + assertEquals( + "The lists[1]ext:entry attribute we set is not read " + + "properly", + XmlUtils.getNamespaceUri(list1ExtElement), "extension"); + assertEquals( + "The lists[1]ext:entry attribute we set is not read " + + "properly", + list1ExtElement.getPrefix(), "ext"); + + EntryType lis1Entry1 = list1.getEntries().get(0); + assertNotNull( + "The lists[1]entry[1] name we set is not read properly", + lis1Entry1.getUri()); + assertEquals( + "The lists[1]entry[1] name we set is not read properly", + lis1Entry1.getUri(), "sip:entry1@example.com"); + assertNotNull( + "The lists[1]entry[1] display-name we set is not read properly", + lis1Entry1.getDisplayName()); + assertEquals( + "The lists[1]entry[1] display-name we set is not read properly", + lis1Entry1.getDisplayName().getValue(), "Entry1"); + assertNull( + "The lists[1]entry[1] display-name we set is not read properly", + lis1Entry1.getDisplayName().getLang()); + String enty1ExtAttribute = lis1Entry1.getAnyAttributes().get( + new QName("extension", "uri", "ext")); + assertNotNull( + "The lists[1]entry[1]ext:uri attribute we set is not read " + + "properly", + enty1ExtAttribute); + assertEquals( + "The lists[1]entry[1]ext:uri attribute we set is not read " + + "properly", + enty1ExtAttribute, "sip:user1@example.com"); + Element enty1ExtElement = lis1Entry1.getAny().get(0); + assertEquals( + "The lists[1]entry[1]ext:entry element we set is not read " + + "properly", + enty1ExtElement.getLocalName(), "display-name"); + assertEquals( + "The lists[1]entry[1]ext:dispaly-name element we set is not " + + "read properly", + XmlUtils.getNamespaceUri(enty1ExtElement), "extension"); + assertEquals( + "The lists[1]entry[1]ext:dispaly-name element we set is not " + + "read properly", + enty1ExtElement.getPrefix(), "ext"); + assertEquals( + "The lists[1]entry[1]ext:dispaly-name element we set is not " + + "read properly", + enty1ExtElement.getTextContent(), "Ext:Entry1"); + + EntryType lis1Entry2 = list1.getEntries().get(1); + assertNotNull( + "The lists[1]entry[2] display-name we set is not read properly", + lis1Entry2.getDisplayName()); + assertNotNull( + "The lists[1]entry[2] name we set is not read properly", + lis1Entry2.getUri()); + assertEquals( + "The lists[1]entry[2] name we set is not read properly", + lis1Entry2.getUri(), "sip:entry2@example.com"); + assertEquals( + "The lists[1]entry[2] display-name we set is not read properly", + lis1Entry2.getDisplayName().getValue(), "Entry2"); + assertEquals( + "The lists[1]entry[2] display-name we set is not read properly", + lis1Entry2.getDisplayName().getLang(), "en-US"); + + EntryRefType list1EntryRef = list1.getEntryRefs().get(0); + assertEquals( + "The lists[1]entryRef[1] name we set is not read properly", + list1EntryRef.getRef(), "ref_uri"); + assertNotNull( + "The lists[1]entryRef[1] display-name we set is not read " + + "properly", + list1EntryRef.getDisplayName()); + assertEquals( + "The llists[1]entryRef[1] display-name we set is not read " + + "properly", + list1EntryRef.getDisplayName().getValue(), "Entry1"); + assertEquals( + "The lists[1]entryRef[1]display-name we set is not read " + + "properly", + list1EntryRef.getDisplayName().getLang(), "en-US"); + + ExternalType list1External = list1.getExternals().get(0); + assertEquals( + "The lists[1]external[1] name we set is not read properly", + list1External.getAnchor(), "anchor_uri"); + assertNotNull( + "The lists[1]external[1] display-name we set is not read " + + "properly", + list1External.getDisplayName()); + assertEquals( + "The llists[1]external[1] display-name we set is not read " + + "properly", + list1External.getDisplayName().getValue(), "External"); + assertEquals( + "The lists[1]external[1]display-name we set is not read " + + "properly", + list1External.getDisplayName().getLang(), "en-US"); + // list2 + ListType list2 = resourceLists.getList().get(1); + assertEquals( + "The lists[2] name we set is not read properly", + list2.getName(), "list2"); + assertNotNull("The lists[2] display-name we set is not read properly", + list2.getDisplayName()); + assertEquals("The lists[2] display-name we set is not read properly", + list2.getDisplayName().getValue(), "List2"); + assertEquals("The lists[2] display-name we set is not read properly", + list2.getDisplayName().getLang(), "en-US"); + } + + /** + * Validates xcap-caps with the original XML. + * + * @param xCapCaps the xcap-caps to analyze. + */ + private static void validateXCapCaps(XCapCapsType xCapCaps) + { + assertNotNull("xcap-caps cannot be null", xCapCaps); + + AuidsType auids = xCapCaps.getAuids(); + NamespacesType namespaces = xCapCaps.getNamespaces(); + ExtensionsType extensions = xCapCaps.getExtensions(); + + assertNotNull("The auids we set is not read properly", auids); + assertTrue("The auids we set is not read properly", + auids.getAuid().size() == 2); + assertNotNull("The namespaces we set is not read properly", namespaces); + assertTrue("The namespaces we set is not read properly", + namespaces.getNamespace().size() == 3); + assertNotNull("The auids we set is not read properly", extensions); + assertTrue("The extensions we set is not read properly", + extensions.getExtension().size() == 0); + // auids + assertEquals( + "The auids[0] name we set is not read properly", + auids.getAuid().get(0), "resource-lists"); + assertEquals( + "The auids[1] name we set is not read properly", + auids.getAuid().get(1), "rls-services"); + // namespaces + assertEquals( + "The namespaces[0] name we set is not read properly", + namespaces.getNamespace().get(0), + "urn:ietf:params:xml:ns:xcap-caps"); + assertEquals( + "The namespaces[1] name we set is not read properly", + namespaces.getNamespace().get(1), + "urn:ietf:params:xml:ns:xcap-error"); + assertEquals( + "The namespaces[2] name we set is not read properly", + namespaces.getNamespace().get(2), + "urn:ietf:params:xml:ns:resource-lists"); + } + + /** + * Validates pres-content with the original XML. + * + * @param presContent the pres-content to analyze. + */ + private static void validatePresContent(ContentType presContent) + { + assertNotNull("pres-content cannot be null", presContent); + DataType data = presContent.getData(); + MimeType mimeType = presContent.getMimeType(); + EncodingType encoding = presContent.getEncoding(); + // data + assertNotNull("The data we set is not read properly", data); + assertEquals("The data we set is not read properly", + data.getValue(), "Data"); + assertTrue("The data custom elements we set is not read properly", + data.getAnyAttributes().size() == 0); + // mime-type + assertNotNull("The mime-type we set is not read properly", mimeType); + assertEquals("The mime-type we set is not read properly", + mimeType.getValue(), "image/png"); + assertTrue("The mime-type custom elements we set is not read properly", + mimeType.getAnyAttributes().size() == 0); + // encoding + assertNotNull("The encoding we set is not read properly", encoding); + assertEquals("The encoding we set is not read properly", + encoding.getValue(), "base64"); + assertTrue("The encoding custom elements we set is not read properly", + encoding.getAnyAttributes().size() == 0); + // description + assertNotNull("The description we set is not read properly", + presContent.getDescription()); + assertTrue("The description we set is not read properly", + presContent.getDescription().size() == 2); + DescriptionType description1 = presContent.getDescription().get(0); + assertEquals( + "The description[0] we set is not read properly", + description1.getValue(), "Description"); + assertNull( + "The description[0] display-name we set is not read properly", + description1.getLang()); + assertTrue( + "The description[0] custom elements we set is not read properly", + description1.getAnyAttributes().size() == 0); + + DescriptionType description2 = presContent.getDescription().get(1); + assertEquals( + "The description[1] we set is not read properly", + description2.getValue(), "Description"); + assertEquals( + "The description[1] we set is not read properly", + description2.getLang(), "en-US"); + assertTrue( + "The description[1] custom elements we set is not read properly", + description2.getAnyAttributes().size() == 0); + } +} diff --git a/test/net/java/sip/communicator/slick/protocol/sip/sip.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/sip/sip.provider.slick.manifest.mf index d285dec..85b6286 100644 --- a/test/net/java/sip/communicator/slick/protocol/sip/sip.provider.slick.manifest.mf +++ b/test/net/java/sip/communicator/slick/protocol/sip/sip.provider.slick.manifest.mf @@ -8,7 +8,16 @@ Import-Package: net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.configuration.event, junit.framework, org.osgi.framework, + org.w3c.dom; + javax.xml.namespace; net.java.sip.communicator.util, net.java.sip.communicator.service.protocol, - net.java.sip.communicator.service.protocol.event - + net.java.sip.communicator.service.protocol.event, + net.java.sip.communicator.impl.protocol.sip, + net.java.sip.communicator.impl.protocol.sip.xcap, + net.java.sip.communicator.impl.protocol.sip.xcap.utils, + net.java.sip.communicator.impl.protocol.sip.xcap.model, + net.java.sip.communicator.impl.protocol.sip.xcap.model.xcapcaps, + net.java.sip.communicator.impl.protocol.sip.xcap.model.resourcelists, + net.java.sip.communicator.impl.protocol.sip.xcap.model.prescontent, + net.java.sip.communicator.impl.protocol.sip.xcap.model.xcaperror |