1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 04:22:05 +01:00

Added avatar test.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3829 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Alex Wenckus 2006-05-03 21:23:18 +00:00 committed by alex
parent c22f731c6d
commit 6f832ddb99
2 changed files with 101 additions and 0 deletions

View file

@ -349,4 +349,20 @@ public abstract class SmackTestCase extends TestCase {
return "config/" + fullClassName.substring(firstChar) + ".xml";
}
/**
* Compares two contents of two byte arrays to make sure that they are equal
*
* @param message The message to show in the case of failure
* @param byteArray1 The first byte array.
* @param byteArray2 The second byte array.
*/
public static void assertEquals(String message, byte [] byteArray1, byte [] byteArray2) {
if(byteArray1.length != byteArray2.length) {
fail(message);
}
for(int i = 0; i < byteArray1.length; i++) {
assertEquals(message, byteArray1[i], byteArray2[i]);
}
}
}

View file

@ -1,6 +1,7 @@
package org.jivesoftware.smackx;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.test.SmackTestCase;
import org.jivesoftware.smackx.packet.VCard;
import org.jivesoftware.smackx.provider.VCardProvider;
@ -82,6 +83,90 @@ public class VCardTest extends SmackTestCase {
// assertEquals("kir max", card.getFullName());
}
public void testBinaryAvatar() throws Throwable {
VCard card = new VCard();
card.setAvatar(getAvatarBinary());
card.save(getConnection(0));
System.out.println(card.getChildElementXML());
VCard loaded = new VCard();
try {
loaded.load(getConnection(0));
}
catch (XMPPException e) {
e.printStackTrace();
fail(e.getMessage());
}
System.out.println(StringUtils.encodeBase64(loaded.getAvatar()));
assertEquals("Should load own Avatar successfully", card.getAvatar(), loaded.getAvatar());
loaded = new VCard();
try {
loaded.load(getConnection(1), getBareJID(0));
}
catch (XMPPException e) {
e.printStackTrace();
fail(e.getMessage());
}
assertEquals("Should load avatar successfully", card.getAvatar(), loaded.getAvatar());
}
private byte[] getAvatarBinary() {
return StringUtils.decodeBase64(get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" +
"T326SU8oV6yhghemkYYzwZpVLAHI5YwcZBIIJLuyN5WDxB2jJubbVX59FUModJFCy08gC8opFyeL\n" +
"rkZGSCCCCVIJ8vdO97EsZtfgZWS148lbjeZZ6Y8gecYSKItgHp88bjBwemexBIuKF3bCZMDTgggg\n" +
"GZSNStuhLRlyAAGP9P8AfOoKW6Udbeqe38i0kANQwHoFHrq0WpG9yp+fdkBb8nrr1GhexDbk2zaN\n" +
"x0vul8tlHcaZG8xI6qBZVVwCOYDAjOCRn9Toe1GwNsWyqBpduWihqkBaKogoo43AIwcMoBHQkaNP\n" +
"lgxYx6ai9xWb4lQfwQBURLyjP3HqupM2NfUPwZNWAi4WmvimKxvLxB6FW1O7XpK1VXzeROe7tqSq\n" +
"/PilaGWNkkU4ZWHUayo5nV8Fv8MakU2uHr+1uIvHtW+Hl5oNy1G+6fFZaK4RLO0a/NRyKixgOP5W\n" +
"4jD9snicHiWBGvTnaFtnnmSeZCsQIKgj6v8AbV5jlDS1AXsqBRqqGJyVs8bM0pcEL9mz2e7pvivi\n" +
"3BvCirLZteMLLDHKjRS3QlQyiPsRCQQTIO4PFDnLI9NBZKKgpaCjtdPDR0YaPhBGgRI1UfKiqOgA\n" +
"CgADtrKoqPLpKaXPVXUdPtnXTNUBLlTQR4xHlj+gHT/7pjw8oTsf/9k=";
}
/*
public void testFullName() throws Throwable {
VCard card = new VCard();