Arquillian OSGi :: Container :: Felix :: Embedded

Parent POM for JBoss projects. Provides default project build configuration.

License

License

Categories

Categories

JBoss Container Application Servers Arquillian Application Testing & Monitoring
GroupId

GroupId

org.jboss.arquillian.container
ArtifactId

ArtifactId

arquillian-container-felix-embedded
Last Version

Last Version

2.2.2.Final
Release Date

Release Date

Type

Type

jar
Description

Description

Arquillian OSGi :: Container :: Felix :: Embedded
Parent POM for JBoss projects. Provides default project build configuration.
Project URL

Project URL

http://www.jboss.org/arquillian-container-felix-embedded
Project Organization

Project Organization

JBoss by Red Hat

Download arquillian-container-felix-embedded

How to add to project

<!-- https://jarcasting.com/artifacts/org.jboss.arquillian.container/arquillian-container-felix-embedded/ -->
<dependency>
    <groupId>org.jboss.arquillian.container</groupId>
    <artifactId>arquillian-container-felix-embedded</artifactId>
    <version>2.2.2.Final</version>
</dependency>
// https://jarcasting.com/artifacts/org.jboss.arquillian.container/arquillian-container-felix-embedded/
implementation 'org.jboss.arquillian.container:arquillian-container-felix-embedded:2.2.2.Final'
// https://jarcasting.com/artifacts/org.jboss.arquillian.container/arquillian-container-felix-embedded/
implementation ("org.jboss.arquillian.container:arquillian-container-felix-embedded:2.2.2.Final")
'org.jboss.arquillian.container:arquillian-container-felix-embedded:jar:2.2.2.Final'
<dependency org="org.jboss.arquillian.container" name="arquillian-container-felix-embedded" rev="2.2.2.Final">
  <artifact name="arquillian-container-felix-embedded" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jboss.arquillian.container', module='arquillian-container-felix-embedded', version='2.2.2.Final')
)
libraryDependencies += "org.jboss.arquillian.container" % "arquillian-container-felix-embedded" % "2.2.2.Final"
[org.jboss.arquillian.container/arquillian-container-felix-embedded "2.2.2.Final"]

Dependencies

compile (7)

Group / Artifact Type Version
org.apache.felix : org.apache.felix.main jar 4.2.1
org.apache.felix : org.apache.felix.framework zip 4.2.1
org.jboss.arquillian.container : arquillian-container-spi jar
org.jboss.arquillian.container : arquillian-container-osgi jar 2.2.2.Final
org.jboss.arquillian.testenricher : arquillian-testenricher-osgi jar 2.2.2.Final
org.jboss.arquillian.protocol : arquillian-protocol-osgi jar 2.2.2.Final
org.slf4j : slf4j-api jar 1.5.11

provided (2)

Group / Artifact Type Version
org.osgi : org.osgi.core jar 6.0.0
org.jboss.arquillian.osgi : arquillian-osgi-bundle jar 2.2.2.Final

test (5)

Group / Artifact Type Version
org.jboss.arquillian.junit : arquillian-junit-container jar
org.jboss.logmanager : jboss-logmanager jar 1.4.1.Final
junit : junit jar 4.12
org.slf4j : slf4j-log4j12 jar 1.5.11
org.jboss.arquillian.container : arquillian-container-osgi-tests test-jar 2.2.2.Final

Project Modules

There are no modules declared in this project.

Arquillian OSGi Container

The Arquillian OSGi Container provides Arquillian testing in OSGi frameworks.

Embedded Container Setup

For the JBOSGi Framework setup the following Maven dependencies:

<dependencies>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-container-jbosgi-embedded</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jboss.osgi.framework</groupId>
        <artifactId>jbosgi-framework-core</artifactId>
    </dependency>
</dependencies>

For Apache Felix setup these:

<dependencies>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-container-felix-embedded</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.framework</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.main</artifactId>
    </dependency>
</dependencies>

For Eclipse Equinox setup these:

<dependencies>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-container-equinox-embedded</artifactId>
    </dependency>
    <dependency>
        <groupId>org.eclipse.osgi</groupId>
        <artifactId>org.eclipse.osgi</artifactId>
    </dependency>
</dependencies>

For each of these embedded containers, create an arquillian.xml resource that references a framework configuration file:

<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

	<container qualifier="jboss" default="true">
		<configuration>
            <property name="frameworkProperties">src/test/resources/jbosgi-framework.properties</property>
		</configuration>
	</container>
</arquillian>

The framework configuration file is in standard properties format:

# Properties to configure the Framework
org.osgi.framework.storage=./target/osgi-store
org.osgi.framework.storage.clean=onFirstInit

# Extra System Packages
org.osgi.framework.system.packages.extra=\
	org.jboss.logging;version=3.0,\
    org.slf4j;version=1.6

# Bundles that need to be installed with the Framework automatically 
#org.jboss.osgi.auto.install=\

# Bundles that need to be started automatically 
org.jboss.osgi.auto.start=\
	file://${test.archive.directory}/bundles/org.apache.felix.log.jar,\
	file://${test.archive.directory}/bundles/jboss-osgi-logging.jar,\
	file://${test.archive.directory}/bundles/jbosgi-repository-bundle.jar,\
	file://${test.archive.directory}/bundles/jbosgi-provision-bundle.jar

Check the test/resource folders for each of the container implementations for container specific examples.

Remote Container Setup

The Arquillian OSGi Container also supports deployment to remote containers, running on the same host or remote hosts.

To use a remote Apache Karaf, or any container running an OSGi Enterprise JMX implementation such as Apache Aries JMX , setup the following dependencies:

<dependencies>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-container-karaf-remote</artifactId>
    </dependency>
</dependencies>

For remote containers the arquillian.xml resource describes the JMX connection details:

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

	<container qualifier="karaf" default="true">
		<configuration>
            <property name="jmxServiceURL">service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root</property>
            <property name="jmxUsername">karaf</property>
            <property name="jmxPassword">karaf</property>
		</configuration>
	</container>
</arquillian>

For Apache Aries JMX, enable RMI access to the JVM and use the following configuration:

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

	<container qualifier="aries" default="true">
		<configuration>
            <property name="jmxServiceURL">service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi</property>
            <property name="jmxUsername">username</property>
            <property name="jmxPassword">password</property>
		</configuration>
	</container>
</arquillian>

Managed Container Setup

Managed containers are started in a separate JVM by the Arquillian OSGi Container.

For an Apache Karaf managed container, setup these dependencies:

<dependencies>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-container-karaf-managed</artifactId>
    </dependency>
</dependencies>

... and specify in the arquillian.xml resource the location of a Karaf installation, and JMX connection details:

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

    <container qualifier="jboss" default="true">
        <configuration>
            <property name="autostartBundle">false</property>
            <property name="karafHome">target/apache-karaf-${version.apache.karaf}</property>
            <property name="javaVmArguments">-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n</property>
            <property name="jmxServiceURL">service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root</property>
            <property name="jmxUsername">karaf</property>
            <property name="jmxPassword">karaf</property>
        </configuration>
    </container>
</arquillian>

Arquillian OSGi Tests

A simple test case looks like this

@RunWith(Arquillian.class)
public class SimpleBundleTestCase {

    @ArquillianResource
    BundleContext context;

    @Deployment
    public static JavaArchive createdeployment() {
        final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
        archive.setManifest(new Asset() {
            public InputStream openStream() {
                OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
                builder.addBundleSymbolicName(archive.getName());
                builder.addBundleManifestVersion(2);
                builder.addImportPackages(Bundle.class);
                return builder.openStream();
            }
        });
        return archive;
    }

    @Test
    public void testBundleContextInjection() throws Exception {
        assertNotNull("BundleContext injected", context);
        assertEquals("System Bundle ID", 0, context.getBundle().getBundleId());
    }
    
    @Test
    public void testBundleInjection(@ArquillianResource Bundle bundle) throws Exception {
        // Assert that the bundle is injected
        assertNotNull("Bundle injected", bundle);

        // Assert that the bundle is in state RESOLVED
        // Note when the test bundle contains the test case it
        // must be resolved already when this test method is called
        assertEquals("Bundle RESOLVED", Bundle.RESOLVED, bundle.getState());

        // Start the bundle
        bundle.start();
        assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundle.getState());

        // Assert the bundle context
        BundleContext context = bundle.getBundleContext();
        assertNotNull("BundleContext available", context);

        // Stop the bundle
        bundle.stop();
        assertEquals("Bundle RESOLVED", Bundle.RESOLVED, bundle.getState());
    }
}
org.jboss.arquillian.container

An Innovative Testing Platform for the JVM

Versions

Version
2.2.2.Final
2.2.1.Final
2.2.0.Final
2.1.0.Final
2.1.0.CR18
2.1.0.CR17
2.1.0.CR16
2.1.0.CR15
2.1.0.CR14
2.1.0.CR13
2.1.0.CR12
2.1.0.CR11
2.1.0.CR10
2.1.0.CR9
2.1.0.CR8
2.1.0.CR7
2.1.0.CR6
2.1.0.CR5
2.1.0.CR4
2.1.0.CR3
2.1.0.CR2
1.1.1.Final
1.1.0.Final