-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEOS-8494] Allow TextDecoration template to pick from request parame…
…ters too
- Loading branch information
Showing
4 changed files
with
138 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/wms/src/test/java/org/geoserver/wms/decoration/TextDecorationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* (c) 2017 Open Source Geospatial Foundation - all rights reserved | ||
* This code is licensed under the GPL 2.0 license, available at the root | ||
* application directory. | ||
*/ | ||
package org.geoserver.wms.decoration; | ||
|
||
import org.geoserver.ows.Dispatcher; | ||
import org.geoserver.ows.Request; | ||
import org.geoserver.ows.util.CaseInsensitiveMap; | ||
import org.geoserver.wms.GetMapRequest; | ||
import org.geoserver.wms.WMSMapContent; | ||
import org.junit.After; | ||
import org.junit.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TextDecorationTest { | ||
|
||
@After | ||
public void clearRequest() { | ||
Dispatcher.REQUEST.remove(); | ||
} | ||
|
||
@Test | ||
public void testExpandRequestVariable() throws Exception { | ||
// setup environment | ||
Request request = new Request(); | ||
Map kvp = new CaseInsensitiveMap(new HashMap()); | ||
kvp.put("time", "2008-10-31T00:00:00.000Z"); | ||
request.setRawKvp(kvp); | ||
Dispatcher.REQUEST.set(request); | ||
|
||
TextDecoration decoration = new TextDecoration(); | ||
Map<String, String> options = new HashMap<>(); | ||
options.put("message", "<#setting datetime_format=\"yyyy-MM-dd'T'HH:mm:ss.SSSX\">\n" + | ||
"<#setting locale=\"en_US\">\n" + | ||
"<#if time??>\n" + | ||
"${time?datetime?string[\"dd.MM.yyyy\"]}" + | ||
"</#if>"); | ||
decoration.loadOptions(options); | ||
|
||
GetMapRequest getMap = new GetMapRequest(); | ||
WMSMapContent wmsMapContent = new WMSMapContent(getMap); | ||
String message = decoration.evaluateMessage(wmsMapContent); | ||
assertEquals("31.10.2008", message); | ||
} | ||
} |