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

Use the same JUnit version everywhere #1500

Closed
1 of 2 tasks
iluwatar opened this issue Aug 21, 2020 · 19 comments · Fixed by #1542, #1668, #1529 or #1505
Closed
1 of 2 tasks

Use the same JUnit version everywhere #1500

iluwatar opened this issue Aug 21, 2020 · 19 comments · Fixed by #1542, #1668, #1529 or #1505

Comments

@iluwatar
Copy link
Owner

iluwatar commented Aug 21, 2020

At the moment there are some modules that are still using JUnit 4. Most of the codebase uses JUnit 5, but even with that there are different versions. For example unit-of-work and partial-response declare their own versions.

In this ticket let's try to apply the same version of JUnit 5 everywhere upgrading from JUnit 4 where needed.

This issue has been partially addressed using #1542 and #1668

Tests from two modules serverless and naked-objects are not being executed.

Respective issues have been opened for resolving the tests in favour of these two modules.

Resolving these two issues should close this current issue

@ImLynxie
Copy link
Contributor

I'd like to take this issue. Thank you in advance.

@iluwatar
Copy link
Owner Author

Yes @ToxicDreamz, go ahead ☺️

@ImLynxie
Copy link
Contributor

Half way through upgrading, one test case seems to be causing an issue, within the Serverless module, in specific the SavePersonApiHandlerTest#handleRequestSavePersonException() method. I do not have any knowledge of the AWS library, which is why I chose not to mess around with it.

Initially the DynamoDBMapper was being Mocked with Mockito, and was causing issues once the tests were upgraded to JUnit 5 stating that the class could not be mocked, but as stated in the official Mockito guidelines, a type should not be mocked if it doesn't belong to you. See attached link below for details.

https://github.com/mockito/mockito/wiki/How-to-write-good-tests#dont-mock-a-type-you-dont-own

Suggestion.

A new issue should be opened to address that certain test case, as of now the test case is commented out and marked with a TODO

Displayed Error

> 
> Caused by: com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
> 	at com.amazonaws.client.builder.AwsClientBuilder.setRegion(AwsClientBuilder.java:371)
> 	at com.amazonaws.client.builder.AwsClientBuilder.configureMutableProperties(AwsClientBuilder.java:337)
> 	at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
> 	at com.iluwatar.serverless.baas.api.SavePersonApiHandlerTest.<clinit>(SavePersonApiHandlerTest.java:58)
> 	... 53 more

Error after supplying region`

> com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain
> 
> 	at com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials(AWSCredentialsProviderChain.java:131)
> 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.getCredentialsFromContext(AmazonHttpClient.java:1164)
> 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.runBeforeRequestHandlers(AmazonHttpClient.java:762)
> 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:724)
> 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:717)
> 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
> 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
> 	at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
> 	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
> 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:3082)
> 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:3058)
> 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executePutItem(AmazonDynamoDBClient.java:2119)
> 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.putItem(AmazonDynamoDBClient.java:2094)
> 	at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$SaveObjectHandler.doPutItem(DynamoDBMapper.java:883)
> 	at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$1.executeLowLevelRequest(DynamoDBMapper.java:536)
> 	at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$SaveObjectHandler.execute(DynamoDBMapper.java:733)
> 	at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:623)
> 	at com.amazonaws.services.dynamodbv2.datamodeling.AbstractDynamoDBMapper.save(AbstractDynamoDBMapper.java:123)
> 	at com.iluwatar.serverless.baas.api.SavePersonApiHandler.handleRequest(SavePersonApiHandler.java:50)
> 	at com.iluwatar.serverless.baas.api.SavePersonApiHandlerTest.handleRequestSavePersonSuccessful(SavePersonApiHandlerTest.java:76)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
> 	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
> 	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
> 	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
> 	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132)
> 	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124)
> 	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74)
> 	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
> 	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
> 	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
> 	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
> 	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43)
> 	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35)
> 	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
> 	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
> 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202)
> 	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198)
> 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
> 	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
> 	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
> 	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
> 	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
> 	at java.base/java.util.ArrayList.forEach(ArrayList.java:1507)
> 	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
> 	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
> 	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
> 	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
> 	at java.base/java.util.ArrayList.forEach(ArrayList.java:1507)
> 	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
> 	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
> 	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
> 	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
> 	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
> 	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
> 	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
> 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
> 	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197)
> 	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
> 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
> 	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
> 	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
> 	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
> 	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
> 	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

@ImLynxie
Copy link
Contributor

Overall the serverless module needs to be looked at, more tests are causing the same issues due to them not being able to be mocked.

@stefanbirkner
Copy link
Contributor

@ToxicDreamz FYI: I created #1505 which removes the dependency of subclass-sandbox to Rule, which is a JUnit 4 only feature.

@ImLynxie
Copy link
Contributor

@stefanbirkner Okay, thank you for the heads up. I'll wait for @iluwatar to merge that PR, until I continue with that module.

@iluwatar
Copy link
Owner Author

It's merged now

@mookkiah
Copy link
Contributor

Using JUnit 5 in Trampoline module. PR #1529 created.

@sgarg5794
Copy link

I want to work on this issue if its is still unassigned .

@iluwatar
Copy link
Owner Author

Ok @sgarg5794

@charlesfinley
Copy link
Contributor

I'm working on updating all the modules to JUnit5 right now. @ohbus

@ohbus
Copy link
Contributor

ohbus commented Mar 5, 2021

Sure @charlesfinley you're good to go!

@ohbus ohbus assigned charlesfinley and unassigned sgarg5794 and ImLynxie Mar 5, 2021
@charlesfinley
Copy link
Contributor

Sure @charlesfinley you're good to go!

Sorry I opened a new PR for this - #1668

@ohbus
Copy link
Contributor

ohbus commented Mar 5, 2021

@charlesfinley no need to be sorry for 😄 It is easier for us to review code in smaller chunks and this helps a lot 💯

Thank you so much for your help!

@charlesfinley
Copy link
Contributor

@charlesfinley no need to be sorry for 😄 It is easier for us to review code in smaller chunks and this helps a lot 💯

Thank you so much for your help!

This issue should probably be closed since the PR was merged and we have 2 new issues identifying the only modules lacking JUnit5.

@ohbus
Copy link
Contributor

ohbus commented Mar 7, 2021

@charlesfinley great work!

We will close this issue for sure.

@ohbus
Copy link
Contributor

ohbus commented Mar 7, 2021

This issue has been partially addressed using #1542 and #1668 thanks to @charlesfinley

Tests from two modules serverless and naked-objects are not being executed.

Respective issues have been opened for resolving the tests in favour of these two modules.

Resolving these two issues should close this current issue

@anuragagarwal561994
Copy link
Contributor

@iluwatar let me know how can I help with this, I am confused about the status of the what has been resolved and what is pending.

@iluwatar
Copy link
Owner Author

iluwatar commented Jul 1, 2022

Thanks for asking @anuragagarwal561994. I think the only remaining issue is that naked objects pattern still uses JUnit 4. Resolving this is covered by issues #1669 and #1683. I think we should close this task.

@iluwatar iluwatar closed this as completed Jul 1, 2022
@iluwatar iluwatar added this to the 1.26.0 milestone Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment