Skip to content

Commit

Permalink
Show pluggable GWC advertised formats also in the Caching Defaults page.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Roldan committed Jul 1, 2015
1 parent 17dcb33 commit 00617ef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Expand Up @@ -29,7 +29,8 @@
import org.apache.wicket.validation.IValidatable;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.ValidationError;
import org.geoserver.gwc.ConfigurableBlobStore;
import org.geoserver.catalog.PublishedType;
import org.geoserver.gwc.GWC;
import org.geoserver.gwc.config.GWCConfig;
import org.geoserver.web.GeoServerApplication;
import org.geoserver.web.wicket.LocalizedChoiceRenderer;
Expand Down Expand Up @@ -111,10 +112,9 @@ protected void onUpdate(AjaxRequestTarget target) {
gutterChoices);
configs.add(gutterChoice);

final List<String> formats = Arrays.asList("image/png", "image/png8", "image/jpeg",
"image/gif");

{
List<String> formats;
formats = new ArrayList<>(GWC.getAdvertisedCachedFormats(PublishedType.VECTOR));
IModel<List<String>> vectorFormatsModel = new PropertyModel<List<String>>(
gwcConfigModel, "defaultVectorCacheFormats");
vectorFormatsGroup = new CheckGroup<String>("vectorFormatsGroup", vectorFormatsModel);
Expand All @@ -133,6 +133,8 @@ protected void populateItem(ListItem<String> item) {
}

{
List<String> formats;
formats = new ArrayList<>(GWC.getAdvertisedCachedFormats(PublishedType.RASTER));
IModel<List<String>> rasterFormatsModel = new PropertyModel<List<String>>(
gwcConfigModel, "defaultCoverageCacheFormats");
rasterFormatsGroup = new CheckGroup<String>("rasterFormatsGroup", rasterFormatsModel);
Expand All @@ -150,6 +152,8 @@ protected void populateItem(ListItem<String> item) {
rasterFormatsGroup.add(formatsList);
}
{
List<String> formats;
formats = new ArrayList<>(GWC.getAdvertisedCachedFormats(PublishedType.GROUP));
IModel<List<String>> otherFormatsModel = new PropertyModel<List<String>>(
gwcConfigModel, "defaultOtherCacheFormats");
otherFormatsGroup = new CheckGroup<String>("otherFormatsGroup", otherFormatsModel);
Expand Down
Expand Up @@ -5,21 +5,22 @@
*/
package org.geoserver.gwc.web;

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.util.tester.FormTester;
import org.apache.wicket.util.tester.Result;
import org.geoserver.catalog.PublishedType;
import org.geoserver.gwc.ConfigurableLockProvider;
import org.geoserver.gwc.GWC;
import org.geoserver.gwc.config.GWCConfig;
Expand Down Expand Up @@ -157,18 +158,19 @@ public void testSetDefaultCacheFormats() throws Exception {
// print(page, true, true);
tester.assertRenderedPage(GWCSettingsPage.class);

final List<String> formats = newArrayList("image/png", "image/png8", "image/jpeg",
"image/gif");
final List<String> vectorFormats = new ArrayList<>(GWC.getAdvertisedCachedFormats(PublishedType.VECTOR));
final List<String> rasterFormats = new ArrayList<>(GWC.getAdvertisedCachedFormats(PublishedType.RASTER));
final List<String> groupFormats = new ArrayList<>(GWC.getAdvertisedCachedFormats(PublishedType.GROUP));

tester.assertListView(
"form:cachingOptionsPanel:container:configs:vectorFormatsGroup:vectorFromats",
formats);
vectorFormats);
tester.assertListView(
"form:cachingOptionsPanel:container:configs:rasterFormatsGroup:rasterFromats",
formats);
rasterFormats);
tester.assertListView(
"form:cachingOptionsPanel:container:configs:otherFormatsGroup:otherFromats",
formats);
groupFormats);

FormTester form = tester.newFormTester("form");
final boolean replace = true;// tell selectMultiple to first set all options to false
Expand All @@ -183,10 +185,12 @@ public void testSetDefaultCacheFormats() throws Exception {

tester.assertRenderedPage(GeoServerHomePage.class);

Set<String> expected = newHashSet(formats.get(1), formats.get(3));
assertEquals(expected, gwc.getConfig().getDefaultVectorCacheFormats());
assertEquals(expected, gwc.getConfig().getDefaultCoverageCacheFormats());
assertEquals(expected, gwc.getConfig().getDefaultOtherCacheFormats());
assertEquals(newHashSet(vectorFormats.get(1), vectorFormats.get(3)), gwc.getConfig()
.getDefaultVectorCacheFormats());
assertEquals(newHashSet(rasterFormats.get(1), rasterFormats.get(3)), gwc.getConfig()
.getDefaultCoverageCacheFormats());
assertEquals(newHashSet(groupFormats.get(1), groupFormats.get(3)), gwc.getConfig()
.getDefaultOtherCacheFormats());
}

private void testEditCheckboxOption(final String pagePath, final String formPath,
Expand Down

0 comments on commit 00617ef

Please sign in to comment.