package org.scotlandyard.tests.engine.json;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.scotlandyard.engine.json.ExceptionJsonContainer;
/**
* TODO add a description for this class
*
*
* @author Hussain Al-Mutawa
* @version 1.0
* @since Sun Sep 23, 2011
*/
public class ExceptionJsonContainerTest {
@Test //TODO add description of what the test should do
public void testNewExceptionJsonContainer() {
final Exception exp = new Exception("My Error");
final ExceptionJsonContainer ejc = new ExceptionJsonContainer(exp);
final String json = ejc.toJson();
assertTrue("test json",json.contains("My Error"));
final ExceptionJsonContainer conv = ejc.fromJson(json);
assertEquals("test cast conversion 1",conv.message,"My Error");
assertEquals("test cast conversion 2",conv.exceptionStack.size(),exp.getStackTrace().length);
assertEquals("test cast conversion 3",conv.exceptionStack.get(1),exp.getStackTrace()[1].toString());
}
}