Skip to content

Commit

Permalink
Upgraded karaf4 to 4.2.0 for java9 and 10 support (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
garethahealy authored Apr 13, 2018
1 parent 6af33dc commit 0586ddb
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 6 deletions.
1 change: 1 addition & 0 deletions plugins-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-modules java.xml.bind,java.activation
Expand Down
38 changes: 37 additions & 1 deletion tests/dozer-osgi-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<name>Dozer :: Tests :: OSGi Bundle Tests</name>

<properties>
<org.ops4j.pax.logging.DefaultServiceLog.level>DEBUG</org.ops4j.pax.logging.DefaultServiceLog.level>
<karaf4-version>4.2.0</karaf4-version>
</properties>

<dependencies>
Expand Down Expand Up @@ -176,6 +176,33 @@
<artifactId>javax.inject</artifactId>
<scope>test</scope>
</dependency>

<!-- Karaf4 distribution zip -->
<dependency>
<groupId>org.apache.karaf</groupId>
<artifactId>apache-karaf</artifactId>
<version>${karaf4-version}</version>
<type>zip</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.dev</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.karaf</groupId>
<artifactId>org.apache.karaf.client</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -210,6 +237,15 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<karafVersion>${karaf4-version}</karafVersion>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@
import com.github.dozermapper.osgitests.support.OsgiTestSupport;
import com.github.dozermapper.osgitestsmodel.Person;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.ProbeBuilder;
import org.ops4j.pax.exam.TestProbeBuilder;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
Expand All @@ -38,8 +45,27 @@

public abstract class AbstractDozerCoreOsgiContainerTest extends OsgiTestSupport {

protected static final Logger LOG = LoggerFactory.getLogger(AbstractDozerCoreOsgiContainerTest.class);

@Inject
private BundleContext bundleContext;
protected BundleContext bundleContext;

@ProbeBuilder
public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
// makes sure the generated Test-Bundle contains this import!
probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, "*");
return probe;
}

@Before
public void setUp() {
LOG.info("setUp() using BundleContext: {}", bundleContext);
}

@After
public void tearDown() {
LOG.info("tearDown()");
}

@Configuration
public Option[] config() {
Expand Down Expand Up @@ -71,7 +97,8 @@ public void canGetBundleFromDozerCore() {

for (Bundle current : bundleContext.getBundles()) {
//Ignore any Karaf bundles
if (current.getSymbolicName().startsWith("org.apache.karaf")) {
if (current.getSymbolicName().startsWith("org.apache.karaf")
|| current.getSymbolicName().startsWith("org.jline")) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,24 @@
import java.io.File;

import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.karaf.options.LogLevelOption;

import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.doNotModifyLogConfiguration;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;

public final class KarafOptions {

private static final String FRAMEWORK_GROUP_ID = "org.apache.karaf";
private static final String FRAMEWORK_ARTIFACT_ID = "apache-karaf";

public static Option karaf4ContainerConfigOptions() {
return karafContainerConfigOptions("4.1.2");
return karafContainerConfigOptions(System.getProperty("karafVersion"));
}

private static Option karafContainerConfigOptions(String version) {
Expand All @@ -41,12 +46,24 @@ private static Option karafContainerConfigOptions(String version) {
.artifactId(FRAMEWORK_ARTIFACT_ID)
.version(version)
.type("zip")
.versionAsInProject()
)
.karafVersion(version)
.name("Apache Karaf " + version)
.unpackDirectory(new File("target/paxexam/unpack"))
.useDeployFolder(false),
doNotModifyLogConfiguration()
logLevel(LogLevelOption.LogLevel.INFO),

// Keep the folder so we can look inside when something fails
keepRuntimeFolder(),

// Disable the SSH port
configureConsole().ignoreRemoteShell(),

vmOption("-Dfile.encoding=UTF-8"),

// Disable the Karaf shutdown port
editConfigurationFilePut("etc/custom.properties", "karaf.shutdown.port", "-1")
);
}
}

0 comments on commit 0586ddb

Please sign in to comment.