@Test
  public void testServerSideOnlyInfo() throws Exception {
    GetMapConfigurationRequest request = new GetMapConfigurationRequest();
    request.setApplicationId("appServerSideOnly");
    request.setMapId("mapServerSideOnly");
    GetMapConfigurationResponse response =
        (GetMapConfigurationResponse)
            dispatcher.execute(GetMapConfigurationRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
    ClientMapInfo mapInfo = response.getMapInfo();
    Assert.assertNotNull(mapInfo);

    // user data
    ClientUserDataInfo info = mapInfo.getUserData();
    Assert.assertNull(info);

    // widget data
    Assert.assertNotNull(mapInfo.getWidgetInfo());
    Assert.assertNull(mapInfo.getWidgetInfo("appDummy")); // not present
    Assert.assertNotNull(mapInfo.getWidgetInfo("layerTree")); // present
    Assert.assertNull(mapInfo.getWidgetInfo("mapDummy")); // filtered because ServerSideOnlyInfo

    // ViewBounds LimitOption
    Assert.assertEquals(
        BoundsLimitOption.COMPLETELY_WITHIN_MAX_BOUNDS, mapInfo.getViewBoundsLimitOption());
  }
コード例 #2
0
 @Test
 public void testSearchByPoint() throws Exception {
   String layer = "layerWmsCountries";
   SearchByPointRequest request = new SearchByPointRequest();
   request.setBbox(
       new Bbox(-3211986.0066263545, 98246.25012821658, 1.065471024672729E7, 3365675.229452881));
   request.setCrs("EPSG:900913");
   Map<String, String> layers = new HashMap<String, String>();
   layers.put(layer, layer);
   request.setLayerMapping(layers);
   request.setLocation(new Coordinate(672238.022713162, 2554015.0948743597));
   request.setScale(1.022083167709322E-4);
   CommandResponse response =
       dispatcher.execute(SearchByPointRequest.COMMAND, request, null, "en");
   Assert.assertFalse(response.isError());
   Assert.assertTrue(response instanceof SearchByPointResponse);
   SearchByPointResponse sbp = (SearchByPointResponse) response;
   Map<String, List<Feature>> map = sbp.getFeatureMap();
   Assert.assertNotNull(map);
   List<Feature> features = map.get(layer);
   Assert.assertEquals(1, features.size());
   Feature feature = features.get(0);
   Assert.assertEquals("belt.2", feature.getId());
   Assert.assertEquals("Tropical", feature.getAttributes().get("BELT").getValue());
   Assert.assertEquals("2", feature.getAttributes().get("FID").getValue());
 }
コード例 #3
0
 @Test
 public void testInvalidRequest() throws Exception {
   SearchByPointRequest request = new SearchByPointRequest();
   CommandResponse response =
       dispatcher.execute(SearchByPointRequest.COMMAND, request, null, "en");
   Assert.assertTrue(response.isError());
   List<Throwable> errors = response.getErrors();
   Assert.assertNotNull(errors);
   Assert.assertEquals(1, errors.size());
   Throwable error = errors.get(0);
   Assert.assertTrue(error instanceof GeomajasException);
   Assert.assertEquals(
       ExceptionCode.PARAMETER_MISSING, ((GeomajasException) error).getExceptionCode());
 }
  @Test
  public void testConvertMaxExtent() throws Exception {
    Layer layer = configurationService.getLayer("countries");
    Bbox configMaxExtent = layer.getLayerInfo().getMaxExtent();
    Assert.assertEquals(-85.05112877980659, configMaxExtent.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(-85.05112877980659, configMaxExtent.getY(), DOUBLE_TOLERANCE);
    Assert.assertEquals(170.102257, configMaxExtent.getWidth(), DOUBLE_TOLERANCE);
    Assert.assertEquals(170.102257, configMaxExtent.getHeight(), DOUBLE_TOLERANCE);

    GetMapConfigurationRequest request = new GetMapConfigurationRequest();
    request.setApplicationId("simplevectors");
    request.setMapId("coordTestMap");
    GetMapConfigurationResponse response =
        (GetMapConfigurationResponse)
            dispatcher.execute(GetMapConfigurationRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
    ClientMapInfo mapInfo = response.getMapInfo();
    Assert.assertNotNull(mapInfo);
    Bbox mapMaxExtent = mapInfo.getLayers().get(0).getMaxExtent();
    // these values were registered during a first run, they have *not* been externally verified
    Assert.assertEquals(-9467848.347161204, mapMaxExtent.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(-2.0037508342789236E7, mapMaxExtent.getY(), DOUBLE_TOLERANCE);
    Assert.assertEquals(1.8935696632026553E7, mapMaxExtent.getWidth(), DOUBLE_TOLERANCE);
    Assert.assertEquals(4.007501596344786E7, mapMaxExtent.getHeight(), DOUBLE_TOLERANCE);

    // user data
    ClientUserDataInfo info = mapInfo.getUserData();
    Assert.assertNotNull(info);
    Assert.assertTrue(info instanceof ClientApplicationInfo.DummyClientUserDataInfo);
    Assert.assertEquals(
        "some data", ((ClientApplicationInfo.DummyClientUserDataInfo) info).getDummy());

    // widget data
    Assert.assertNotNull(mapInfo.getWidgetInfo());
    Assert.assertNull(mapInfo.getWidgetInfo("mapSelect"));
    Assert.assertNotNull(mapInfo.getWidgetInfo("layerTree"));
    Assert.assertEquals(
        "layer1, layer2",
        ((ClientApplicationInfo.DummyClientWidgetInfo) mapInfo.getWidgetInfo("layerTree"))
            .getDummy());
    // Default value of ViewBounds LimitOption
    BoundsLimitOption boundsLimitOption = mapInfo.getViewBoundsLimitOption();
    Assert.assertNotNull(info);
    Assert.assertEquals(BoundsLimitOption.COMPLETELY_WITHIN_MAX_BOUNDS, boundsLimitOption);
  }
  @Test
  public void testViewBoundsLimitOption() throws Exception {
    GetMapConfigurationRequest request = new GetMapConfigurationRequest();
    request.setApplicationId("vectorsMapWithViewBoundsOption");
    request.setMapId("viewBoundsLimitTestMap");
    GetMapConfigurationResponse response =
        (GetMapConfigurationResponse)
            dispatcher.execute(GetMapConfigurationRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
    ClientMapInfo mapInfo = response.getMapInfo();
    Assert.assertNotNull(mapInfo);

    // ViewBounds LimitOption
    BoundsLimitOption boundsLimitOption = mapInfo.getViewBoundsLimitOption();
    Assert.assertNotNull(boundsLimitOption);
    Assert.assertEquals(BoundsLimitOption.CENTER_WITHIN_MAX_BOUNDS, boundsLimitOption);
  }