summaryrefslogtreecommitdiffstats
path: root/test/com
diff options
context:
space:
mode:
Diffstat (limited to 'test/com')
-rw-r--r--test/com/isode/stroke/avatars/AvatarManagerImplTest.java45
-rwxr-xr-xtest/com/isode/stroke/avatars/VCardAvatarManagerTest.java10
-rwxr-xr-xtest/com/isode/stroke/avatars/VCardUpdateAvatarManagerTest.java9
3 files changed, 28 insertions, 36 deletions
diff --git a/test/com/isode/stroke/avatars/AvatarManagerImplTest.java b/test/com/isode/stroke/avatars/AvatarManagerImplTest.java
index 7ee10fd..339ccf4 100644
--- a/test/com/isode/stroke/avatars/AvatarManagerImplTest.java
+++ b/test/com/isode/stroke/avatars/AvatarManagerImplTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -11,31 +11,30 @@
package com.isode.stroke.avatars;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Vector;
+
import org.junit.Before;
import org.junit.Test;
-import java.util.Vector;
-import com.isode.stroke.elements.VCardUpdate;
-import com.isode.stroke.elements.Presence;
+
+import com.isode.stroke.base.ByteArray;
+import com.isode.stroke.client.DummyStanzaChannel;
+import com.isode.stroke.crypto.CryptoProvider;
+import com.isode.stroke.crypto.JavaCryptoProvider;
import com.isode.stroke.elements.IQ;
+import com.isode.stroke.elements.Presence;
import com.isode.stroke.elements.VCard;
-import com.isode.stroke.avatars.VCardUpdateAvatarManager;
-import com.isode.stroke.avatars.VCardAvatarManager;
-import com.isode.stroke.avatars.AvatarMemoryStorage;
-import com.isode.stroke.vcards.VCardMemoryStorage;
-import com.isode.stroke.vcards.VCardManager;
+import com.isode.stroke.elements.VCardUpdate;
+import com.isode.stroke.jid.JID;
import com.isode.stroke.muc.MUCRegistry;
import com.isode.stroke.queries.IQRouter;
-import com.isode.stroke.client.DummyStanzaChannel;
-import com.isode.stroke.crypto.JavaCryptoProvider;
-import com.isode.stroke.crypto.CryptoProvider;
import com.isode.stroke.stringcodecs.Hexify;
-import com.isode.stroke.jid.JID;
-import com.isode.stroke.base.ByteArray;
-import com.isode.stroke.signals.SignalConnection;
-import com.isode.stroke.signals.Slot1;
+import com.isode.stroke.vcards.VCardManager;
+import com.isode.stroke.vcards.VCardMemoryStorage;
public class AvatarManagerImplTest {
@@ -75,8 +74,8 @@ public class AvatarManagerImplTest {
public void testGetSetAvatar() {
/* initially we have no knowledge of the user or their avatar */
JID personJID = new JID("person@domain.com/theperson");
- ByteArray avatar = avatarManager.getAvatar(personJID.toBare());
- assertTrue(avatar.getSize() == 0);
+ String avatar = avatarManager.getAvatar(personJID.toBare());
+ assertTrue(avatar == null);
/* notify the 'owner' JID that our avatar has changed */
@@ -109,8 +108,8 @@ public class AvatarManagerImplTest {
/* check hash through avatarManager that it received the correct photo */
- ByteArray reportedAvatar = avatarManager.getAvatar(personJID.toBare());
- assertEquals(fullAvatar.toString(), reportedAvatar.toString());
+ String reportedAvatar = avatarManager.getAvatar(personJID.toBare());
+ assertEquals(fullAvatar.toString(), avatarStorage.getAvatarBytes(reportedAvatar).toString());
/* send new presence to notify of blank avatar */
@@ -143,6 +142,6 @@ public class AvatarManagerImplTest {
/* check hash through avatarManager that it received the correct photo */
reportedAvatar = avatarManager.getAvatar(personJID.toBare());
- assertEquals(blankAvatar.toString(), reportedAvatar.toString());
+ assertNull(reportedAvatar); // Empty photo => empty hash => null Avatar
}
} \ No newline at end of file
diff --git a/test/com/isode/stroke/avatars/VCardAvatarManagerTest.java b/test/com/isode/stroke/avatars/VCardAvatarManagerTest.java
index 56121ac..303ed1b 100755
--- a/test/com/isode/stroke/avatars/VCardAvatarManagerTest.java
+++ b/test/com/isode/stroke/avatars/VCardAvatarManagerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2013 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -30,7 +30,6 @@ import com.isode.stroke.client.DummyStanzaChannel;
import com.isode.stroke.crypto.JavaCryptoProvider;
import com.isode.stroke.crypto.CryptoProvider;
import com.isode.stroke.stringcodecs.Hexify;
-import com.isode.stroke.signals.SignalConnection;
import com.isode.stroke.signals.Slot1;
import com.isode.stroke.elements.IQ;
@@ -59,9 +58,7 @@ public class VCardAvatarManagerTest {
private String avatar1Hash;
private Vector<JID> changes;
private JID user1;
- private JID user2;
private CryptoProvider crypto;
- private SignalConnection onAvatarChangedConnection;
@Before
public void setUp() {
@@ -78,12 +75,11 @@ public class VCardAvatarManagerTest {
avatar1Hash = Hexify.hexify(crypto.getSHA1Hash(avatar1));
changes = new Vector<JID>();
user1 = new JID("user1@bar.com/bla");
- user2 = new JID("user2@foo.com/baz");
}
private VCardAvatarManager createManager() {
VCardAvatarManager result = new VCardAvatarManager(vcardManager, avatarStorage, crypto, mucRegistry);
- onAvatarChangedConnection = result.onAvatarChanged.connect(new Slot1<JID>() {
+ result.onAvatarChanged.connect(new Slot1<JID>() {
public void call(JID j1) {
handleAvatarChanged(j1);
@@ -143,7 +139,7 @@ public class VCardAvatarManagerTest {
assertNotNull(result);
assertEquals(avatar1Hash, result);
assertTrue(avatarStorage.hasAvatar(avatar1Hash));
- assertEquals(avatar1, avatarStorage.getAvatar(avatar1Hash));
+ assertEquals(avatar1, avatarStorage.getAvatarBytes(avatar1Hash));
}
@Test
diff --git a/test/com/isode/stroke/avatars/VCardUpdateAvatarManagerTest.java b/test/com/isode/stroke/avatars/VCardUpdateAvatarManagerTest.java
index 1030d5d..95ccf7a 100755
--- a/test/com/isode/stroke/avatars/VCardUpdateAvatarManagerTest.java
+++ b/test/com/isode/stroke/avatars/VCardUpdateAvatarManagerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2013 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -23,7 +23,6 @@ import com.isode.stroke.elements.Presence;
import com.isode.stroke.elements.IQ;
import com.isode.stroke.elements.VCard;
import com.isode.stroke.avatars.VCardUpdateAvatarManager;
-import com.isode.stroke.avatars.VCardAvatarManager;
import com.isode.stroke.avatars.AvatarMemoryStorage;
import com.isode.stroke.vcards.VCardMemoryStorage;
import com.isode.stroke.vcards.VCardManager;
@@ -35,7 +34,6 @@ import com.isode.stroke.crypto.CryptoProvider;
import com.isode.stroke.stringcodecs.Hexify;
import com.isode.stroke.jid.JID;
import com.isode.stroke.base.ByteArray;
-import com.isode.stroke.signals.SignalConnection;
import com.isode.stroke.signals.Slot1;
public class VCardUpdateAvatarManagerTest {
@@ -62,7 +60,6 @@ public class VCardUpdateAvatarManagerTest {
private JID user1;
private JID user2;
private CryptoProvider crypto;
- private SignalConnection onAvatarChangedConnection;
@Before
public void setUp() {
@@ -84,7 +81,7 @@ public class VCardUpdateAvatarManagerTest {
private VCardUpdateAvatarManager createManager() {
VCardUpdateAvatarManager result = new VCardUpdateAvatarManager(vcardManager, stanzaChannel, avatarStorage, crypto, mucRegistry);
- onAvatarChangedConnection = result.onAvatarChanged.connect(new Slot1<JID>() {
+ result.onAvatarChanged.connect(new Slot1<JID>() {
public void call(JID j1) {
handleAvatarChanged(j1);
@@ -133,7 +130,7 @@ public class VCardUpdateAvatarManagerTest {
assertNotNull(hash);
assertEquals(avatar1Hash, hash);
assertTrue(avatarStorage.hasAvatar(avatar1Hash));
- assertEquals(avatar1, avatarStorage.getAvatar(avatar1Hash));
+ assertEquals(avatar1, avatarStorage.getAvatarBytes(avatar1Hash));
}
@Test