All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.tester.bundle.engine.BundleDescriptor Maven / Gradle / Ivy

Go to download

A bnd tester using JUnit Platform. Like biz.aQute.tester, this bundle will add itself to the -runbundles at the end. At startup, this bundle will then look for TestEngine implementations among the loaded bundles and use them to execute the tests. This bundle does NOT contain the necessary TestEngine implementations for JUnit 3, 4 or 5 - it will import them just like any other bundle.

There is a newer version: 7.0.0
Show newest version
package aQute.tester.bundle.engine;

import java.util.HashMap;
import java.util.Map;

import org.junit.platform.engine.ConfigurationParameters;
import org.junit.platform.engine.EngineExecutionListener;
import org.junit.platform.engine.ExecutionRequest;
import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.TestEngine;
import org.junit.platform.engine.UniqueId;
import org.junit.platform.engine.support.descriptor.AbstractTestDescriptor;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;

public class BundleDescriptor extends AbstractTestDescriptor {

	final private Bundle							bundle;
	final private BundleException					bundleException;
	final private Map	engineMap	= new HashMap<>();

	public static String displayNameOf(Bundle bundle) {
		return "[" + bundle.getBundleId() + "] " + bundle.getSymbolicName() + ';'
			+ bundle.getVersion();
	}

	public BundleDescriptor(Bundle bundle, UniqueId uniqueId) {
		this(bundle, uniqueId, null);
	}

	public BundleDescriptor(Bundle bundle, UniqueId uniqueId, BundleException bundleException) {
		super(uniqueId, displayNameOf(bundle));
		this.bundle = bundle;
		this.bundleException = bundleException;
	}

	public Bundle getBundle() {
		return bundle;
	}

	public void addChild(TestDescriptor descriptor, TestEngine engine) {
		engineMap.put(descriptor, engine);
		addChild(descriptor);
	}

	public void executeChild(TestDescriptor descriptor, EngineExecutionListener listener, ConfigurationParameters params) {
		TestEngine engine = engineMap.get(descriptor);
		ExecutionRequest er = new ExecutionRequest(descriptor, listener, params);
		engine.execute(er);

	}
	@Override
	public Type getType() {
		return bundleException == null ? Type.CONTAINER : Type.TEST;
	}

	public BundleException getException() {
		return bundleException;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy