initializationError while running integration tests | Community
Skip to main content
Level 2
August 8, 2019
Solved

initializationError while running integration tests

  • August 8, 2019
  • 1 reply
  • 2826 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by seabreeze631

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.

1 reply

seabreeze631AuthorAccepted solution
Level 2
August 10, 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.