예제 #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());
  }
예제 #2
0
  @Test
  public void testRemoveGridsets() throws Exception {
    try {
      mediator.removeGridSets(null);
      fail();
    } catch (NullPointerException e) {
      assertTrue(true);
    }

    {
      final GridSet oldGridset = gridSetBroker.get("EPSG:4326");
      final GridSet newGridset;
      XMLGridSet xmlGridSet = new XMLGridSet(oldGridset);
      xmlGridSet.setName("My4326");
      // make it a bit different
      xmlGridSet.setAlignTopLeft(!xmlGridSet.getAlignTopLeft());
      newGridset = xmlGridSet.makeGridSet();
      gridSetBroker.put(newGridset);
    }

    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("My4326"))).thenReturn(config);

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

    assertEquals(ImmutableSet.of("EPSG:900913"), tileLayer.getGridSubsets());
    assertEquals(ImmutableSet.of("EPSG:900913"), tileLayerGroup.getGridSubsets());

    verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:4326"));
    verify(storageBroker, times(1))
        .deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:4326"));

    verify(storageBroker, never()).deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:900913"));
    verify(storageBroker, never()).deleteByGridSetId(eq(tileLayer.getName()), eq("My4326"));
    verify(storageBroker, never())
        .deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:900913"));
    verify(storageBroker, never()).deleteByGridSetId(eq(tileLayerGroup.getName()), eq("My4326"));

    verify(tld, times(1)).modify(same(tileLayer));
    verify(tld, times(1)).modify(same(tileLayerGroup));
    verify(tld, times(1)).removeGridset(eq("EPSG:4326"));
    verify(tld, times(1)).removeGridset(eq("My4326"));
    // all these modifications, and a single save()
    verify(config, times(1)).save();
  }