Ejemplo n.º 1
0
  @Test
  public void testRemoveAllLayerGridsetsDisablesLayer() throws Exception {

    when(tld.getConfiguration(same(tileLayer))).thenReturn(config);
    when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config);
    when(tld.modify(same(tileLayer))).thenReturn(config);
    when(tld.modify(same(tileLayerGroup))).thenReturn(config);
    when(tld.removeGridset(eq("EPSG:4326"))).thenReturn(config);
    when(tld.removeGridset(eq("EPSG:900913"))).thenReturn(config);

    // sanity check before modification
    assertTrue(tileLayer.getInfo().isEnabled());
    assertTrue(tileLayer.getInfo().isEnabled());

    mediator.removeGridSets(ImmutableSet.of("EPSG:900913", "EPSG:4326"));

    verify(config, times(1)).save(); // all other checks are in testRemoveGridsets
    verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:4326"));
    verify(storageBroker, times(1))
        .deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:900913"));
    verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:4326"));
    verify(storageBroker, times(1))
        .deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:900913"));

    assertTrue(tileLayer.getGridSubsets().isEmpty());
    assertTrue(tileLayerGroup.getGridSubsets().isEmpty());

    // layers ended up with no gridsubsets, shall have been disabled
    assertFalse(tileLayer.getInfo().isEnabled());
    assertFalse(tileLayerGroup.getInfo().isEnabled());
  }
Ejemplo n.º 2
0
  @Test
  public void testDispatchGetMapWithMatchingParameterFilters() throws Exception {
    GetMapRequest request = new GetMapRequest();

    @SuppressWarnings("unchecked")
    Map<String, String> rawKvp = new CaseInsensitiveMap(new HashMap<String, String>());
    request.setRawKvp(rawKvp);
    request.setFormat("image/png");
    request.setSRS("EPSG:900913");
    request.setWidth(256);
    request.setHeight(256);
    rawKvp.put("layers", tileLayer.getName());

    // tileLayer = mockTileLayer("mockLayer", ImmutableList.of("EPSG:900913", "EPSG:4326"));

    // make the request match a tile in the expected gridset
    BoundingBox bounds;
    bounds = tileLayer.getGridSubset("EPSG:900913").boundsFromIndex(new long[] {0, 0, 1});

    Envelope reqBbox =
        new Envelope(bounds.getMinX(), bounds.getMaxX(), bounds.getMinY(), bounds.getMaxY());
    request.setBbox(reqBbox);

    assertTrue(tileLayer.getInfo().cachedStyles().size() > 0);

    for (String style : tileLayer.getInfo().cachedStyles()) {

      String rawKvpParamName = "styles";
      String rawKvpParamValue = style;

      testParameterFilter(request, rawKvp, rawKvpParamName, rawKvpParamValue);
    }

    request.setEnv(ImmutableMap.of("envKey", "envValue"));
    updateStringParameterFilter(
        tileLayerInfo, "ENV", true, "def:devVal", "envKey:envValue", "envKey2:envValue2");
    testParameterFilter(request, rawKvp, "env", "envKey:envValue");

    updateAcceptAllFloatParameterFilter(tileLayerInfo, "ANGLE", true);
    request.setAngle(60);
    testParameterFilter(request, rawKvp, "angle", "60.0");

    request.setAngle(61.1);
    testParameterFilter(request, rawKvp, "angle", "61.1");
  }
Ejemplo n.º 3
0
  @Test
  public void testTruncateByBounds() throws Exception {

    String layerName = tileLayer.getName();
    ReferencedEnvelope bounds;
    // bounds outside layer bounds (which are -180,0,0,90)
    bounds = new ReferencedEnvelope(10, 20, 10, 20, DefaultGeographicCRS.WGS84);
    BoundingBox layerBounds = tileLayer.getGridSubset("EPSG:4326").getGridSet().getOriginalExtent();

    assertFalse(bounds.intersects(layerBounds.getMinX(), layerBounds.getMinY()));
    assertFalse(bounds.intersects(layerBounds.getMaxX(), layerBounds.getMaxY()));

    mediator.truncate(layerName, bounds);

    verify(tileBreeder, never()).dispatchTasks(any(GWCTask[].class));

    // bounds intersecting layer bounds
    bounds = new ReferencedEnvelope(-10, -10, 10, 10, DefaultGeographicCRS.WGS84);

    mediator.truncate(layerName, bounds);

    int numGridsets = tileLayer.getGridSubsets().size();
    int numFormats = tileLayer.getMimeTypes().size();
    int numStyles = 1 /* default */ + tileLayer.getInfo().cachedStyles().size();
    final int expected = numGridsets * numFormats * numStyles;
    verify(tileBreeder, times(expected)).dispatchTasks(any(GWCTask[].class));

    reset(tileBreeder);
    bounds = bounds.transform(CRS.decode("EPSG:900913"), true);
    mediator.truncate(layerName, bounds);
    verify(tileBreeder, times(expected)).dispatchTasks(any(GWCTask[].class));

    reset(tileBreeder);
    bounds = mediator.getAreaOfValidity(CRS.decode("EPSG:2083")); // Terra del Fuego
    mediator.truncate(layerName, bounds);
    verify(tileBreeder, never()).dispatchTasks(any(GWCTask[].class));

    reset(tileBreeder);
    bounds = mediator.getAreaOfValidity(CRS.decode("EPSG:26986")); // Massachussets
    mediator.truncate(layerName, bounds);
    verify(tileBreeder, times(expected)).dispatchTasks(any(GWCTask[].class));
  }