Skip to content

Commit

Permalink
Support new GWCConferter constructor, fix test failures
Browse files Browse the repository at this point in the history
 - PUT is now supported for existing layers
 - Layers list URL fixed
  • Loading branch information
tbarsballe committed Feb 16, 2018
1 parent d3c4ef7 commit 180721f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/gwc/src/main/resources/geowebcache-rest-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<!-- Used by org.geoserver.rest.RestConfiguration when setting up converters -->
<bean id="gwcConverter" class="org.geowebcache.rest.converter.GWCConverter">
<constructor-arg ref="gwcXmlConfig" />
<constructor-arg ref="gwcAppCtx" />
</bean>

<context:component-scan base-package="org.geowebcache.rest, org.geowebcache.diskquota.rest.controller, org.geowebcache.service.wmts" />
Expand Down
15 changes: 5 additions & 10 deletions src/gwc/src/test/java/org/geoserver/gwc/RESTIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testGetLayersList() throws Exception {
assertTrue(sr.getContentType(), sr.getContentType().startsWith("application/xml"));

Document dom = getAsDOM(url);
// print(dom);
print(dom);

ArrayList<String> tileLayerNames = Lists.newArrayList(GWC.get().getTileLayerNames());
Collections.sort(tileLayerNames);
Expand All @@ -83,8 +83,8 @@ public void testGetLayersList() throws Exception {
String xpath = "//layers/layer/name[text() = '" + name + "']";
assertXpathExists(xpath, dom);

xpath = "//layers/layer/atom:link[@href = 'http://localhost:8080/geoserver/gwc/layers/"
+ ServletUtils.URLEncode(name) + ".xml']";
xpath = "//layers/layer/atom:link[@href = 'http://localhost:8080/geoserver/gwc/rest/layers/"
+ name + ".xml']";
assertXpathExists(xpath, dom);
}
}
Expand Down Expand Up @@ -203,7 +203,7 @@ public void testPutGoodIdNoLayerName() throws Exception {
}

@Test
public void testPutOverExistingTileLayerFails() throws Exception {
public void testPutOverExistingTileLayerSucceeds() throws Exception {

final String layerName = getLayerId(MockData.BASIC_POLYGONS);
final String id = getCatalog().getLayerByName(layerName).getId();
Expand All @@ -212,12 +212,7 @@ public void testPutOverExistingTileLayerFails() throws Exception {

MockHttpServletResponse response = putLayer(url, id, layerName);

assertEquals(HttpServletResponse.SC_BAD_REQUEST, response.getStatus());
// See GWC's TileLayerRestlet
String expected = "Layer with name " + layerName
+ " already exists, use POST if you want to replace it.";
assertEquals(expected, response.getContentAsString().substring(response.getContentAsString().indexOf(":") + 2));

assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,18 @@ protected void configureMessageConverters(List<HttpMessageConverter<?>> converte
gsConverters.add(new StyleWriterConverter(sh.mimeType(ver), ver, sh));
}
}
//Add GWC REST converter (add it first, since it has stricter constraints than the defalt GS XML converters)
if (applicationContext.containsBean("gwcConverter")) {
converters.add((HttpMessageConverter<?>) applicationContext.getBean("gwcConverter"));
}

//Sort the converters based on ExtensionPriority
gsConverters.sort(Comparator.comparingInt(BaseMessageConverter::getPriority));
for (BaseMessageConverter converter : gsConverters) {
converters.add(converter);
}

//Add GWC REST converter
if (applicationContext.containsBean("gwcConverter")) {
converters.add((HttpMessageConverter<?>) applicationContext.getBean("gwcConverter"));
}


//use the default ones as lowest priority
super.addDefaultHttpMessageConverters(converters);
Expand Down

0 comments on commit 180721f

Please sign in to comment.