import java.io.File;
import javax.inject.Inject;
import org.junit.Before;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.MavenUtils;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.OptionUtils;
import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
import org.ops4j.pax.exam.options.MavenUrlReference;
+import org.ops4j.pax.exam.options.extra.VMOption;
import org.ops4j.pax.exam.util.Filter;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AbstractMdsalTestBase implements BindingAwareProvider {
+public abstract class AbstractMdsalTestBase {
private static final Logger LOG = LoggerFactory.getLogger(AbstractMdsalTestBase.class);
private static final String MAVEN_REPO_LOCAL = "maven.repo.local";
- private static final String ORG_OPS4J_PAX_URL_MVN_LOCAL_REPOSITORY = "org.ops4j.pax.url.mvn.localRepository";
private static final String ETC_ORG_OPS4J_PAX_URL_MVN_CFG = "etc/org.ops4j.pax.url.mvn.cfg";
private static final String ETC_ORG_OPS4J_PAX_LOGGING_CFG = "etc/org.ops4j.pax.logging.cfg";
private static final String KARAF_DEBUG_PORT = "5005";
private static final String KARAF_DEBUG_PROP = "karaf.debug";
private static final String KEEP_UNPACK_DIRECTORY_PROP = "karaf.keep.unpack";
- private static final int REGISTRATION_TIMEOUT = 70000;
/*
* Default values for karaf distro type, groupId, and artifactId
* Property names to override defaults for karaf distro artifactId, groupId,
* version, and type
*/
- private static final String KARAF_DISTRO_VERSION_PROP = "karaf.distro.version";
private static final String KARAF_DISTRO_TYPE_PROP = "karaf.distro.type";
private static final String KARAF_DISTRO_ARTIFACTID_PROP = "karaf.distro.artifactId";
private static final String KARAF_DISTRO_GROUPID_PROP = "karaf.distro.groupId";
@Inject @Filter(timeout = 60000)
private BundleContext context;
- @Inject @Filter(timeout = 60000)
- private BindingAwareBroker broker;
- private ProviderContext session = null;
-
- public ProviderContext getSession() {
- return session;
- }
public abstract MavenUrlReference getFeatureRepo();
public abstract String getFeatureName();
- @Override
- public void onSessionInitiated(ProviderContext session) {
- LOG.info("Session Initiated: {}",session);
- this.session = session;
- }
-
@Before
public void setup() throws Exception {
- long start = System.nanoTime();
- broker.registerProvider(this);
- for (int i = 0; i < REGISTRATION_TIMEOUT; i++) {
- if (session != null) {
- long stop = System.nanoTime();
- LOG.info("Registered session {} with the MD-SAL after {} ns",
- session,
- stop - start);
- return;
- } else {
- Thread.sleep(1);
- }
- }
- throw new RuntimeException("Session not initiated after " + REGISTRATION_TIMEOUT + " ms");
}
public Option getLoggingOption() {
* @return An array of additional config options
*/
protected Option[] getAdditionalOptions() {
- return null;
+ return new Option[0];
}
/**
protected Option mvnLocalRepoOption() {
String mvnRepoLocal = System.getProperty(MAVEN_REPO_LOCAL, "");
LOG.info("mvnLocalRepo \"{}\"", mvnRepoLocal);
- return editConfigurationFilePut(ETC_ORG_OPS4J_PAX_URL_MVN_CFG, ORG_OPS4J_PAX_URL_MVN_LOCAL_REPOSITORY,
- mvnRepoLocal);
+ return editConfigurationFilePut(ETC_ORG_OPS4J_PAX_URL_MVN_CFG,
+ "org.ops4j.pax.url.mvn.localRepository", mvnRepoLocal);
}
@Configuration
.unpackDirectory(new File(PAX_EXAM_UNPACK_DIRECTORY)).useDeployFolder(false),
when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()),
features(getFeatureRepo(), getFeatureName()),
- //mavenBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api", "1.0.0"), getLoggingOption(),
mvnLocalRepoOption(),
+
+ // Make sure karaf's default repository is consulted before anything else
+ editConfigurationFilePut(ETC_ORG_OPS4J_PAX_URL_MVN_CFG, "org.ops4j.pax.url.mvn.defaultRepositories",
+ "file:${karaf.home}/${karaf.default.repository}@id=system.repository"),
+
configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
editConfigurationFilePut(ETC_ORG_OPS4J_PAX_LOGGING_CFG, "log4j2.rootLogger.level", "INFO") };
+
+ final String karafVersion = MavenUtils.getArtifactVersion("org.apache.karaf.features",
+ "org.apache.karaf.features.core");
+ options = OptionUtils.combine(options, new VMOption[] {
+ new VMOption("--add-reads=java.xml=java.logging"),
+ new VMOption("--add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED"),
+ new VMOption("--patch-module"),
+ new VMOption("java.base=lib/endorsed/org.apache.karaf.specs.locator-" + karafVersion + ".jar"),
+ new VMOption("--patch-module"),
+ new VMOption("java.xml=lib/endorsed/org.apache.karaf.specs.java.xml-" + karafVersion + ".jar"),
+ new VMOption("--add-opens"),
+ new VMOption("java.base/java.security=ALL-UNNAMED"),
+ new VMOption("--add-opens"),
+ new VMOption("java.base/java.net=ALL-UNNAMED"),
+ new VMOption("--add-opens"),
+ new VMOption("java.base/java.lang=ALL-UNNAMED"),
+ new VMOption("--add-opens"),
+ new VMOption("java.base/java.util=ALL-UNNAMED"),
+ new VMOption("--add-opens"),
+ new VMOption("java.naming/javax.naming.spi=ALL-UNNAMED"),
+ new VMOption("--add-opens"),
+ new VMOption("java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"),
+ new VMOption("--add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED"),
+ new VMOption("--add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED"),
+ new VMOption("--add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED"),
+ new VMOption("--add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED"),
+ new VMOption("-classpath"),
+ new VMOption("lib/jdk9plus/*" + File.pathSeparator + "lib/boot/*")
+ });
+
return OptionUtils.combine(options, getAdditionalOptions());
}
}