circle.setLineStyle(LineStyle.solid);
circle.setPositionX(8);
circle.setPositionY(9);
circle.setRadius(10);
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
ObjectMapper circleMapper = provider.locateMapper(Circle.class, MediaType.APPLICATION_JSON_TYPE);
ObjectMapper clientMapper = new ObjectMapper();
ByteArrayOutputStream out = new ByteArrayOutputStream();
circleMapper.writeValue(out, circle);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
shapes.json.Circle clientCircle = clientMapper.readValue(in, shapes.json.Circle.class);
assertSame(shapes.json.Color.BLUE, clientCircle.getColor());
assertEquals("someid", clientCircle.getId());
assertEquals(shapes.json.LineStyle.solid, clientCircle.getLineStyle());
assertEquals(8, clientCircle.getPositionX());
assertEquals(9, clientCircle.getPositionY());
assertEquals(10, clientCircle.getRadius());
out = new ByteArrayOutputStream();
clientMapper.writeValue(out, clientCircle);
in = new ByteArrayInputStream(out.toByteArray());
circle = circleMapper.readValue(in, Circle.class);
assertSame(Color.BLUE, circle.getColor());
assertEquals("someid", circle.getId());
assertEquals(LineStyle.solid, circle.getLineStyle());
assertEquals(8, circle.getPositionX());
assertEquals(9, circle.getPositionY());
assertEquals(10, circle.getRadius());
ObjectMapper rectangleMapper = provider.locateMapper(Rectangle.class, MediaType.APPLICATION_JSON_TYPE);
Rectangle rectangle = new Rectangle();
rectangle.setColor(Color.GREEN);
rectangle.setId("rectid");
rectangle.setHeight(500);
rectangle.setWidth(1000);
rectangle.setLineStyle(LineStyle.dotted);
rectangle.setPositionX(-100);
rectangle.setPositionY(-300);
out = new ByteArrayOutputStream();
rectangleMapper.writeValue(out, rectangle);
in = new ByteArrayInputStream(out.toByteArray());
shapes.json.Rectangle clientRect = clientMapper.readValue(in, shapes.json.Rectangle.class);
assertSame(shapes.json.Color.GREEN, clientRect.getColor());
assertEquals("rectid", clientRect.getId());
assertEquals(shapes.json.LineStyle.dotted, clientRect.getLineStyle());
assertEquals(500, clientRect.getHeight());
assertEquals(1000, clientRect.getWidth());
assertEquals(-100, clientRect.getPositionX());
assertEquals(-300, clientRect.getPositionY());
out = new ByteArrayOutputStream();
clientMapper.writeValue(out, clientRect);
in = new ByteArrayInputStream(out.toByteArray());
rectangle = rectangleMapper.readValue(in, Rectangle.class);
assertSame(Color.GREEN, rectangle.getColor());
assertEquals("rectid", rectangle.getId());
assertEquals(LineStyle.dotted, rectangle.getLineStyle());
assertEquals(500, rectangle.getHeight());
assertEquals(1000, rectangle.getWidth());
assertEquals(-100, rectangle.getPositionX());
assertEquals(-300, rectangle.getPositionY());
ObjectMapper triangleMapper = provider.locateMapper(Triangle.class, MediaType.APPLICATION_JSON_TYPE);
Triangle triangle = new Triangle();
triangle.setBase(90);
triangle.setColor(Color.RED);
triangle.setHeight(100);