• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  package org.geojson.jackson;
2  
3  import com.fasterxml.jackson.databind.ObjectMapper;
4  import org.geojson.Crs;
5  import org.geojson.GeoJsonObject;
6  import org.geojson.Point;
7  import org.junit.Test;
8  
9  import static org.junit.Assert.assertEquals;
10  import static org.junit.Assert.assertNotNull;
11  
12  public class CrsTest {
13  
14  	private ObjectMapper mapper = new ObjectMapper();
15  
16  	@Test
itShouldParseCrsWithLink()17  	public void itShouldParseCrsWithLink() throws Exception {
18  		GeoJsonObject value = mapper.readValue("{\"crs\": { \"type\": \"link\", \"properties\": "
19  				+ "{ \"href\": \"http://example.com/crs/42\", \"type\": \"proj4\" }},"
20  				+ "\"type\":\"Point\",\"coordinates\":[100.0,5.0]}", GeoJsonObject.class);
21  		assertNotNull(value);
22  		assertEquals(CrsType.link, value.getCrs().getType());
23  	}
24  
25  	@Test
itShouldSerializeCrsWithLink()26  	public void itShouldSerializeCrsWithLink() throws Exception {
27  		Point point = new Point();
28  		Crs crs = new Crs();
29  		crs.setType(CrsType.link);
30  		point.setCrs(crs);
31  		String value = mapper.writeValueAsString(point);
32  		assertEquals("{\"type\":\"Point\",\"crs\":{\"type\":\"link\",\"properties\":{}}}", value);
33  	}
34  }
35