Expand my Community achievements bar.

Constructor must call super() or this() Junit

Avatar

Level 5

Hi,

I am trying to execute simple test case, but getting an error. Below is my test case :

@Rule
public AemContext context = new AemContext();

@Test
public void test() throws Exception {

   Resource currentResource = context.create().resource("/content/app/en-us/page",

   "jcr:title", "Title Page", "width", "5","height","9");

   inheritanceValueMap = Mockito.spy(new HierarchyNodeInheritanceValueMap(currentResource));

  Assert.assertThat(inheritanceValueMap.getInherited("width", StringUtils.EMPTY), Is.is("5"));

}

Error I am getting is :

java.lang.VerifyError: (class: com/day/cq/commons/ValueMapWrapper, method: <init> signature: (Lorg/apache/sling/api/resource/ValueMap;)V) Constructor must call super() or this()

Any solution to this?

Thanks,

2 Replies

Avatar

Level 10

Take a look at this community blog on this subject: Adobe CQ/Adobe AEM: How to Write Tests in AEM

Also - I recommend that you watch this GEMS session: From Unit Testing to Integration Test of an AEM Application

Avatar

Level 2

Hi,

This issue usually comes when we use below dependency of uber jar :

<dependency>

   <groupId>com.adobe.aem</groupId>

   <artifactId>uber-jar</artifactId>

   <version>6.2.0</version>

   <classifier>obfuscated-apis</classifier>

   <scope>provided</scope>

</dependency>

Try changing the dependency classifier to apis , as shown below:

<dependency>

   <groupId>com.adobe.aem</groupId>

   <artifactId>uber-jar</artifactId>

   <version>6.2.0</version>

   <classifier>apis</classifier>

   <scope>provided</scope>

</dependency>