/*
* Copyright (c) 2010 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
/*
* Copyright (c) 2015 Tarun Gupta.
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
package com.isode.stroke.serializer;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.isode.stroke.serializer.AuthRequestSerializer;
import com.isode.stroke.elements.AuthRequest;
import com.isode.stroke.base.ByteArray;
import com.isode.stroke.base.SafeByteArray;
public class AuthRequestSerializerTest {
/**
* Default Constructor.
*/
public AuthRequestSerializerTest() {
}
@Test
public void testSerialize() {
AuthRequestSerializer testling = new AuthRequestSerializer();
AuthRequest authRequest = new AuthRequest("PLAIN");
authRequest.setMessage(new SafeByteArray("foo"));
assertEquals(
new SafeByteArray("" +
"Zm9v" +
""), testling.serialize(authRequest));
}
@Test
public void testSerialize_NoMessage() {
AuthRequestSerializer testling = new AuthRequestSerializer();
AuthRequest authRequest = new AuthRequest("PLAIN");
assertEquals(
new SafeByteArray("" +
""), testling.serialize(authRequest));
}
@Test
public void testSerialize_EmptyMessage() {
AuthRequestSerializer testling = new AuthRequestSerializer();
AuthRequest authRequest = new AuthRequest("PLAIN");
authRequest.setMessage(new SafeByteArray());
assertEquals(
new SafeByteArray("" +
"=" +
""), testling.serialize(authRequest));
}
}