1717import org .locationtech .jts .io .ParseException ;
1818import org .locationtech .jts .io .WKTReader ;
1919
20- import junit .framework .TestCase ;
2120import junit .textui .TestRunner ;
21+ import test .jts .GeometryTestCase ;
2222
2323
2424/**
2525 * Tests for {@link GeometryFactory}.
2626 *
2727 * @version 1.13
2828 */
29- public class GeometryFactoryTest extends TestCase {
29+ public class GeometryFactoryTest extends GeometryTestCase {
3030
3131 PrecisionModel precisionModel = new PrecisionModel ();
3232 GeometryFactory geometryFactory = new GeometryFactory (precisionModel , 0 );
@@ -38,18 +38,27 @@ public static void main(String args[]) {
3838
3939 public GeometryFactoryTest (String name ) { super (name ); }
4040
41- public void testCreateGeometry () throws ParseException
41+ public void testCreateGeometry ()
4242 {
43- checkCreateGeometryExact ("POINT EMPTY" );
4443 checkCreateGeometryExact ("POINT ( 10 20 )" );
45- checkCreateGeometryExact ("LINESTRING EMPTY " );
44+ checkCreateGeometryExact ("MULTIPOINT ( (10 20), (30 40) ) " );
4645 checkCreateGeometryExact ("LINESTRING(0 0, 10 10)" );
4746 checkCreateGeometryExact ("MULTILINESTRING ((50 100, 100 200), (100 100, 150 200))" );
4847 checkCreateGeometryExact ("POLYGON ((100 200, 200 200, 200 100, 100 100, 100 200))" );
4948 checkCreateGeometryExact ("MULTIPOLYGON (((100 200, 200 200, 200 100, 100 100, 100 200)), ((300 200, 400 200, 400 100, 300 100, 300 200)))" );
5049 checkCreateGeometryExact ("GEOMETRYCOLLECTION (POLYGON ((100 200, 200 200, 200 100, 100 100, 100 200)), LINESTRING (250 100, 350 200), POINT (350 150))" );
5150 }
5251
52+ public void testCreateGeometryEmpty () {
53+ checkCreateGeometryExact ("POINT EMPTY" );
54+ checkCreateGeometryExact ("LINESTRING EMPTY" );
55+ checkCreateGeometryExact ("POLYGON EMPTY" );
56+ checkCreateGeometryExact ("MULTIPOINT EMPTY" );
57+ checkCreateGeometryExact ("MULTILINESTRING EMPTY" );
58+ checkCreateGeometryExact ("MULTIPOLYGON EMPTY" );
59+ checkCreateGeometryExact ("GEOMETRYCOLLECTION EMPTY" );
60+ }
61+
5362 public void testCreateEmpty () {
5463 checkEmpty ( geometryFactory .createEmpty (0 ), Point .class );
5564 checkEmpty ( geometryFactory .createEmpty (1 ), LineString .class );
@@ -70,7 +79,7 @@ private void checkEmpty(Geometry geom, Class clz) {
7079 assertTrue ( geom .getClass () == clz );
7180 }
7281
73- public void testDeepCopy () throws ParseException
82+ public void testDeepCopy ()
7483 {
7584 Point g = (Point ) read ("POINT ( 10 10) " );
7685 Geometry g2 = geometryFactory .createGeometry (g );
@@ -100,7 +109,7 @@ public void testMultiPointCS()
100109 *
101110 * @throws ParseException
102111 */
103- public void testCopyGeometryWithNonDefaultDimension () throws ParseException
112+ public void testCopyGeometryWithNonDefaultDimension ()
104113 {
105114 GeometryFactory gf = new GeometryFactory (CoordinateArraySequenceFactory .instance ());
106115 CoordinateSequence mpSeq = gf .getCoordinateSequenceFactory ().create (1 , 2 );
@@ -116,15 +125,13 @@ public void testCopyGeometryWithNonDefaultDimension() throws ParseException
116125
117126 }
118127
119- private void checkCreateGeometryExact (String wkt ) throws ParseException
128+ private void checkCreateGeometryExact (String wkt )
120129 {
121130 Geometry g = read (wkt );
122131 Geometry g2 = geometryFactory .createGeometry (g );
123132 assertTrue (g .equalsExact (g2 ));
133+ // check a copy has been made
134+ assertTrue (g != g2 );
124135 }
125136
126- private Geometry read (String wkt ) throws ParseException
127- {
128- return reader .read (wkt );
129- }
130137}
0 commit comments