package geniusweb.references; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.util.Arrays; import java.util.List; import org.junit.Before; import org.junit.Test; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import geniusweb.references.DomainRef; import tudelft.utilities.junit.GeneralTests; public class DomainRefTest extends GeneralTests { private static final String HTTP_A = "http://a", HTTP_B = "http://there/whatever"; private ObjectMapper jackson = new ObjectMapper(); private String domainrefstring = "\"" + HTTP_B + "\""; private DomainRef ref1, ref1a, ref2; @Before public void before() throws MalformedURLException, URISyntaxException { ref1 = new DomainRef(HTTP_A); ref1a = new DomainRef(HTTP_A); ref2 = new DomainRef(new URI(HTTP_B)); } @Test public void SerializeTest() throws JsonProcessingException { System.out.println(jackson.writeValueAsString(ref2)); assertEquals(domainrefstring, jackson.writeValueAsString(ref2)); } @Test public void DeSerializeTest() throws IOException { assertEquals(ref2, jackson.readValue(domainrefstring, DomainRef.class)); } @Override public List> getGeneralTestData() { return Arrays.asList(Arrays.asList(ref1, ref1a), Arrays.asList(ref2)); } @Override public List getGeneralTestStrings() { return Arrays.asList("DomainRef." + HTTP_A + ".", "DomainRef." + HTTP_B + "."); } }