initializationError while running integration tests

Avatar

Avatar

seabreeze631

Avatar

seabreeze631

seabreeze631

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

seabreeze631

Avatar

seabreeze631

seabreeze631

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)