OskariWFS110Client { protected static String getFilter(Filter filter) { if (filter == null) { return null; } try { Encoder encoder = new Encoder(new org.geotools.filter.v1_1.OGCConfiguration()); encoder.setOmitXMLDeclaration(true); return encoder.encodeAsString(filter, org.geotools.filter.v1_1.OGC.Filter); } catch (IOException e) { throw new ServiceRuntimeException("Failed to encode filter!", e); } } private  OskariWFS110Client(); static SimpleFeatureCollection getFeatures(OskariLayer layer,
            ReferencedEnvelope bbox, CoordinateReferenceSystem crs, Filter filter);  }
@Test public void testGetFilter() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Filter f = ff.equals(ff.property("bar"), ff.literal("foo")); String actual = OskariWFS110Client.getFilter(f); String expected = "<ogc:Filter xmlns:xs=\"http: + "<ogc:PropertyIsEqualTo matchCase=\"true\">" + "<ogc:PropertyName>bar</ogc:PropertyName>" + "<ogc:Literal>foo</ogc:Literal>" + "</ogc:PropertyIsEqualTo>" + "</ogc:Filter>"; assertEquals(expected, actual); }
@Test public void testGetFilterWitbBBox() throws Exception { FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Filter f = ff.equals(ff.property("bar"), ff.literal("foo")); Filter bboxFilter = ff.bbox("geometry", 382056, 6670472, 388896, 6674196, CRS.toSRS(CRS.decode("EPSG:3067"))); String actual = OskariWFS110Client.getFilter(ff.and(Arrays.asList(f, bboxFilter))); String expected = "<ogc:Filter xmlns:xs=\"http: "<ogc:And><ogc:PropertyIsEqualTo matchCase=\"true\"><ogc:PropertyName>bar</ogc:PropertyName><ogc:Literal>foo</ogc:Literal></ogc:PropertyIsEqualTo>" + "<ogc:BBOX><ogc:PropertyName>geometry</ogc:PropertyName><gml:Envelope srsDimension=\"2\" srsName=\"urn:x-ogc:def:crs:EPSG:3067\">" + "<gml:lowerCorner>382056 6670472</gml:lowerCorner><gml:upperCorner>388896 6674196</gml:upperCorner></gml:Envelope></ogc:BBOX></ogc:And></ogc:Filter>"; assertEquals(expected, actual); }