Skip to content

Commit

Permalink
[GEOS-10013] Mark invalid error while validating or saving a Style
Browse files Browse the repository at this point in the history
  • Loading branch information
taba90 authored and aaime committed Apr 16, 2021
1 parent 3f9a2a3 commit bf182f1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class SLDHandler extends StyleHandler {
* number of bytes to "look ahead" when pre parsing xml document. TODO: make this configurable,
* and possibley link it to the same value used by the ows dispatcher.
*/
static int XML_LOOKAHEAD = 8192;
static int XML_LOOKAHEAD = 8500;

public static final String FORMAT = "sld";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -68,7 +69,12 @@
import org.geoserver.wms.web.data.publish.WMSLayerConfigTest;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.CRS;
import org.geotools.styling.FeatureTypeStyle;
import org.geotools.styling.Style;
import org.geotools.styling.StyleBuilder;
import org.geotools.styling.visitor.DuplicatingStyleVisitor;
import org.geotools.util.URLs;
import org.geotools.xml.styling.SLDTransformer;
import org.junit.Before;
import org.junit.Test;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
Expand Down Expand Up @@ -984,6 +990,37 @@ public void testStyleComponents() {
"styleForm:style-component-mock", StyleEditPageTest.MockStyleComponent.class);
}

@Test
public void testInvalidMark() throws Exception {
// GEOS-10013 tests that with a big style there is no error message MarkInvalid throw by the
// SLDHandler
// method getVersionAndReader

// generate a long style
StyleBuilder styleBuilder = new StyleBuilder();
DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
buildingsStyle.getStyle().accept(duplicatingStyleVisitor);
Style style = (Style) duplicatingStyleVisitor.getCopy();
FeatureTypeStyle typeStyle = style.featureTypeStyles().get(0);
for (int i = 0; i < 30; i++) {
FeatureTypeStyle fts =
styleBuilder.createFeatureTypeStyle(
typeStyle.getName() + i, typeStyle.rules().get(0));
style.featureTypeStyles().add(fts);
}
SLDTransformer transformer = new SLDTransformer();
StringWriter writer = new StringWriter();
transformer.transform(style, writer);
String sld = writer.toString();

// test that the Mark invalid error message not appears doesn't occur
tester.newFormTester("styleForm")
.setValue("styleEditor:editorContainer:editorParent:editor", sld);

tester.executeAjaxEvent("validate", "click");
tester.assertNoErrorMessage();
}

public static class MockStyleComponentInfo extends StyleComponentInfo {
public MockStyleComponentInfo(String id, AbstractStylePage clazz) {
super("test", clazz);
Expand Down

0 comments on commit bf182f1

Please sign in to comment.