Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

AEM 6.5 Java 11 upgrade: Junit tests with MockSlingHttpServletRequest adaptTo() failing

Avatar

Avatar
Level 1
bytecode0110
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
bytecode0110
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
bytecode0110
Level 1

18-03-2020

On upgrading from Java 8 to Java 11, all unit tests with request.adaptTo() have started failing with NPE - code snippet below. We are using Junit 4 and mockito-core version 2.25.1. Please advice on this issue. Do we need to add additional dependencies when upgrading to Java 11? TIA.

 

import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
Resource resource = resolver.getResource("/abc-component/main_abc_component");
request.setResource(resource);
Abc abc = request.adaptTo(Abc.class);

 

Accepted Solutions (0)

Answers (0)