@Test public void testGetRequestsJoin() throws Exception { List<RequestData> datas = dao.getRequests(new Query().properties("path", "resource") .filter("path","/foo", Comparison.EQ). group("path", "resource") .sort("resource", SortOrder.ASC)); assertEquals(3, datas.size()); assertEquals("stuff", datas.get(0).getResources().get(0)); assertEquals("things", datas.get(1).getResources().get(0)); assertEquals("widgets", datas.get(2).getResources().get(0)); } @Test
@Test public void testGetRequestsJoinIN() throws Exception { List<String> resources = Arrays.asList("widgets", "things"); List<RequestData> datas = dao.getRequests(new Query().properties("resource") .aggregate("count()").filter("resource", resources, Comparison.IN) .group("resource").sort("resource", SortOrder.ASC)); assertEquals(2, datas.size()); assertEquals("things", datas.get(0).getResources().get(0)); assertEquals("widgets", datas.get(1).getResources().get(0)); }
@Test public void testUpdate() throws Exception { RequestData data = dao.getRequest(1); data.setPath("/one_updated"); dao.update(data); data = dao.getRequest(1); assertEquals("/one_updated", data.getPath()); data.getResources().add("one_layer"); dao.update(data); data = dao.getRequest(1); assertEquals(1, data.getResources().size()); assertEquals("one_layer", data.getResources().get(0)); }
@Test public void testUpdate() throws Exception { RequestData data = dao.getRequest(1); data.setPath("/one_updated"); dao.update(data); data = dao.getRequest(1); assertEquals("/one_updated", data.getPath()); data.getResources().add("one_layer"); dao.update(data); data = dao.getRequest(1); assertEquals(1, data.getResources().size()); assertEquals("one_layer", data.getResources().get(0)); }
@Test public void testWFSDescribeFeatureType() throws Exception { DescribeFeatureTypeType dft = WfsFactory.eINSTANCE.createDescribeFeatureTypeType(); dft.getTypeName().add(new QName("http://acme.org", "foo", "acme")); dft.getTypeName().add(new QName("http://acme.org", "bar", "acme")); Operation op = op("DescribeFeatureType", "WFS", "1.0.0", dft); callback.operationDispatched(new Request(), op); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); }
@Test public void testWFSDescribeFeatureType() throws Exception { DescribeFeatureTypeType dft = WfsFactory.eINSTANCE.createDescribeFeatureTypeType(); dft.getTypeName().add(new QName("http://acme.org", "foo", "acme")); dft.getTypeName().add(new QName("http://acme.org", "bar", "acme")); Operation op = op("DescribeFeatureType", "WFS", "1.0.0", dft); callback.operationDispatched(new Request(), op); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); }
@Test public void testWCS10DescribeCoverage() throws Exception { DescribeCoverageType dc = Wcs10Factory.eINSTANCE.createDescribeCoverageType(); dc.getCoverage().add("acme:foo"); dc.getCoverage().add("acme:bar"); callback.operationDispatched(new Request(), op("DescribeCoverage", "WCS", "1.0.0", dc)); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); }
@Test public void testWCS11DescribeCoverage() throws Exception { net.opengis.wcs11.DescribeCoverageType dc = Wcs11Factory.eINSTANCE.createDescribeCoverageType(); dc.getIdentifier().add("acme:foo"); dc.getIdentifier().add("acme:bar"); callback.operationDispatched(new Request(), op("DescribeCoverage", "WCS", "1.1.0", dc)); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); }
@Test public void testWCS10DescribeCoverage() throws Exception { DescribeCoverageType dc = Wcs10Factory.eINSTANCE.createDescribeCoverageType(); dc.getCoverage().add("acme:foo"); dc.getCoverage().add("acme:bar"); callback.operationDispatched(new Request(), op("DescribeCoverage", "WCS", "1.0.0", dc)); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); }
@Test public void testWCS11DescribeCoverage() throws Exception { net.opengis.wcs11.DescribeCoverageType dc = Wcs11Factory.eINSTANCE.createDescribeCoverageType(); dc.getIdentifier().add("acme:foo"); dc.getIdentifier().add("acme:bar"); callback.operationDispatched(new Request(), op("DescribeCoverage", "WCS", "1.1.0", dc)); assertEquals("acme:foo", data.getResources().get(0)); assertEquals("acme:bar", data.getResources().get(1)); }
@Test public void testWMSGetLegendGraphic() throws Exception { WMS wms = new WMS(createMock(GeoServer.class)); GetLegendGraphicRequest glg = new GetLegendGraphicRequest(); FeatureType type = createMock(FeatureType.class); expect(type.getName()).andReturn(new NameImpl("http://acme.org", "foo")).anyTimes(); replay(type); glg.setLayer(type); callback.operationDispatched(new Request(), op("GetFeatureInfo", "WMS", "1.1.1", glg)); assertEquals("http://acme.org:foo", data.getResources().get(0)); }
@Test public void testWMSGetLegendGraphic() throws Exception { WMS wms = new WMS(createMock(GeoServer.class)); GetLegendGraphicRequest glg = new GetLegendGraphicRequest(); FeatureType type = createMock(FeatureType.class); expect(type.getName()).andReturn(new NameImpl("http://acme.org", "foo")).anyTimes(); replay(type); glg.setLayer(type); callback.operationDispatched(new Request(), op("GetFeatureInfo", "WMS", "1.1.1", glg)); assertEquals("http://acme.org:foo", data.getResources().get(0)); }
@Test public void testURLEncodedRequestPathInfo() throws Exception { MockHttpServletResponse response = getAsServletResponse(RestBaseController.ROOT_PATH + "/layers/foo"); assertEquals(404, response.getStatus()); assertEquals("foo", data.getResources().get(1)); response = getAsServletResponse(RestBaseController.ROOT_PATH + "/layers/acme:foo"); assertEquals(404, response.getStatus()); assertEquals("acme:foo", data.getResources().get(2)); response = getAsServletResponse(RestBaseController.ROOT_PATH + "acme:foo"); assertEquals(404, response.getStatus()); assertEquals("acme:foo", data.getResources().get(3)); } }
@Test public void testWFSLockFeature() throws Exception { LockFeatureType lf = WfsFactory.eINSTANCE.createLockFeatureType(); LockType l = WfsFactory.eINSTANCE.createLockType(); l.setTypeName(new QName("http://acme.org", "foo", "acme")); lf.getLock().add(l); Operation op = op("LockFeature", "WFS", "1.0.0", lf); callback.operationDispatched(new Request(), op); assertEquals("acme:foo", data.getResources().get(0)); }
@Test public void testWFSLockFeature() throws Exception { LockFeatureType lf = WfsFactory.eINSTANCE.createLockFeatureType(); LockType l = WfsFactory.eINSTANCE.createLockType(); l.setTypeName(new QName("http://acme.org", "foo", "acme")); lf.getLock().add(l); Operation op = op("LockFeature", "WFS", "1.0.0", lf); callback.operationDispatched(new Request(), op); assertEquals("acme:foo", data.getResources().get(0)); }
@Test public void testWMSReflect() throws Exception { GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); callback.operationDispatched(new Request(), op("reflect", "WMS", "1.1.1", gm)); assertEquals("acme:foo", data.getResources().get(0)); }
@Test public void testWMSGetMapDifferentCrs() throws Exception { //xMin,yMin 5988504.35,851278.90 : xMax,yMax 7585113.55,1950872.01 //xMin,yMin -95.1193,42.2802 : xMax,yMax -71.295,53.73 GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); Envelope env = new Envelope(5988504.35, 7585113.55, 851278.90, 1950872.01); CoordinateReferenceSystem crs = CRS.decode("EPSG:3348", true); gm.setBbox(env); gm.setCrs(crs); callback.operationDispatched(new Request(), op("GetMap", "WMS", "1.1.1", gm)); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326", false); BoundingBox bbox = new ReferencedEnvelope(42.2802, 53.73, -95.1193, -71.295, logCrs); assertEquals("acme:foo", data.getResources().get(0)); BBoxAsserts.assertEqualsBbox(bbox, data.getBbox(), 0.1); }
@Test public void testWMSGetMap() throws Exception { GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); Envelope env = new Envelope(100,110,70,80); CoordinateReferenceSystem crs = CRS.decode("EPSG:4326", true); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326"); gm.setBbox(env); gm.setCrs(crs); callback.operationDispatched(new Request(), op("GetMap", "WMS", "1.1.1", gm)); assertEquals("acme:foo", data.getResources().get(0)); BBoxAsserts.assertEqualsBbox(new ReferencedEnvelope(env,crs).toBounds(logCrs), data.getBbox(), 0.1); }
@Test public void testWMSGetMap() throws Exception { GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); Envelope env = new Envelope(100, 110, 70, 80); CoordinateReferenceSystem crs = CRS.decode("EPSG:4326", true); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326"); gm.setBbox(env); gm.setCrs(crs); callback.operationDispatched(new Request(), op("GetMap", "WMS", "1.1.1", gm)); assertEquals("acme:foo", data.getResources().get(0)); BBoxAsserts.assertEqualsBbox( new ReferencedEnvelope(env, crs).toBounds(logCrs), data.getBbox(), 0.1); }
@Test public void testWMSGetMapDifferentCrs() throws Exception { // xMin,yMin 5988504.35,851278.90 : xMax,yMax 7585113.55,1950872.01 // xMin,yMin -95.1193,42.2802 : xMax,yMax -71.295,53.73 GetMapRequest gm = new GetMapRequest(); gm.setLayers(Arrays.asList(createMapLayer("foo", "acme"))); Envelope env = new Envelope(5988504.35, 7585113.55, 851278.90, 1950872.01); CoordinateReferenceSystem crs = CRS.decode("EPSG:3348", true); gm.setBbox(env); gm.setCrs(crs); callback.operationDispatched(new Request(), op("GetMap", "WMS", "1.1.1", gm)); CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326", false); BoundingBox bbox = new ReferencedEnvelope(42.2802, 53.73, -95.1193, -71.295, logCrs); assertEquals("acme:foo", data.getResources().get(0)); BBoxAsserts.assertEqualsBbox(bbox, data.getBbox(), 0.1); }