X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2FTestUserSerialize.java;fp=tests%2Forg%2Fcacert%2Fgigi%2FTestUserSerialize.java;h=0000000000000000000000000000000000000000;hp=91c1dfd437ab5eff0f27a731df0783ff356ee975;hb=bccd4cc0dba0f89aa045b113bac46eb8cc1dab4e;hpb=c9ed09f0007fc2c813815be927a5a24b23dab83c diff --git a/tests/org/cacert/gigi/TestUserSerialize.java b/tests/org/cacert/gigi/TestUserSerialize.java deleted file mode 100644 index 91c1dfd4..00000000 --- a/tests/org/cacert/gigi/TestUserSerialize.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.cacert.gigi; - -import static org.junit.Assert.*; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; - -import org.cacert.gigi.dbObjects.User; -import org.cacert.gigi.testUtils.BusinessTest; -import org.junit.Test; - -public class TestUserSerialize extends BusinessTest { - - private byte[] serialize(Object o) throws IOException { - try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { - oos.writeObject(o); - oos.flush(); - } - baos.flush(); - return baos.toByteArray(); - } - } - - private Object deserialize(byte[] ba) throws IOException, ClassNotFoundException { - try (ByteArrayInputStream bais = new ByteArrayInputStream(ba)) { - try (ObjectInputStream ois = new ObjectInputStream(bais)) { - Object o = ois.readObject(); - return o; - } - } - } - - @Test - public void testSerializeUser() throws GigiApiException, IOException, ClassNotFoundException { - User u = createVerifiedUser(); - byte[] ba = serialize(u); - Object uo = deserialize(ba); - assertSame("Original user and the deserialized object must be the same", u, uo); - } - -}