Пример #1
0
  @Test
  public void testReloadAndLayerRemovedExternally() throws Exception {

    final String removedLayer = tileLayer.getName();
    final String remainingLayer = tileLayerGroup.getName();

    final Set<String> layerNames = Sets.newHashSet(removedLayer, remainingLayer);

    when(tld.getLayerNames()).thenReturn(layerNames);
    doAnswer(
            new Answer<Void>() {

              @Override
              public Void answer(InvocationOnMock invocation) throws Throwable {
                layerNames.remove(removedLayer);
                return null;
              }
            })
        .when(tld)
        .reInit();

    ArgumentCaptor<String> argCaptor = ArgumentCaptor.forClass(String.class);

    mediator = spy(mediator);
    doReturn(true).when(mediator).layerRemoved(argCaptor.capture());

    mediator.reload();

    verify(tld, times(1)).reInit();
    assertEquals(1, argCaptor.getAllValues().size());
    assertEquals(removedLayer, argCaptor.getValue());
  }
Пример #2
0
  private void mockTileLayerDispatcher() throws Exception {
    when(tld.getConfiguration(same(tileLayer))).thenReturn(config);
    when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config);
    when(tld.getConfiguration(eq(tileLayer.getName()))).thenReturn(config);
    when(tld.getConfiguration(eq(tileLayerGroup.getName()))).thenReturn(config);

    when(tld.getTileLayer(eq(tileLayer.getName()))).thenReturn(tileLayer);
    when(tld.getTileLayer(eq(tileLayerGroup.getName()))).thenReturn(tileLayerGroup);

    when(tld.getLayerNames())
        .thenReturn(ImmutableSet.of(tileLayer.getName(), tileLayerGroup.getName()));
    Iterable<TileLayer> tileLayers =
        ImmutableList.of((TileLayer) tileLayer, (TileLayer) tileLayerGroup);
    when(tld.getLayerList()).thenReturn(tileLayers);

    when(tld.layerExists(eq(tileLayer.getName()))).thenReturn(true);
    when(tld.layerExists(eq(tileLayerGroup.getName()))).thenReturn(true);
  }
Пример #3
0
  private static String tableRows(
      TileLayerDispatcher tileLayerDispatcher, GridSetBroker gridSetBroker)
      throws GeoWebCacheException {
    StringBuffer buf = new StringBuffer();

    Set<String> layerList = new TreeSet<String>(tileLayerDispatcher.getLayerNames());
    for (String layerName : layerList) {
      TileLayer layer = tileLayerDispatcher.getTileLayer(layerName);
      buf.append(
          "<tr><td style=\"min-width: 100px;\"><strong>" + layer.getName() + "</strong><br />\n");
      buf.append("<a href=\"rest/seed/" + layer.getName() + "\">Seed this layer</a>\n");
      buf.append("</td><td>" + layer.isEnabled() + "</td>");
      buf.append("<td><table width=\"100%\">");

      int count = 0;
      for (String gridSetId : layer.getGridSubsets()) {
        GridSubset gridSubset = layer.getGridSubset(gridSetId);
        String gridSetName = gridSubset.getName();
        if (gridSetName.length() > 20) {
          gridSetName = gridSetName.substring(0, 20) + "...";
        }
        buf.append("<tr><td style=\"width: 170px;\">").append(gridSetName);

        buf.append("</td><td>OpenLayers: [");
        Iterator<MimeType> mimeIter = layer.getMimeTypes().iterator();
        boolean prependComma = false;
        while (mimeIter.hasNext()) {
          MimeType mime = mimeIter.next();
          if (mime instanceof ImageMime) {
            if (prependComma) {
              buf.append(", ");
            } else {
              prependComma = true;
            }
            buf.append(generateDemoUrl(layer.getName(), gridSubset.getName(), (ImageMime) mime));
          }
        }
        buf.append("]</td><td>\n");

        if (gridSubset.getName().equals(gridSetBroker.WORLD_EPSG4326.getName())) {
          buf.append(" &nbsp; KML: [");
          String prefix = "";
          prependComma = false;
          Iterator<MimeType> kmlIter = layer.getMimeTypes().iterator();
          while (kmlIter.hasNext()) {
            MimeType mime = kmlIter.next();
            if (mime instanceof ImageMime || mime == XMLMime.kml) {
              if (prependComma) {
                buf.append(", ");
              } else {
                prependComma = true;
              }
              buf.append(
                  "<a href=\""
                      + prefix
                      + "service/kml/"
                      + layer.getName()
                      + "."
                      + mime.getFileExtension()
                      + ".kml\">"
                      + mime.getFileExtension()
                      + "</a>");
            } else if (mime == XMLMime.kmz) {
              if (prependComma) {
                buf.append(", ");
              } else {
                prependComma = true;
              }
              buf.append(
                  "<a href=\"" + prefix + "service/kml/" + layer.getName() + ".kml.kmz\">kmz</a>");
            }
          }
          buf.append("]");
        } else {
          // No Google Earth support
        }
        buf.append("</td></tr>");
        count++;
      }

      // if(count == 0) {
      // buf.append("<tr><td colspan=\"2\"><i>None</i></td></tr>\n");
      // }

      buf.append("</table></td>\n");
      buf.append("</tr>\n");
    }

    return buf.toString();
  }