source: references/src/test/java/geniusweb/references/DomainRefTest.java@ 52

Last change on this file since 52 was 52, checked in by ruud, 14 months ago

Fixed small issues in domaineditor.

File size: 1.6 KB
Line 
1package geniusweb.references;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.net.MalformedURLException;
7import java.net.URI;
8import java.net.URISyntaxException;
9import java.util.Arrays;
10import java.util.List;
11
12import org.junit.Before;
13import org.junit.Test;
14
15import com.fasterxml.jackson.core.JsonProcessingException;
16import com.fasterxml.jackson.databind.ObjectMapper;
17
18import geniusweb.references.DomainRef;
19import tudelft.utilities.junit.GeneralTests;
20
21public class DomainRefTest extends GeneralTests<DomainRef> {
22
23 private static final String HTTP_A = "http://a",
24 HTTP_B = "http://there/whatever";
25 private ObjectMapper jackson = new ObjectMapper();
26
27 private String domainrefstring = "\"" + HTTP_B + "\"";
28 private DomainRef ref1, ref1a, ref2;
29
30 @Before
31 public void before() throws MalformedURLException, URISyntaxException {
32 ref1 = new DomainRef(HTTP_A);
33 ref1a = new DomainRef(HTTP_A);
34 ref2 = new DomainRef(new URI(HTTP_B));
35 }
36
37 @Test
38 public void SerializeTest() throws JsonProcessingException {
39 System.out.println(jackson.writeValueAsString(ref2));
40 assertEquals(domainrefstring, jackson.writeValueAsString(ref2));
41
42 }
43
44 @Test
45 public void DeSerializeTest() throws IOException {
46 assertEquals(ref2, jackson.readValue(domainrefstring, DomainRef.class));
47
48 }
49
50 @Override
51 public List<List<DomainRef>> getGeneralTestData() {
52 return Arrays.asList(Arrays.asList(ref1, ref1a), Arrays.asList(ref2));
53 }
54
55 @Override
56 public List<String> getGeneralTestStrings() {
57 return Arrays.asList("DomainRef." + HTTP_A + ".",
58 "DomainRef." + HTTP_B + ".");
59
60 }
61}
Note: See TracBrowser for help on using the repository browser.