Skip to content

Commit

Permalink
Merge pull request #78 from groldan/dependency/upgrade_plugin_support…
Browse files Browse the repository at this point in the history
…ed_geoserver_versions

Upgrade plugin test versions: 2.27-SNAPSHOT, 2.26.2, 2.25.5
  • Loading branch information
groldan authored Feb 4, 2025
2 parents ad73b45 + 622c98c commit 185a17a
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 93 deletions.
4 changes: 2 additions & 2 deletions examples/java-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
<version>2.7.11</version>
<version>2.7.18</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -55,7 +55,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.7.11</version>
<version>2.7.18</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
9 changes: 5 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@
<revision>2.4-SNAPSHOT</revision>
<java.version>17</java.version>
<!-- Default GeoServer version to build and test the plugin against-->
<gs.version>2.26-SNAPSHOT</gs.version>
<gs.version>2.27-SNAPSHOT</gs.version>
<!-- GeoTools version used by gs-acl-authorization, doesn't need to match any version used by GeoServer -->
<gt.version>32-SNAPSHOT</gt.version>
<jts.version>1.19.0</jts.version>
<gt.version>33-SNAPSHOT</gt.version>
<wicket.version>9.19.0</wicket.version>
<jts.version>1.20.0</jts.version>
<fmt.action>format</fmt.action>
<fmt.skip>false</fmt.skip>
<openapi-generator-maven-plugin.version>7.0.1</openapi-generator-maven-plugin.version>
Expand Down Expand Up @@ -579,7 +580,7 @@
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>7.18.0</version>
<version>${wicket.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
24 changes: 8 additions & 16 deletions src/plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<gs.version>2.26-SNAPSHOT</gs.version>
<gt.version>32-SNAPSHOT</gt.version>
<gs.version>2.27-SNAPSHOT</gs.version>
<gt.version>33-SNAPSHOT</gt.version>
</properties>
</profile>
<profile>
Expand All @@ -176,28 +176,20 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<gs.version>2.25.3</gs.version>
<gt.version>31.3</gt.version>
<gs.version>2.26.2</gs.version>
<gt.version>32.2</gt.version>
<wicket.version>7.18.0</wicket.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<!-- downgrade the root dependencyConvergence maven profile settled versions where appropriate -->
<groupId>javax.measure</groupId>
<artifactId>unit-api</artifactId>
<version>2.1.2</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
<profile>
<id>gs_maintenance</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<gs.version>2.24.4</gs.version>
<gt.version>30.4</gt.version>
<gs.version>2.25.5</gs.version>
<gt.version>31.5</gt.version>
<wicket.version>7.18.0</wicket.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down
38 changes: 38 additions & 0 deletions src/plugin/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@
<scope>provided</scope>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- Junit4 dependency required by WicketTester -->
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geoserver.acl.plugin</groupId>
<artifactId>gs-acl-plugin-accessmanager</artifactId>
Expand Down Expand Up @@ -128,5 +149,22 @@
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Disable JUnit 5 -->
<excludeGroups>org.junit.jupiter.api.*</excludeGroups>
<!-- Ensure JUnit 4 is detected -->
<properties>
<property>
<name>junit4</name>
<value>true</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.markup.html.form.AbstractSubmitLink;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.TextField;
Expand Down Expand Up @@ -41,42 +39,16 @@ public ACLServiceConfigPage() {
form.setOutputMarkupId(true);
super.add(form);

// TODO: allow to configure the url, user, and pwd
// TODO: allow to configure the url, user, and pwd?
form.add(serviceURLField());
form.add(testConnectionLink());

// form.add(allowRemoteAndInlineLayers());
// form.add(grantWriteToWorkspacesToAuthenticatedUsers());
// form.add(useRolesToFilter());

// form.add(new TextField<>("acceptedRoles", new PropertyModel<>(configModel,
// "acceptedRoles")));

// form.add(submitButton());
// form.add(cancelButton());
}

private CheckBox useRolesToFilter() {
return new CheckBox("useRolesToFilter", pageModel.getUseRolesToFilter());
}

private CheckBox grantWriteToWorkspacesToAuthenticatedUsers() {
return new CheckBox(
"grantWriteToWorkspacesToAuthenticatedUsers",
pageModel.getGrantWriteToWorkspacesToAuthenticatedUsers());
}

private CheckBox allowRemoteAndInlineLayers() {
return new CheckBox(
"allowRemoteAndInlineLayers", pageModel.getAllowRemoteAndInlineLayers());
}

private TextField<String> serviceURLField() {
final boolean isInternal = pageModel.isInternal();
ExtPropertyModel<String> serviceUrl = pageModel.getServiceUrl().setReadOnly(isInternal);
TextField<String> serviceURLField = new TextField<>("servicesUrl", serviceUrl);
serviceURLField.setRequired(true);
// serviceURLField.setEnabled(!isInternal);
serviceURLField.setEnabled(false);
return serviceURLField;
}
Expand All @@ -85,12 +57,19 @@ private AbstractSubmitLink testConnectionLink() {
return new AjaxSubmitLink("test") {
private static final long serialVersionUID = 1L;

@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
// signature of wicket 7.x, remove when the minimum version is 2.27.x
@SuppressWarnings("unused")
protected void onSubmit(AjaxRequestTarget target, Form form) {
onSubmit(target);
}

// signature for wicket 9.x+, uncomment the Override annotation when the minimum version
// is 2.27.x
// @Override
protected void onSubmit(AjaxRequestTarget target) {
try {
((FormComponent<?>) form.get("servicesUrl")).processInput();
// String servicesUrl = (String) ((FormComponent<?>)
// form.get("servicesUrl")).getConvertedInput();
FormComponent<?> url = (FormComponent<?>) super.getForm().get("servicesUrl");
url.processInput();
pageModel.testConnection();
info(
new StringResourceModel(
Expand All @@ -108,32 +87,4 @@ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
}
}.setDefaultFormProcessing(false);
}

private Button submitButton() {
return new Button("submit") {
private static final long serialVersionUID = 1L;

@Override
public void onSubmit() {
try {
pageModel.applyAndSaveConfiguration();
doReturn();
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Save error", e);
error(e);
}
}
};
}

private Button cancelButton() {
return new Button("cancel") {
private static final long serialVersionUID = 1L;

@Override
public void onSubmit() {
doReturn();
}
}.setDefaultFormProcessing(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.junit.Ignore;
import org.junit.Test;

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

Expand All @@ -42,7 +43,8 @@ public class LayerDetailsEditPanelTest extends AclWicketTestSupport {
private AjaxRequestTarget mockTarget;

@Before
public void beforeEach() throws Exception {
@Override
public void beforeEach() throws IOException {
super.beforeEach();
mockTarget = mock(AjaxRequestTarget.class);
setUpTester(new MutableRule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.convert.ConversionException;
import org.apache.wicket.util.tester.FormTester;
import org.apache.wicket.util.tester.WicketTester;
import org.geolatte.geom.Geometry;
Expand Down Expand Up @@ -63,9 +65,9 @@ public void testMultiPolygon() {

form = tester.newFormTester("panel:form");
form.setValue("wkt", "SRID=4326;POLYGON ((-180 -90,-180 90,180 90,180 -90,-180 -90))");
// String message = assertThrows(ConversionException.class, form::submit).getMessage();
// assertThat(message, containsString("Expected MultiPolygon, got Polygon"));
assertThrows(WicketRuntimeException.class, form::submit);
// WicketRuntimException for GeoServer 2.26.x or lower, ConversionException since 2.27.x
RuntimeException error = assertThrows(RuntimeException.class, form::submit);
assertTrue(error instanceof ConversionException || error instanceof WicketRuntimeException);
}

@Test
Expand Down Expand Up @@ -97,7 +99,9 @@ public void testInvalidWKT() {
FormTester form = tester.newFormTester("panel:form");

form.setValue("wkt", "MULTIPOLYGON(( NAH ))");
assertThrows(WicketRuntimeException.class, form::submit);
RuntimeException error = assertThrows(RuntimeException.class, form::submit);
// WicketRuntimException for GeoServer 2.26.x or lower, ConversionException since 2.27.x
assertTrue(error instanceof ConversionException || error instanceof WicketRuntimeException);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
*/
package org.geoserver.acl.plugin.web.components;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.repeater.OddEvenItem;
import org.geoserver.acl.domain.adminrules.AdminRule;
import org.geoserver.acl.domain.adminrules.AdminRuleAdminService;
Expand Down Expand Up @@ -73,7 +75,13 @@ public void testRows() {
for (int i = 1; i <= 10; i++) {
String itemPath = "rulesPanel:listContainer:items:" + i;
tester.assertComponent(itemPath, OddEvenItem.class);
tester.assertListView(itemPath + ":itemProperties", expectedProperties);

@SuppressWarnings("unchecked")
ListView<MutableAdminRule> listView =
(ListView<MutableAdminRule>)
tester.getComponentFromLastRenderedPage(itemPath + ":itemProperties");
assertNotNull(listView);

tester.assertComponent(
itemPath + ":itemProperties:5:component:up", ImageAjaxLink.class);
tester.assertComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.rules.TemporaryFolder;

import java.io.File;
import java.io.IOException;
import java.util.List;

public class ACLServiceConfigPageTest extends AclWicketTestSupport {
Expand All @@ -29,7 +30,7 @@ public class ACLServiceConfigPageTest extends AclWicketTestSupport {

@Before
@Override
public void beforeEach() throws Exception {
public void beforeEach() throws IOException {
super.beforeEach();
configManager = GeoServerExtensions.bean(AclConfigurationManager.class);
assertNotNull(configManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.junit.After;
import org.junit.Before;

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

public abstract class AclWicketTestSupport extends GeoServerWicketTestSupport {
Expand All @@ -31,7 +32,7 @@ protected void setUpSpring(List<String> springContextLocations) {
}

@Before
public void beforeEach() throws Exception {
public void beforeEach() throws IOException {
login();
}

Expand Down

0 comments on commit 185a17a

Please sign in to comment.