-
Notifications
You must be signed in to change notification settings - Fork 291
fix(gwc-core): srs equals(..) should allow one-directional aliases #1450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aaime
merged 1 commit into
GeoWebCache:main
from
dirk-jamieson-aem:fix-srs-equals-when-decoding-xml
Nov 24, 2025
+75
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
69 changes: 69 additions & 0 deletions
69
geowebcache/core/src/test/java/org/geowebcache/grid/SRSTest.java
This file contains hidden or 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,69 @@ | ||
| package org.geowebcache.grid; | ||
|
|
||
| import java.lang.reflect.Constructor; | ||
| import java.lang.reflect.InvocationTargetException; | ||
| import java.util.List; | ||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| /** Simple Test class for testing the behavior of a {@link GridSubset} with a non-zero zoomStart parameter. */ | ||
| public class SRSTest { | ||
| private SRS createSRSWithReflection(int epsgCode) { | ||
| return createSRSWithReflection(epsgCode, null); | ||
| } | ||
|
|
||
| private SRS createSRSWithReflection(int epsgCode, List<Integer> aliases) { | ||
| try { | ||
| Constructor<SRS> constructor = SRS.class.getDeclaredConstructor(int.class, List.class); | ||
| constructor.setAccessible(true); | ||
|
|
||
| return constructor.newInstance(epsgCode, aliases); | ||
| } catch (NoSuchMethodException | ||
| | InstantiationException | ||
| | IllegalAccessException | ||
| | InvocationTargetException e) { | ||
| Assert.fail("Failed to invoke SRS constructor via reflection: " + e.getMessage()); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| /** Two SRS objects created with the same EPSG code should be equal */ | ||
| @Test | ||
| public void testCompareSameSRS() { | ||
| SRS srs1 = createSRSWithReflection(3308); | ||
| SRS srs2 = createSRSWithReflection(3308); | ||
|
|
||
| Assert.assertEquals("Expect two identical SRS", srs1, srs2); | ||
| Assert.assertEquals("Expect two identical SRS", srs2, srs1); | ||
| } | ||
|
|
||
| /** Two SRS objects created with different EPSG codes should not be equal */ | ||
| @Test | ||
| public void testCompareDifferentSRS() { | ||
| SRS srs1 = createSRSWithReflection(3308); | ||
| SRS srs2 = createSRSWithReflection(3857); | ||
|
|
||
| Assert.assertNotEquals("Expect two different SRS", srs1, srs2); | ||
| Assert.assertNotEquals("Expect two different SRS", srs2, srs1); | ||
| } | ||
|
|
||
| /** But two different SRS objects created with alias EPSG codes should be equal */ | ||
| @Test | ||
| public void testCompareAliasSRS() { | ||
| SRS srs1 = createSRSWithReflection(3857, List.of(900913)); | ||
| SRS srs2 = createSRSWithReflection(900913, List.of(3857)); | ||
|
|
||
| Assert.assertEquals("Expect two alias SRS to be equal", srs1, srs2); | ||
| Assert.assertEquals("Expect two alias SRS to be equal", srs2, srs1); | ||
| } | ||
|
|
||
| /** Two different SRS objects. One has an alias of the other, but not vice versa. They should still be equal. */ | ||
| @Test | ||
| public void testCompareOneDirectionalAliasSRS() { | ||
| SRS srs1 = createSRSWithReflection(900913, List.of(3857)); | ||
| SRS srs2 = createSRSWithReflection(3857); | ||
|
|
||
| Assert.assertEquals("Expect two alias SRS to be equal", srs1, srs2); | ||
| Assert.assertEquals("Expect two alias SRS to be equal", srs2, srs1); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the case that is failing in the current release |
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using reflection here, because it simulates what the XML deserialization process is doing - invoking the private constructor without initializing the aliases list.