### Question:
GeoJsonWriter { private void writeFeatureCollection(JSONStringer b, GeometryCollection g) throws JSONException { b.object(); b.key(TYPE).value("FeatureCollection"); b.key(FEATURES).array(); for (int i = 0; i < g.getNumGeometries(); i++) { writeFeature(b, g.getGeometryN(i)); } b.endArray(); b.endObject(); }  String write(Geometry geometry);  }### Answer:
@Test public void writeFeatureCollection() { GeometryCollection g = factory.createGeometryCollection(new Geometry[]{ factory.createPoint(p(5,10)), factory.createLineString(new Coordinate[]{p(5,10),p(10,5)}) }); assertEquals("{\"type\":\"FeatureCollection\",\"features\":[" + "{\"type\":\"Feature\",\"properties\":{},\"geometry\":" + "{\"type\":\"Point\",\"coordinates\":[5,10]}}," + "{\"type\":\"Feature\",\"properties\":{},\"geometry\":" + "{\"type\":\"LineString\",\"coordinates\":[[5,10],[10,5]]}}" + "]}", write(g)); }