Skip to content
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

Conversation

gluser1357
Copy link
Contributor

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.

sre and others added 21 commits September 25, 2023 15:00
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>
Copy link
Contributor

@bitstorm bitstorm left a 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;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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).

Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

@solomax
Copy link
Contributor

solomax commented Oct 4, 2023

Just have tested this branch in VSCode

there no errors :))

Hooray! :)

@gluser1357
Copy link
Contributor Author

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
Copy link
Contributor Author

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()?

Copy link
Contributor

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 :-)

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.)

Copy link
Member

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

Copy link
Contributor Author

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");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
Screenshot from 2023-10-12 16-18-31

Copy link
Member

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.

wicket-core/pom.xml Outdated Show resolved Hide resolved
wicket-util/pom.xml Outdated Show resolved Hide resolved
@martin-g
Copy link
Member

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>
@martin-g
Copy link
Member

@gluser1357 Why most of the commits in this PR are by user @sre ? What is your relation ?

@martin-g
Copy link
Member

martin-g commented Oct 12, 2023

org.apache.wicket.core.util.license.ApacheLicenceHeaderTest does nothing in wicket-core-tests module.
Issues:

  1. it does not override before() and licenseHeaders()
  2. even when 1) is fixed it does not check the sources of wicket-core module

Update: Fixed

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
@martin-g martin-g force-pushed the WICKET-7072-wicket-tester-and-core-tests-without-test-jar branch from 15fcba5 to ceacaf2 Compare October 12, 2023 11:51
@gluser1357
Copy link
Contributor Author

gluser1357 commented Oct 12, 2023

@gluser1357 Why most of the commits in this PR are by user @sre ? What is your relation ?

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 :/

org.apache.wicket.core.util.license.ApacheLicenceHeaderTest does nothing in wicket-core-tests module. Issues:

1. it does not override `before()` and `licenseHeaders()`

2. even when 1) is fixed it does not check the sources of `wicket-core` module

Update: Fixed

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?

@sre
Copy link

sre commented Oct 12, 2023

@gluser1357 Why most of the commits in this PR are by user @sre ? What is your relation ?

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.

@martin-g
Copy link
Member

Are sources of wicket-core checked now, or is something to do here?

ceacaf2#diff-cd87ffc1ff8683a3f9ae0fcc7055de1691b36452d962a438d32b72840d5f0c99R137-R151

@martin-g
Copy link
Member

Merging ...
More improvements could be made in a separate PR. This one is too big already!

@martin-g martin-g merged commit b0f3da3 into apache:master Oct 12, 2023
3 checks passed
@martin-g
Copy link
Member

Thanks for pushing this work, @gluser1357 !

@gluser1357
Copy link
Contributor Author

@gluser1357 Why most of the commits in this PR are by user @sre ? What is your relation ?

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.

@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 :/

@gluser1357
Copy link
Contributor Author

Are sources of wicket-core checked now, or is something to do here?

ceacaf2#diff-cd87ffc1ff8683a3f9ae0fcc7055de1691b36452d962a438d32b72840d5f0c99R137-R151

Ok, tests runs for me on wicket-core with this change, nothing to do anymore here.

@gluser1357
Copy link
Contributor Author

Thanks for pushing this work, @gluser1357 !

Thanks for pushing this work, @gluser1357 !

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 👍

@bitstorm
Copy link
Contributor

@gluser1357 thank you indeed for your effort! 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants