Forked from
IT1901 / course-material
273 commits behind the upstream repository.
-
Hallvard Trætteberg authoredHallvard Trætteberg authored
LatLongJsonTest.java 982 B
package simpleex.json;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
import simpleex.core.LatLong;
public class LatLongJsonTest extends AbstractJsonTest {
@Before
@Override
public void setUp() {
super.setUp();
}
@Override
protected ObjectMapper createObjectMapper() {
return createObjectMapper(LatLong.class, new LatLongSerializer(), new LatLongDeserializer());
}
@Test
public void testLatLongSerialization() throws Exception {
assertWriteValue("{\"latitude\":63.1,\"longitude\":12.3}", new LatLong(63.1, 12.3));
}
@Test
public void testLatLongObjectDeserialization() throws Exception {
Assert.assertEquals(new LatLong(63.1, 12.3), readValue("{\"latitude\":63.1,\"longitude\":12.3}", LatLong.class));
}
@Test
public void testLatLongArrayDeserialization() throws Exception {
Assert.assertEquals(new LatLong(63.1, 12.3), readValue("[ 63.1, 12.3 ]", LatLong.class));
}
}