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

initializationError while running integration tests

Avatar

Avatar
Validate 1
Level 1
seabreeze631
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
seabreeze631
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
seabreeze631
Level 1

08-08-2019

Hi everyone,

I would like to create integration tests using Teleporter for my AEM project but run into and error while trying to execute a simple test.

I run the command mvn clean verify -PintegrationTests -Dtest.server.url=http://localhost:4502

and receive this error:

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.346 s <<< FAILURE! - in com.adobe.wknd.it.launcher.SlingServerSideTest

[ERROR] initializationError(com.adobe.wknd.it.tests.BasicTeleporterTest)(com.adobe.wknd.it.launcher.SlingServerSideTest)  Time elapsed: 0.006 s  <<< FAILURE!

java.lang.AssertionError: initializationError(com.adobe.wknd.it.tests.BasicTeleporterTest): Lorg/apache/sling/junit/rules/TeleporterRule;

Here's the test im trying to run:

package com.adobe.wknd.it.tests;

import org.apache.sling.junit.rules.TeleporterRule;
import org.junit.Rule;
import org.junit.Test;
import org.osgi.framework.BundleContext;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;

import java.io.IOException;
import java.util.UUID;

import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;

public class BasicTeleporterTest {

   @Rule
   public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "Launchpad");

   @Test
   public void testBundleContext() {

   final BundleContext bc = teleporter.getService(BundleContext.class);
   assertNotNull("Teleporter should provide a BundleContext", bc);
   }

   @Test
   public void testConfigAdmin() throws IOException {

   final String pid = "TEST_" + getClass().getName() + UUID.randomUUID();

  final ConfigurationAdmin ca = teleporter.getService(ConfigurationAdmin.class);
   assertNotNull("Teleporter should provide a ConfigurationAdmin", ca);

  final Configuration cfg = ca.getConfiguration(pid);
   assertNotNull("Expecting to get a Configuration", cfg);
   assertEquals("Expecting the correct pid", pid, cfg.getPid());
   }

}

My project is based on version 19 of the AEM archetype and the pom files are largely unchanged.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 1
seabreeze631
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
seabreeze631
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
seabreeze631
Level 1

09-08-2019

The issue I encountered can be resolved by:

Making sure you import all packages required to run you tests (by default, every packaged needed is imported Apache Felix - Apache Felix Maven Bundle Plugin (BND) ). Also update your org.apache.sling.junit.core bundle to make sure TeleporterRule is there and exported correctly.

Answers (0)