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
WICKET-7072 wicket tester and core tests without test jar #666
WICKET-7072 wicket tester and core tests without test jar #666
Conversation
Wicket does not use maven-site-plugin since a long time Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
…dule Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
…tests-without-test-jar
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 generally happy with this PR, it's a good improvement for the JPMS support of Wicket. I think I've found some other JPMS related problems working on this PR but they probably deserve a separate issue. For example, resources from package org.apache.wicket from wicket-core are not visible from external modules, so in a fully JPMS compliant project we might have problems with simply using core components (like Form). I think we should add 'opens' clause to info-module.java, but as I said this should a work for a separate issue.
Forgot to mention WICKET-7072 for Jira
@@ -24,6 +24,7 @@ | |||
requires org.apache.wicket.request; | |||
requires org.apache.wicket.core; | |||
requires org.slf4j; | |||
requires static jakarta.servlet; |
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.
This change is not related to this commit.
I reverted it once and everything was working.
Now it is re-introduced silently again.
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.
Please see my latest comment in WICKET-7072 for leaving this change.
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.
Maven Surefire plugin is only for executing the tests via Maven. It does not affect the compilation phase!
I agree, sorry for mixing up compile and surefire plugins.
In addition: the src/test/java don't have module-info.java, i.e. they are not Java modules!
IMO (esp. after reading https://stackoverflow.com/questions/46613214/java-9-maven-junit-does-test-code-need-module-info-java-of-its-own-and-wher), /src/main/java/module-info.java is used for compiling both /src/main/java and /src/test/java, but compilation of test code seems to be different in Eclipse and Maven, leading to different results (Maven compiles test sources, but Eclipse doesn't do in this case). I think more research is needed here. It would be great if Eclipse would follow Maven in this use case. Meanwhile we could keep requires static jakarta.servlet which would prevent Eclipse developers from manually fixing the build path (via exclude module-info.java, see also my comment in WICKET-7072).
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.
Meanwhile we could keep requires static jakarta.servlet which would prevent Eclipse developers from manually fixing the build path
Fully agree on this!
I just want to propose an improvement:
- either mention the reason for the change in the commit message
- or even better - use a separate commit for it. Mixing it in the same commit with the wicket-util:test-jar one is not good
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.
Fully agree on this!
Ok, great!
I just want to propose an improvement:
Thank you for this proposal. I'm unsure how to do this practically:
- revert the change, commit, redo the change with appropriate comment and commit
or
- revert the change, commit, wait until PR is merged into master (with commits squashed), open another PR for WICKET-7072, redo the change with appropriate comment and commit?
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.
@martin-g: Looking at some commits in wicket master it looks like that commits of a PR are squashed, and the comments of these commits are merged and used as comment of the squashed commit. Because of this I decided for the first option (reverted the change, commit, redo, added again and commit) and applied it.
Just have tested this branch in VSCode there no errors :)) Hooray! :) |
Great, thanks for testing! |
@@ -146,7 +145,8 @@ public ServletContext getServletContext() | |||
@Override | |||
public void invalidate() | |||
{ | |||
Session session = (Session) attributes.get("wicket:" + BaseWicketTester.TestFilterConfig.class.getName() + ":session"); | |||
Session session = (Session) attributes.get("wicket:" + "BaseWicketTester.TestFilterConfig" + ":session"); // TODO |
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.
Copied from previous PR #659:
wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpSession.java
I think this class should be moved to wicket-tester
Ok, we could do that (I also thought about moving the whole _package org/apache/wicket/protocol/http/mock to wicket-tester but org.apache.wicket.core.util.string.ComponentRenderer in /src/main/java makes use of org.apache.wicket.protocol.http.mock.MockServletContext, so that won’t work).
Should we move only MockHttpSession to wicket-tester then? If not, how to rewrite this line in MockHttpSession.invalidate()?
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.
If we want to move the entire package I don't see many alternatives,,,maybe the best option first glance could be move it into wicket-util module (i.e org.apache.wicket.util.protocol.http.mock ). Waiting for better ideas :-)
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 don't think that moving the package from wicket-core to wicket-util would have advantages.
My initial assumption was that mocking stuff should be only test scoped, but it currently isn't (as ComponentRenderer shows). IMO we should leave it as it is (possibly requiring a better fix in MockHttpSession.java, see diff) OR move just MockHttpSession.java to wicket-tester?
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 think these classes should stay in -core.
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.
Ok, and what about Session session = (Session) attributes.get("wicket:" + BaseWicketTester.TestFilterConfig.class.getName() + ":session");? Where is this relevant?
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.
This seems to be the only open issue of this PR. Could someone please take a closer look at this?
(I just don't see any reference where this attribute "wicket:[class]:session" is set. Related could be AbstractPersistentPageStore.KEY_PREFIX = "wicket:", but I dont see any other ":session" in the code.)
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.
See org.apache.wicket.session.HttpSessionStore#getSessionAttributePrefix
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.
See org.apache.wicket.session.HttpSessionStore#getSessionAttributePrefix
Ok, I see you changed this
originally: ... attributes.get("wicket:" + BaseWicketTester.TestFilterConfig.class.getName() + ":session");
to: ... attributes.get("wicket:org.apache.wicket.util.tester.BaseWicketTester.TestFilterConfig:session");
I wonder if that's correct since TestFilterConfig is an inner class?
A simple alternative would be to save TestFilterConfig as new file and adapt the line to attributes.get("wicket:org.apache.wicket.util.tester.TestFilterConfig:session");
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.
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 fixed the bug!
The best would be to use a real class reference instead of hardcoding a String like now.
…ar' of https://github.com/gluser1357/wicket-fork.git into WICKET-7072-wicket-tester-and-core-tests-without-test-jar
I'll take a new look soon! |
This module is just tests for wicket-core Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
@gluser1357 Why most of the commits in this PR are by user @sre ? What is your relation ? |
org.apache.wicket.core.util.license.ApacheLicenceHeaderTest does nothing in wicket-core-tests module.
Update: Fixed |
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
15fcba5
to
ceacaf2
Compare
My fault, its both me, sre = gluser1357 (Eclipse switched sometimes back to other author/commit that I use in another repo). Sorry for mixing this up :/
Thanks for fixing, I obviously forgot the two overrides in this class. Are sources of wicket-core checked now, or is something to do here? |
None of them are from me. You see 'sre', because that has been used as the full name for git when authoring the commits. Github just shows the name of the commit, since there is no account connected to the mapchart.com mail address used by the 'sre' in this pull request. |
ceacaf2#diff-cd87ffc1ff8683a3f9ae0fcc7055de1691b36452d962a438d32b72840d5f0c99R137-R151 |
Merging ... |
Thanks for pushing this work, @gluser1357 ! |
@sre: Ah, ok, I see, we are both using "sre" ;-) I really have to take care about that when commiting, sorry for this confusion. I wonder that my "sre" commits haven't been checked and rejected by Github :/ |
Ok, tests runs for me on wicket-core with this change, nothing to do anymore here. |
No problem. Thank you as well for your great support. 10.0.0-M2 master doesn't show any errors in Eclipse anymore, that's really great 👍 |
@gluser1357 thank you indeed for your effort! 🙏🏻 |
Just before the weekend, here is the new PR for the updated branch which seems to run now for Eclipse and VSCode.
See latest comments and test results on WICKET-7072.
Thank you for testing and reviewing in different environments.