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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

AEM 6.1 | Sightly , JUnit for Class extending WCMuse

Avatar

Level 4

Hi All,

I have a similar issue as described in this link http://stackoverflow.com/questions/31672975/null-pointer-exception-while-creating-junit-testcases-fo... , Any Solution for this?

Thanks in Advance.

1 Accepted Solution

Avatar

Correct answer by
Level 4

Thanks for the Reply. I figured out a way, this worked for me.

@Cascading
WCMUse wcmUse;

wcmUse.getResource().adaptTo(Node.class);

 

or 

@Mocked
WCMUse wcmUse;

wcmUse.getResource();

 

Thanks!

View solution in original post

2 Replies

Avatar

Level 7

Try acquiring the resourceResolver object like the below example and try once

@Rulepublic final AemContext context = new AemContext();@Testpublic void testSomething() { ResourceResolver resourceResolver = context.resourceResolver(); }

Avatar

Correct answer by
Level 4

Thanks for the Reply. I figured out a way, this worked for me.

@Cascading
WCMUse wcmUse;

wcmUse.getResource().adaptTo(Node.class);

 

or 

@Mocked
WCMUse wcmUse;

wcmUse.getResource();

 

Thanks!