public void testStringToGeometry() throws Exception {
   Geometry geometry =
       factory
           .createConverter(String.class, Geometry.class, null)
           .convert("POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))", Geometry.class);
   assertNotNull(geometry);
   assertTrue(
       new GeometryFactory()
           .createPolygon(
               new GeometryFactory()
                   .createLinearRing(
                       new Coordinate[] {
                         new Coordinate(0, 0),
                         new Coordinate(1, 0),
                         new Coordinate(1, 1),
                         new Coordinate(0, 1),
                         new Coordinate(0, 0)
                       }),
               null)
           .equalsTopo(geometry));
 }
 public void testEnvelopeToGeometry() throws Exception {
   Geometry geometry =
       factory
           .createConverter(Envelope.class, Geometry.class, null)
           .convert(new Envelope(new Coordinate(0, 0), new Coordinate(1, 1)), Geometry.class);
   assertNotNull(geometry);
   assertTrue(
       new GeometryFactory()
           .createPolygon(
               new GeometryFactory()
                   .createLinearRing(
                       new Coordinate[] {
                         new Coordinate(0, 0),
                         new Coordinate(1, 0),
                         new Coordinate(1, 1),
                         new Coordinate(0, 1),
                         new Coordinate(0, 0)
                       }),
               null)
           .equalsTopo(geometry));
 }
  public void testGeometryToEnvelope() throws Exception {
    Envelope envelope =
        factory
            .createConverter(Geometry.class, Envelope.class, null)
            .convert(
                new GeometryFactory()
                    .createPolygon(
                        new GeometryFactory()
                            .createLinearRing(
                                new Coordinate[] {
                                  new Coordinate(0, 0),
                                  new Coordinate(1, 0),
                                  new Coordinate(1, 1),
                                  new Coordinate(0, 1),
                                  new Coordinate(0, 0)
                                }),
                        null),
                Envelope.class);

    assertEquals(new Envelope(new Coordinate(0, 0), new Coordinate(1, 1)), envelope);
  }
  public void testGeometryToString() throws Exception {
    String wkt =
        factory
            .createConverter(Geometry.class, String.class, null)
            .convert(
                new GeometryFactory()
                    .createPolygon(
                        new GeometryFactory()
                            .createLinearRing(
                                new Coordinate[] {
                                  new Coordinate(0, 0),
                                  new Coordinate(1, 0),
                                  new Coordinate(1, 1),
                                  new Coordinate(0, 1),
                                  new Coordinate(0, 0)
                                }),
                        null),
                String.class);

    assertEquals("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", wkt);
  }