Skip to content

Commit

Permalink
Full compile and build passing with wicket 1.5 (haven't tried interac…
Browse files Browse the repository at this point in the history
…tively)
  • Loading branch information
aaime committed Nov 1, 2013
1 parent 6e5da76 commit b3c7b46
Show file tree
Hide file tree
Showing 33 changed files with 633 additions and 611 deletions.
Expand Up @@ -137,7 +137,7 @@ public void testStartupForEdit() {
// this is a TextParamPanel instead of a RasterTableSelectionPanel when editing instead of
// adding
tester.assertComponent(base + "tableNamePanel", TextParamPanel.class);
tester.assertModelValue(base + "tableNamePanel:border:paramValue", "FAKE.TABLE");
tester.assertModelValue(base + "tableNamePanel:border:border_body:paramValue", "FAKE.TABLE");
}

/**
Expand Down Expand Up @@ -237,7 +237,7 @@ public void close() {

//print(page, true, true);

final String dropDownPath = base + "tableNamePanel:border:rasterTable";
final String dropDownPath = base + "tableNamePanel:border:border_body:rasterTable";
final DropDownChoice choice = (DropDownChoice) tester
.getComponentFromLastRenderedPage(dropDownPath);
assertTrue(choice.getChoices().isEmpty());
Expand Down
Expand Up @@ -15,7 +15,6 @@
import java.util.Arrays;
import java.util.List;

import org.apache.wicket.PageParameters;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
Expand All @@ -25,7 +24,6 @@
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.extensions.markup.html.tabs.PanelCachingTab;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;
Expand All @@ -34,6 +32,8 @@
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.string.StringValue;
import org.geoscript.geocss.CssParser;
import org.geoscript.geocss.Translator;
import org.geoserver.catalog.Catalog;
Expand Down Expand Up @@ -73,8 +73,9 @@ public CssDemoPage(PageParameters params) {
}

private static LayerInfo extractLayer(PageParameters params, Catalog catalog) {
if (params.containsKey("layer")) {
String name = params.getString("layer");
StringValue layerParam = params.get("layer");
if (layerParam != null && !layerParam.isEmpty()) {
String name = layerParam.toString();
return catalog.getLayerByName(name);
} else {
// TODO: Revisit this behavior
Expand All @@ -95,8 +96,9 @@ private static LayerInfo extractLayer(PageParameters params, Catalog catalog) {
}

private static StyleInfo extractStyle(PageParameters params, Catalog catalog, LayerInfo layer) {
if (params.containsKey("style")) {
String style = params.getString("style");
StringValue styleParam = params.get("style");
if (styleParam != null && !styleParam.isEmpty()) {
String style = styleParam.toString();
String[] parts = style.split(":", 2);
if (parts.length == 1) {
return catalog.getStyleByName(parts[0]);
Expand Down Expand Up @@ -194,7 +196,7 @@ private void doMainLayout() {
mainContent.add(new Label("layer.name", new PropertyModel(layer, "name")));
mainContent.add(new AjaxLink("change.style", new ParamResourceModel("CssDemoPage.changeStyle", this)) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
popup.setInitialHeight(400);
popup.setInitialWidth(600);
popup.setTitle(new Model("Choose style to edit"));
Expand All @@ -204,7 +206,7 @@ public void onClick(AjaxRequestTarget target) {
});
mainContent.add(new AjaxLink("change.layer", new ParamResourceModel("CssDemoPage.changeLayer", this)) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
popup.setInitialHeight(400);
popup.setInitialWidth(600);
popup.setTitle(new Model("Choose layer to edit"));
Expand All @@ -214,7 +216,7 @@ public void onClick(AjaxRequestTarget target) {
});
mainContent.add(new AjaxLink("create.style", new ParamResourceModel("CssDemoPage.createStyle", this)) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
popup.setInitialHeight(200);
popup.setInitialWidth(300);
popup.setTitle(new Model("Choose name for new style"));
Expand All @@ -224,7 +226,7 @@ public void onClick(AjaxRequestTarget target) {
});
mainContent.add(new AjaxLink("associate.styles", new ParamResourceModel("CssDemoPage.associateStyles", this)) {
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
popup.setInitialHeight(400);
popup.setInitialWidth(600);
popup.setTitle(new Model("Choose layers to associate"));
Expand Down
Expand Up @@ -43,8 +43,8 @@ public void onSubmit(AjaxRequestTarget target, Form<?> form) {
page.catalog().getResourcePool().writeStyle(
page.getStyleInfo(), new ByteArrayInputStream(sld.getBytes()));
page.catalog().save(page.getStyleInfo());
if (page.sldPreview != null) target.addComponent(page.sldPreview);
if (page.map != null) target.appendJavascript(page.map.getUpdateCommand());
if (page.sldPreview != null) target.add(page.sldPreview);
if (page.map != null) target.appendJavaScript(page.map.getUpdateCommand());
} catch (Exception e) {
throw new WicketRuntimeException(e);
}
Expand Down
Expand Up @@ -8,14 +8,14 @@
import java.util.List;

import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.geoserver.catalog.LayerInfo;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.web.wicket.GeoServerDataProvider;
Expand Down Expand Up @@ -85,12 +85,12 @@ public Component getComponentForProperty(
@Override
public void onClick(AjaxRequestTarget target) {
PageParameters params = new PageParameters();
params.put("layer", layer.prefixedName());
params.add("layer", layer.prefixedName());
WorkspaceInfo workspace= demo.getStyleInfo().getWorkspace();
if (workspace == null) {
params.put("style", demo.getStyleInfo().getName());
params.add("style", demo.getStyleInfo().getName());
} else {
params.put("style", workspace.getName() + ":" + demo.getStyleInfo().getName());
params.add("style", workspace.getName() + ":" + demo.getStyleInfo().getName());
}
setResponsePage(CssDemoPage.class, params);
}
Expand Down
Expand Up @@ -4,7 +4,9 @@
*/
package org.geoserver.community.css.web;

import org.apache.wicket.PageParameters;
import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
Expand All @@ -14,15 +16,12 @@
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.validation.IValidatable;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.ValidationError;

import org.geoserver.catalog.WorkspaceInfo;

import java.util.ArrayList;
import java.util.List;

public class LayerNameInput extends Panel {
String workspace = null;
String name = "";
Expand Down Expand Up @@ -85,11 +84,11 @@ public void onSubmit(AjaxRequestTarget target, Form f) {
demo.createCssTemplate(name);

PageParameters params = new PageParameters();
params.put("layer", demo.getLayer().prefixedName());
params.add("layer", demo.getLayer().prefixedName());
if (workspace == null) {
params.put("style", name);
params.add("style", name);
} else {
params.put("style", workspace + ":" + name);
params.add("style", workspace + ":" + name);
}
setResponsePage(CssDemoPage.class, params);
}
Expand Down
Expand Up @@ -114,8 +114,8 @@ private void renderHeaderScript(IHeaderResponse header)
Template template = templates.getTemplate("ol-load.ftl");
StringWriter script = new java.io.StringWriter();
template.process(context, script);
header.renderJavascriptReference("../openlayers/OpenLayers.js");
header.renderOnLoadJavascript(script.toString());
header.renderJavaScriptReference("../openlayers/OpenLayers.js");
header.renderOnLoadJavaScript(script.toString());
}

public String getUpdateCommand() throws IOException, TemplateException {
Expand Down
Expand Up @@ -8,14 +8,14 @@
import java.util.List;

import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.geoserver.catalog.StyleInfo;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.web.wicket.GeoServerDataProvider;
Expand Down Expand Up @@ -64,15 +64,15 @@ public Component getComponentForProperty(

public void onClick(AjaxRequestTarget target) {
PageParameters params = new PageParameters();
params.put(
params.add(
"layer",
demo.getLayer().prefixedName()
);
WorkspaceInfo workspace = style.getWorkspace();
if (workspace == null) {
params.put("style", style.getName());
params.add("style", style.getName());
} else {
params.put("style", workspace.getName() + ":" + style.getName());
params.add("style", workspace.getName() + ":" + style.getName());
}
setResponsePage(CssDemoPage.class, params);
}
Expand Down
Expand Up @@ -2,7 +2,6 @@

import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.extensions.ajax.markup.html.tabs.AjaxTabbedPanel;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.geoserver.web.GeoServerWicketTestSupport;
import org.geoserver.web.wicket.GeoServerTablePanel;
import org.junit.Test;
Expand Down
Expand Up @@ -4,9 +4,9 @@
*/
package org.geoserver.csw.web;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.geoserver.csw.CSWInfo;
import org.geoserver.web.services.BaseServiceAdminPage;

Expand Down
Expand Up @@ -44,29 +44,29 @@ public void testContents() {
// print(tester.getLastRenderedPage(), true, true);
tester.assertComponent("form", Form.class);

tester.assertModelValue("form:panel:container:identifiers:listContainer:items:1:itemProperties:0:component:border:txt", "one");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:1:itemProperties:1:component:border:txt", "http://www.geoserver.org/one");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:2:itemProperties:0:component:border:txt", "two");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:2:itemProperties:1:component:border:txt", "http://www.geoserver.org/two");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:1:itemProperties:0:component:border:border_body:txt", "one");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:1:itemProperties:1:component:border:border_body:txt", "http://www.geoserver.org/one");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:2:itemProperties:0:component:border:border_body:txt", "two");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:2:itemProperties:1:component:border:border_body:txt", "http://www.geoserver.org/two");
}

@Test
public void testRemoveLinks() {
// print(tester.getLastRenderedPage(), true, true);
tester.assertComponent("form", Form.class);

tester.assertModelValue("form:panel:container:identifiers:listContainer:items:1:itemProperties:0:component:border:txt", "one");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:2:itemProperties:0:component:border:txt", "two");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:1:itemProperties:0:component:border:border_body:txt", "one");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:2:itemProperties:0:component:border:border_body:txt", "two");

// remove the first identifier
tester.executeAjaxEvent("form:panel:container:identifiers:listContainer:items:1:itemProperties:2:component:remove", "onclick");
assertNull(tester.getLastRenderedPage().get("form:panel:container:identifiers:listContainer:items:1:itemProperties:0:component:border:txt"));
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:2:itemProperties:0:component:border:txt", "two");
assertNull(tester.getLastRenderedPage().get("form:panel:container:identifiers:listContainer:items:1:itemProperties:0:component:border:border_body:txt"));
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:2:itemProperties:0:component:border:border_body:txt", "two");

// remove the second as well
tester.executeAjaxEvent("form:panel:container:identifiers:listContainer:items:2:itemProperties:2:component:remove", "onclick");
assertNull(tester.getLastRenderedPage().get("form:panel:container:identifiers:listContainer:items:1:itemProperties:0:component:border:txt"));
assertNull(tester.getLastRenderedPage().get("form:panel:container:identifiers:listContainer:items:2:itemProperties:0:component:border:txt"));
assertNull(tester.getLastRenderedPage().get("form:panel:container:identifiers:listContainer:items:1:itemProperties:0:component:border:border_body:txt"));
assertNull(tester.getLastRenderedPage().get("form:panel:container:identifiers:listContainer:items:2:itemProperties:0:component:border:border_body:txt"));

// print(tester.getLastRenderedPage(), true, true);

Expand All @@ -82,8 +82,8 @@ public void testAddIdentifiers() {
tester.executeAjaxEvent("form:panel:addIdentifier", "onclick");

// new empty line
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:3:itemProperties:0:component:border:txt", null);
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:3:itemProperties:1:component:border:txt", null);
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:3:itemProperties:0:component:border:border_body:txt", null);
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:3:itemProperties:1:component:border:border_body:txt", null);

// try to submit, should complain about invalid code
FormTester ft = tester.newFormTester("form");
Expand All @@ -96,24 +96,24 @@ public void testAddIdentifiers() {

// submit with just code, that is fine
ft = tester.newFormTester("form");
ft.setValue("panel:container:identifiers:listContainer:items:3:itemProperties:0:component:border:txt", "code");
ft.setValue("panel:container:identifiers:listContainer:items:3:itemProperties:0:component:border:border_body:txt", "code");
ft.submit();
tester.assertNoErrorMessage();
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:3:itemProperties:0:component:border:txt", "code");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:3:itemProperties:0:component:border:border_body:txt", "code");

// now provide an invalid namespace (not a valid URI)
ft = tester.newFormTester("form");
ft.setValue("panel:container:identifiers:listContainer:items:3:itemProperties:1:component:border:txt", "invalid uri");
ft.setValue("panel:container:identifiers:listContainer:items:3:itemProperties:1:component:border:border_body:txt", "invalid uri");
ft.submit();
messages = tester.getMessages(FeedbackMessage.ERROR);
assertEquals(1, messages.size());

// finally, set a valid namespace
ft = tester.newFormTester("form");
ft.setValue("panel:container:identifiers:listContainer:items:3:itemProperties:1:component:border:txt", "http://www.geoserver.org/meta");
ft.setValue("panel:container:identifiers:listContainer:items:3:itemProperties:1:component:border:border_body:txt", "http://www.geoserver.org/meta");
ft.submit();
tester.assertNoErrorMessage();
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:3:itemProperties:1:component:border:txt", "http://www.geoserver.org/meta");
tester.assertModelValue("form:panel:container:identifiers:listContainer:items:3:itemProperties:1:component:border:border_body:txt", "http://www.geoserver.org/meta");
}


Expand Down

0 comments on commit b3c7b46

Please sign in to comment.