jakartaee / rest

Jakarta RESTful Web Services
Other
361 stars 117 forks source link

Question: How to build from source and test in local machine? #1144

Open frankiie12a9 opened 1 year ago

frankiie12a9 commented 1 year ago

Hello Hosts!

I'm curious about the guidance on building the project from source. Is there any guidance on building this project from the source and testing in the local machine?

mkarg commented 1 year ago

Hello @codeforfut17! Building JAX-RS from scratch is rather simple:

If there are problem, feel free to ask here!

andygibson commented 1 year ago

(TLDR; looks like the mockito version needs an update, but I'd be happy to supply a patch for my changes below if thats not an option)

While browsing projects, I decided to have a go, I pulled the latest source and tried to build (java 19.0.2 & mvn 3.9.3). First problem I hit was in all the seBootstrapTest.java tests

SeBootstrapTest.setUp:xxx » IllegalState Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)

After a bit of searching, I found that bumping the mockito version fixes it (3.12.0 sufficed). I then hit my next problem in seBootstrapTest -

SeBootstrapTest.shouldPullCorrespondingPropertiesFromConfiguration:201 Mockito 
Cannot call abstract real method on java object!
Calling real methods is only possible when mocking non abstract method.

The problem here is that mockito (or at least that version) has trouble invoking willCallRealMethod on default methods of an interface. A quick fix was to create an Abstract class (with no implementations) that implemented the interface, and mock/spy on that instead. It also needs doing for any attempts to mock/spy on SeBootstrap.Configuration.Builder.class

The other alternative is to bump the mockito version to a much more recent version, and everything passes as-is.