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

SWC-7040 - Bump Java version to 11 #5500

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

nickgros
Copy link
Contributor

@nickgros nickgros commented Aug 28, 2024

Also bump Guice to 6, Mockito to 2, and lock guice-assistedinject to 6 to override Gin.

Migrate many tests to be compatible with Mockito 2. The main reason tests had to change was because anyString() and any(Foo.class) matchers do not allow null as a valid match in v2, but they do in v1. In these cases, just use any()

Also fix the dev scripts so now yarn dev should launch the GWT Codeserver and a Tomcat 9 container that will re-compile on refresh if there's a source code change.

We should be able to upgrade to Java 17 at a later date just by upgrading the JDK and compile target.

Also bump Guice to 6, Mockito to 2, and lock guice-assistedinject to 6 to override Gin.

Migrate many tests to be compatible with Mockito 2. The main reason tests had to change was because `anyString()` and `any(Foo.class)` matchers do not allow `null` as a valid match in v2, but they do in v1. In these cases, just use `any()`
"dev:codeserver": "mvn gwt:run-codeserver -Dgwt.compiler.skip=true -Dnoserver=true -Dwar=/$(pwd)/target/portal-develop-SNAPSHOT -Dstyle=PRETTY",
"dev": "concurrently -k -n \"CODESERVER,TOMCAT\" -c \"auto,auto\" \"yarn dev:codeserver\" \"yarn dev:tomcat\"",
"dev:codeserver": "mvn clean gwt:run-codeserver",
"dev:tomcat": "wait-on tcp:9876 && docker pull tomcat:9.0; docker run --name swc-dev --rm -p 8888:8080 -v \"/$(pwd)/target/portal-develop-SNAPSHOT/:/usr/local/tomcat/webapps/ROOT/\" -v \"/$HOME/.m2/settings.xml\":/root/.m2/settings.xml tomcat:9.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait-on will prevent Tomcat from launching until the code server is ready

@@ -138,7 +138,7 @@
import org.sagebionetworks.web.shared.exceptions.UnauthorizedException;
import org.sagebionetworks.web.shared.exceptions.UnknownErrorException;

@RunWith(MockitoJUnitRunner.class)
@RunWith(MockitoJUnitRunner.Silent.class)
Copy link
Contributor Author

@nickgros nickgros Aug 28, 2024

Choose a reason for hiding this comment

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

Without Silent, mockito fails tests that have mocks that are not called. Which is great, but a ton of unnecessary work to fix.

when(
mockRequestBuilder.sendRequest(anyString(), any(RequestCallback.class))
)
when(mockRequestBuilder.sendRequest(any(), any(RequestCallback.class)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For nearly all of these test changes, the mock was called where the matcher received null. In Mockito v1, anyString() matched null. In Mockito v2, it does not. Replace it with any().

Copy link
Member

Choose a reason for hiding this comment

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

Ah, now I understand why my newly checked in test with anyLong() may fail :)

@nickgros nickgros changed the title SWC-7040 - Bump Java version to 17 SWC-7040 - Bump Java version to 11 Aug 28, 2024
@nickgros nickgros merged commit 7db9365 into Sage-Bionetworks:develop Aug 28, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants