TAMAYA-238: OSGI improvements and service loading.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/7251f41c Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/7251f41c Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/7251f41c Branch: refs/heads/master Commit: 7251f41c7fe2506c49ae17ddc0dc96b8b9bd4713 Parents: 065f572 Author: anatole <anat...@apache.org> Authored: Thu Feb 23 01:08:12 2017 +0100 Committer: anatole <anat...@apache.org> Committed: Mon Feb 27 00:05:00 2017 +0100 ---------------------------------------------------------------------- osgi/common/bnd.bnd | 9 + osgi/common/pom.xml | 71 +++- .../java/org/apache/tamaya/osgi/Activator.java | 55 +-- .../java/org/apache/tamaya/osgi/OSGITest.java | 133 ++++++ osgi/features/pom.xml | 145 ------- osgi/features/src/main/features/features.xml | 23 -- .../org/apache/tamaya/osgi/OSGIKarafTest.java | 188 --------- .../src/test/resources/META-INF/OSGIResource | 17 - .../META-INF/javaconfiguration.properties | 21 - .../test/resources/org.ops4j.pax.logging.cfg | 48 --- osgi/karaf-features/pom.xml | 159 ++++++++ .../src/main/features/features.xml | 23 ++ .../test/java/org/apache/tamaya/osgi/Hello.java | 10 + .../java/org/apache/tamaya/osgi/HelloImpl.java | 17 + .../apache/tamaya/osgi/InjectionKarafTest.java | 149 +++++++ .../org/apache/tamaya/osgi/OSGIKarafTest.java | 188 +++++++++ .../src/test/resources/META-INF/OSGIResource | 17 + .../META-INF/javaconfiguration.properties | 21 + .../test/resources/org.ops4j.pax.logging.cfg | 48 +++ osgi/pom.xml | 402 +++++++++++++++++-- pom.xml | 3 +- .../apache/tamaya/usagetracker/ConfigUsage.java | 37 +- .../validation/spi/ConfigModelReader.java | 2 - 23 files changed, 1219 insertions(+), 567 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/common/bnd.bnd ---------------------------------------------------------------------- diff --git a/osgi/common/bnd.bnd b/osgi/common/bnd.bnd index 5115cdd..12952bb 100644 --- a/osgi/common/bnd.bnd +++ b/osgi/common/bnd.bnd @@ -2,3 +2,12 @@ Export-Package: \ org.apache.tamaya.osgi Bundle-Activator: org.apache.tamaya.osgi.Activator Export-Service: org.osgi.service.cm.ConfigurationAdmin +Import-Package: \ + org.osgi.service.cm,\ + org.osgi.framework,\ + org.apache.tamaya,\ + org.apache.tamaya.core,\ + org.apache.tamaya.spi,\ + org.apache.tamaya.functions,\ + org.apache.tamaya.spisupport +Bundle-SymbolicName: org.apache.tamaya.osgi \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/common/pom.xml ---------------------------------------------------------------------- diff --git a/osgi/common/pom.xml b/osgi/common/pom.xml index 6e6a094..797864f 100644 --- a/osgi/common/pom.xml +++ b/osgi/common/pom.xml @@ -29,30 +29,29 @@ <artifactId>tamaya-osgi</artifactId> <packaging>jar</packaging> - <name>Apache Tamaya Modules - OSGi Integration :: ConfigAdmin</name> + <name>Apache Tamaya :: OSGi Integration :: ConfigAdmin</name> <description>Tamaya Based OSGI Implementation of ConfigAdmin and Config Injection</description> - <properties> - <osgi.version>6.0.0</osgi.version> - </properties> - <dependencies> <dependency> <groupId>org.osgi</groupId> - <artifactId>org.osgi.service.cm</artifactId> - <version>1.5.0</version> + <artifactId>org.osgi.core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> - <version>${osgi.version}</version> + <artifactId>org.osgi.util.tracker</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-atinject_1.0_spec</artifactId> - <version>1.0</version> </dependency> <dependency> <groupId>org.apache.tamaya</groupId> @@ -76,12 +75,6 @@ </dependency> <!-- Testing --> - - <!--<dependency>--> - <!--<groupId>org.apache.tamaya.ext</groupId>--> - <!--<artifactId>tamaya-injection</artifactId>--> - <!--<version>${project.version}</version>--> - <!--</dependency>--> <dependency> <groupId>org.hamcrest</groupId> <artifactId>java-hamcrest</artifactId> @@ -91,6 +84,52 @@ <artifactId>junit</artifactId> </dependency> + <!-- OSGI Testbed --> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-forked</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-junit4</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-link-mvn</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-aether</artifactId> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-junit4</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-wrap</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-reference</artifactId> + </dependency> + </dependencies> </project> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java b/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java index 1fe445c..83e1acf 100644 --- a/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java +++ b/osgi/common/src/main/java/org/apache/tamaya/osgi/Activator.java @@ -23,7 +23,6 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceRegistration; import org.osgi.service.cm.ConfigurationAdmin; -import org.osgi.util.tracker.ServiceTracker; import java.util.Dictionary; import java.util.Hashtable; @@ -43,16 +42,12 @@ public class Activator implements BundleActivator { private static final String SERVICE_RANKING_PROP = "org.apache.tamaya.osgi.cm.ranking"; -// private static final String SERVICE_OVERRIDE_PROP = "org.apache.tamaya.osgi.cm.override"; - private static final Integer DEFAULT_RANKING = 10; private static final Logger LOG = Logger.getLogger(Activator.class.getName()); private ServiceRegistration<ConfigurationAdmin> registration; -// private ServiceTracker<Object, Object> injectionTracker; - @Override public void start(BundleContext context) throws Exception { Dictionary<String, Object> props = new Hashtable<>(); @@ -69,52 +64,7 @@ public class Activator implements BundleActivator { } TamayaConfigAdminImpl cm = new TamayaConfigAdminImpl(context); registration = context.registerService(ConfigurationAdmin.class, cm, props); - LOG.info("Registered Tamaya OSGI ConfigAdmin service-"); - - // register injection mechanisms, if not configured otherwise -// val = context.getProperty(SERVICE_INJECT_PROP); -// if(val == null || Boolean.parseBoolean(val)){ -// injectionTracker = new ServiceTracker<Object, Object>(context, Object.class, null) { -// @Override -// public Object addingService(ServiceReference<Object> reference) { -// Object service = context.getService(reference); -// Object pidObj = reference.getProperty(Constants.SERVICE_PID); -// if (pidObj instanceof String) { -// String pid = (String) pidObj; -// ConfigurationAdmin configAdmin = null; -// ServiceReference<ConfigurationAdmin> adminRef = -// context.getServiceReference(ConfigurationAdmin.class); -// if(adminRef!=null){ -// configAdmin = context.getService(adminRef); -// } -// try { -// Configuration targetConfig = null; -// if(configAdmin != null){ -// org.osgi.service.cm.Configuration osgiConfig = configAdmin.getConfiguration(pid); -// if(osgiConfig!=null){ -// targetConfig = new OSGIEnhancedConfiguration(osgiConfig); -// } -// } -// if(targetConfig==null){ -// targetConfig = ConfigurationProvider.getConfiguration(); -// } -// ConfigurationInjection.getConfigurationInjector().configure(service, targetConfig); -// } catch (Exception e) { -// LOG.log(Level.WARNING, "Error configuring Service: " + service, e); -// } -// } else { -// LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj); -// } -// return service; -// } -// -// @Override -// public void removedService(ServiceReference<Object> reference, Object service) { -// context.ungetService(reference); -// } -// }; -// injectionTracker.open(); -// } + LOG.info("Registered Tamaya OSGI ConfigAdmin service."); } @Override @@ -122,9 +72,6 @@ public class Activator implements BundleActivator { if (registration != null) { registration.unregister(); } -// if(injectionTracker!=null){ -// injectionTracker.close(); -// } } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGITest.java ---------------------------------------------------------------------- diff --git a/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGITest.java b/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGITest.java new file mode 100644 index 0000000..1c5b959 --- /dev/null +++ b/osgi/common/src/test/java/org/apache/tamaya/osgi/OSGITest.java @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.osgi; + +import org.apache.tamaya.spi.ConfigurationProviderSpi; +import org.apache.tamaya.spi.ServiceContextManager; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerMethod; +import org.osgi.framework.BundleContext; +import org.osgi.service.cm.ConfigurationAdmin; + +import javax.inject.Inject; +import java.io.IOException; +import java.net.URL; +import java.util.Arrays; +import java.util.Enumeration; + +import static org.junit.Assert.*; +import static org.ops4j.pax.exam.CoreOptions.*; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerMethod.class) +public class OSGITest { + + @Inject + private BundleContext bundleContext; + + @Inject + private ConfigurationAdmin configAdmin; + + private Activator activator = new Activator(); + + @Before + public void setup()throws Exception{ + activator.start(bundleContext); + } + + @After + public void tearDown()throws Exception{ + activator.stop(bundleContext); + } + + @Configuration + public Option[] config() { + return options( + cleanCaches(), + junitBundles(), + mavenBundle("org.apache.felix", "org.apache.felix.configadmin"), + mavenBundle("org.apache.geronimo.specs", "geronimo-annotation_1.2_spec", "1.0"), + mavenBundle("org.apache.tamaya", "tamaya-api"), + mavenBundle("org.apache.tamaya", "tamaya-core"), + mavenBundle("org.apache.tamaya.ext", "tamaya-spisupport"), + mavenBundle("org.apache.tamaya.ext", "tamaya-functions"), + bundle("reference:file:target/classes") + ); + } + + + @Test + public void testConfiguration() throws Exception { + assertNotNull(configAdmin); + org.osgi.service.cm.Configuration config = configAdmin.getConfiguration("tamaya"); + assertNotNull(config); + assertNotNull(config.getProperties()); + assertFalse(config.getProperties().isEmpty()); + assertEquals(config.getProperties().size(), 4); + assertEquals(config.getProperties().get("my.testProperty1"), "success1"); + assertEquals(config.getProperties().get("my.testProperty2"), "success2"); + assertEquals(config.getProperties().get("my.testProperty3"), "success3"); + assertEquals(config.getProperties().get("my.testProperty4"), "success4"); + StringBuilder b = new StringBuilder(); + b.append("Print all configs....\n\n"); + org.osgi.service.cm.Configuration[] configs = configAdmin.listConfigurations(null); + for (org.osgi.service.cm.Configuration cfg : configs) { + b.append("\nConfiguration found in OSGI Container: " + cfg); + b.append("\n-------------------------------------------------"); + } + System.out.println(b.toString()); + } + + @Test + public void ensureEnvironmentIsWorkingAndTamayaIsActive()throws Exception { + assertNotNull(configAdmin); + assertEquals("Tamaya ConfigAdmin is not installed.", + "TamayaConfigAdminImpl", configAdmin.getClass().getSimpleName()); + System.out.println("ConfigAdmin found in OSGI Container: " + configAdmin); + } + + @Test + public void testResourceIsVisible(){ + assertNotNull(ServiceContextManager.getServiceContext() + .getResource("META-INF/javaconfiguration.properties", null)); + } + + @Test + public void testResourcesAreVisible() throws IOException { + Enumeration<URL> urls = ServiceContextManager.getServiceContext() + .getResources("META-INF/javaconfiguration.properties", null); + assertNotNull(urls); + assertTrue(urls.hasMoreElements()); + URL url = urls.nextElement(); + assertNotNull(url); + } + + @Test + public void testServices() { + assertNotNull("ConfigurationProviderSpi service missing.", bundleContext.getService(bundleContext.getServiceReference(ConfigurationProviderSpi.class))); + assertNotNull("ConfigurationAdmin service missing.", bundleContext.getService(bundleContext.getServiceReference(ConfigurationAdmin.class))); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/features/pom.xml ---------------------------------------------------------------------- diff --git a/osgi/features/pom.xml b/osgi/features/pom.xml deleted file mode 100644 index 9414d28..0000000 --- a/osgi/features/pom.xml +++ /dev/null @@ -1,145 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.tamaya.ext</groupId> - <artifactId>tamaya-osgi-all</artifactId> - <version>0.3-incubating-SNAPSHOT</version> - </parent> - - <artifactId>tamaya-features</artifactId> - <packaging>bundle</packaging> - <name>Apache Tamaya Modules - OSGi Integration :: Features</name> - - <properties> - <karaf.version>4.0.7</karaf.version> - <pax.exam.version>4.5.0</pax.exam.version> - </properties> - - <build> - <plugins> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-resources-plugin</artifactId> - <executions> - <execution> - <id>features</id> - <phase>generate-resources</phase> - <goals> - <goal>copy-resources</goal> - </goals> - <configuration> - <resources> - <resource> - <directory>src/main/features</directory> - <filtering>true</filtering> - </resource> - </resources> - <outputDirectory>target/features</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>1.12</version> - <executions> - <execution> - <id>attach-artifacts</id> - <phase>package</phase> - <goals> - <goal>attach-artifact</goal> - </goals> - <configuration> - <artifacts> - <artifact> - <file>target/features/features.xml</file> - <type>xml</type> - <classifier>features</classifier> - </artifact> - </artifacts> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.apache.tamaya.ext</groupId> - <artifactId>tamaya-osgi</artifactId> - <version>${project.version}</version> - <type>jar</type> - </dependency> - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-junit4</artifactId> - <version>${pax.exam.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.ops4j.pax.exam</groupId> - <artifactId>pax-exam-container-karaf</artifactId> - <version>${pax.exam.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.karaf.features</groupId> - <artifactId>framework</artifactId> - <version>${karaf.version}</version> - <type>kar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.karaf.features</groupId> - <artifactId>standard</artifactId> - <version>${karaf.version}</version> - <classifier>features</classifier> - <type>xml</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.karaf.features</groupId> - <artifactId>enterprise</artifactId> - <version>${karaf.version}</version> - <classifier>features</classifier> - <type>xml</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.ops4j.pax.url</groupId> - <artifactId>pax-url-mvn</artifactId> - <version>1.3.7</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - <version>1.3</version> - <scope>test</scope> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/features/src/main/features/features.xml ---------------------------------------------------------------------- diff --git a/osgi/features/src/main/features/features.xml b/osgi/features/src/main/features/features.xml deleted file mode 100644 index 5a36bff..0000000 --- a/osgi/features/src/main/features/features.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Copyright 2013 David Valeri. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="org-apache-tamaya"> - <feature name="configadmin" version="${project.version}"> - <bundle>mvn:${project.groupId}/tamaya-osgi/${project.version}/jar</bundle> - <bundle>mvn:${project.groupId}/tamaya-functions/${project.version}/jar</bundle> - <bundle>mvn:${project.groupId}/tamaya-spi-support/${project.version}/jar</bundle> - <bundle>mvn:org.apache.tamaya/tamaya-api/${project.version}/jar</bundle> - <bundle>mvn:org.apache.tamaya/tamaya-core/${project.version}/jar</bundle> - <bundle>mvn:org.apache.geronimo.specs/geronimo-annotation_1.2_spec/1.0-alpha-1/jar</bundle> - </feature> -</features> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java ---------------------------------------------------------------------- diff --git a/osgi/features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java b/osgi/features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java deleted file mode 100644 index 4baa28e..0000000 --- a/osgi/features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.osgi; - -import org.apache.karaf.features.Feature; -import org.apache.karaf.features.FeaturesService; -import org.apache.tamaya.spi.ServiceContextManager; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.ConfigurationManager; -import org.ops4j.pax.exam.CoreOptions; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.karaf.options.KarafDistributionOption; -import org.ops4j.pax.exam.options.BootClasspathLibraryOption; -import org.ops4j.pax.exam.options.MavenUrlReference; -import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; -import org.ops4j.pax.exam.spi.reactors.PerClass; -import org.ops4j.pax.exam.spi.reactors.PerMethod; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.service.cm.ConfigurationAdmin; -import org.slf4j.Logger; - -import javax.inject.Inject; -import javax.swing.*; -import java.awt.*; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.Enumeration; - -import static org.junit.Assert.*; -import static org.junit.Assert.assertEquals; -import static org.ops4j.pax.exam.CoreOptions.*; - -@Ignore("20170123: deactivated temporarily in order to allow 0.3 release") -@RunWith(PaxExam.class) -@ExamReactorStrategy(PerMethod.class) -public class OSGIKarafTest { - - @Inject - private BundleContext bundleContext; - - @Inject - protected FeaturesService featuresService; - private ConfigurationAdmin configAdmin; - - @Configuration - public Option[] config() { - MavenUrlReference karafStandardRepo = maven() - .groupId("org.apache.karaf.features") - .artifactId("standard") - .classifier("features") - .type("xml") - .version(getKarafVersion()); - MavenUrlReference tamayaRepo = maven() - .groupId("org.apache.tamaya.ext") - .artifactId("tamaya-osgi-features") - .type("xml") - .classifier("features") - .version("0.3-incubating-SNAPSHOT"); - return options( - KarafDistributionOption.karafDistributionConfiguration() - .frameworkUrl(CoreOptions.maven() - .groupId("org.apache.karaf") - .artifactId("apache-karaf") - .type("zip") - .version(getKarafVersion())) - .karafVersion(getKarafVersion()) - .name("ApacheKaraf") - .useDeployFolder(false) - .unpackDirectory(new File("target/karaf")), - // if activated, the remote karaf instance will stop and wait for - // debugger to connect to. -// KarafDistributionOption.debugConfiguration("5006", true), - KarafDistributionOption.configureConsole().ignoreLocalConsole(), - KarafDistributionOption.configureConsole().ignoreRemoteShell(), - // keep runtime folder allowing analysing results - KarafDistributionOption.keepRuntimeFolder(), - // use custom logging configuration file with a custom appender - KarafDistributionOption.replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", new File( - "src/test/resources/org.ops4j.pax.logging.cfg")), - - mavenBundle("org.apache.geronimo.specs", "geronimo-annotation_1.2_spec", "1.0-alpha-1"), - mavenBundle("org.apache.tamaya", "tamaya-api", "0.3-incubating-SNAPSHOT"), - mavenBundle("org.apache.tamaya", "tamaya-core", "0.3-incubating-SNAPSHOT"), - mavenBundle("org.apache.tamaya.ext", "tamaya-spisupport", "0.3-incubating-SNAPSHOT"), - mavenBundle("org.apache.tamaya.ext", "tamaya-functions", "0.3-incubating-SNAPSHOT"), - mavenBundle("org.apache.tamaya.ext", "tamaya-osgi", "0.3-incubating-SNAPSHOT"), - KarafDistributionOption.features( - karafStandardRepo, "scr"), - KarafDistributionOption.features( - tamayaRepo, "tamaya-osgi-features/0.3.0.incubating-SNAPSHOT"), - junitBundles() - ); - } - - public static String getKarafVersion() { - ConfigurationManager cm = new ConfigurationManager(); - String karafVersion = cm.getProperty("pax.exam.karaf.version", "4.0.7"); - return karafVersion; - } - - @Before - public void beforeTest()throws Exception { - featuresService.installFeature("config/4.0.7"); - featuresService.installFeature("tamaya-osgi-features/0.3.0.incubating-SNAPSHOT"); - } - - @Test - public void ensureFeatureIsInstalled() throws Exception { - Feature feature = featuresService.getFeature("tamaya-osgi-features/0.3.0.incubating-SNAPSHOT"); - assertNotNull(feature); - for (Feature feat : featuresService.listFeatures()){ - System.out.println(feat); - } - } - - @Test - public void ensureEnvironmentIsWorkingAndTamayaIsActive() { - ConfigurationAdmin configAdmin = getConfigAdmin(); - assertNotNull(configAdmin); - assertTrue(configAdmin instanceof TamayaConfigAdminImpl); - System.out.println("ConfigAdmin found in Karaf OSGI Container: " + configAdmin); - } - - @Test - public void getConfiguration() throws Exception { - ConfigurationAdmin configAdmin = getConfigAdmin(); - org.osgi.service.cm.Configuration config = configAdmin.getConfiguration("tamaya"); - assertNotNull(config); - assertNotNull(config.getProperties()); - assertFalse(config.getProperties().isEmpty()); - assertEquals(config.getProperties().size(), 4); - assertEquals(config.getProperties().get("my.testProperty1"), "success1"); - assertEquals(config.getProperties().get("my.testProperty2"), "success2"); - assertEquals(config.getProperties().get("my.testProperty3"), "success3"); - assertEquals(config.getProperties().get("my.testProperty4"), "success4"); - StringBuilder b = new StringBuilder(); - b.append("Print all configs....\n\n"); - org.osgi.service.cm.Configuration[] configs = configAdmin.listConfigurations(null); - for (org.osgi.service.cm.Configuration cfg : configs) { - b.append("\nConfiguration found in Karaf OSGI Container: " + cfg); - b.append("\n-------------------------------------------------"); - } - System.out.println(b.toString()); - } - - @Test - public void testResourceIsVisible(){ - assertNotNull(ServiceContextManager.getServiceContext() - .getResource("META-INF/javaconfiguration.properties", null)); - } - - @Test - public void testResourcesAreVisible() throws IOException { - Enumeration<URL> urls = ServiceContextManager.getServiceContext() - .getResources("META-INF/javaconfiguration.properties", null); - assertNotNull(urls); - assertTrue(urls.hasMoreElements()); - URL url = urls.nextElement(); - assertNotNull(url); - } - - public ConfigurationAdmin getConfigAdmin() { - return bundleContext.getService(bundleContext.getServiceReference(ConfigurationAdmin.class)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/features/src/test/resources/META-INF/OSGIResource ---------------------------------------------------------------------- diff --git a/osgi/features/src/test/resources/META-INF/OSGIResource b/osgi/features/src/test/resources/META-INF/OSGIResource deleted file mode 100644 index 20989a6..0000000 --- a/osgi/features/src/test/resources/META-INF/OSGIResource +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/features/src/test/resources/META-INF/javaconfiguration.properties ---------------------------------------------------------------------- diff --git a/osgi/features/src/test/resources/META-INF/javaconfiguration.properties b/osgi/features/src/test/resources/META-INF/javaconfiguration.properties deleted file mode 100644 index f2879a0..0000000 --- a/osgi/features/src/test/resources/META-INF/javaconfiguration.properties +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -[tamaya]my.testProperty1=success1 -[tamaya]my.testProperty2=success2 -[tamaya]my.testProperty3=success3 -[tamaya]my.testProperty4=success4 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/features/src/test/resources/org.ops4j.pax.logging.cfg ---------------------------------------------------------------------- diff --git a/osgi/features/src/test/resources/org.ops4j.pax.logging.cfg b/osgi/features/src/test/resources/org.ops4j.pax.logging.cfg deleted file mode 100644 index 6683438..0000000 --- a/osgi/features/src/test/resources/org.ops4j.pax.logging.cfg +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -#updated by pax-exam -#Sun Nov 27 20:55:11 CET 2016 -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.sift.appender.append=true -log4j.appender.out.maxFileSize=1MB -log4j.appender.audit.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n -log4j.appender.sift.appender.file=${karaf.data}/log/$\\{bundle.name\\}.log -log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout -log4j.appender.out.append=true -log4j.appender.sift.appender=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out=org.apache.log4j.RollingFileAppender -log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n -log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer -log4j.appender.out.file=${karaf.data}/log/karaf.log -log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender -log4j.appender.audit.append=true -log4j.appender.audit.maxBackupIndex=10 -log4j.appender.audit.layout=org.apache.log4j.PatternLayout -log4j.appender.sift.key=bundle.name -log4j.appender.audit.maxFileSize=1MB -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.additivity.org.apache.karaf.jaas.modules.audit=false -log4j.logger.org.apache.karaf.jaas.modules.audit=INFO, audit -log4j.appender.audit.file=${karaf.data}/security/audit.log -log4j.appender.sift.default=karaf -log4j.appender.sift.appender.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %m%n -log4j.appender.out.maxBackupIndex=10 -log4j.appender.audit=org.apache.log4j.RollingFileAppender -log4j.rootLogger=WARN, out, stdout, osgi\:* -log4j.appender.out.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/karaf-features/pom.xml ---------------------------------------------------------------------- diff --git a/osgi/karaf-features/pom.xml b/osgi/karaf-features/pom.xml new file mode 100644 index 0000000..37bd45b --- /dev/null +++ b/osgi/karaf-features/pom.xml @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-osgi-all</artifactId> + <version>0.3-incubating-SNAPSHOT</version> + </parent> + + <artifactId>tamaya-karaf-features</artifactId> + <packaging>jar</packaging> + <description>Tamaya Karaf Integration Tests Suite.</description> + <name>Apache Tamaya :: Karaf :: Features</name> + + <properties> + <karaf.version>4.0.7</karaf.version> + <pax.exam.version>4.5.0</pax.exam.version> + </properties> + + <build> + <plugins> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>features</id> + <phase>generate-resources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <resources> + <resource> + <directory>src/main/features</directory> + <filtering>true</filtering> + </resource> + </resources> + <outputDirectory>target/features</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.12</version> + <executions> + <execution> + <id>attach-artifacts</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file>target/features/features.xml</file> + <type>xml</type> + <classifier>features</classifier> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-osgi</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-atinject_1.0_spec</artifactId> + </dependency> + + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-junit4</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-karaf</artifactId> + </dependency> + <dependency> + <groupId>org.apache.karaf.features</groupId> + <artifactId>framework</artifactId> + <version>${dependency.karaf.version}</version> + <type>kar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.karaf.features</groupId> + <artifactId>standard</artifactId> + <version>${dependency.karaf.version}</version> + <classifier>features</classifier> + <type>xml</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.karaf.features</groupId> + <artifactId>enterprise</artifactId> + <version>${dependency.karaf.version}</version> + <classifier>features</classifier> + <type>xml</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-forked</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-mvn</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-reference</artifactId> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-wrap</artifactId> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>java-hamcrest</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + </dependencies> + +</project> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/karaf-features/src/main/features/features.xml ---------------------------------------------------------------------- diff --git a/osgi/karaf-features/src/main/features/features.xml b/osgi/karaf-features/src/main/features/features.xml new file mode 100644 index 0000000..5a36bff --- /dev/null +++ b/osgi/karaf-features/src/main/features/features.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 2013 David Valeri. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="org-apache-tamaya"> + <feature name="configadmin" version="${project.version}"> + <bundle>mvn:${project.groupId}/tamaya-osgi/${project.version}/jar</bundle> + <bundle>mvn:${project.groupId}/tamaya-functions/${project.version}/jar</bundle> + <bundle>mvn:${project.groupId}/tamaya-spi-support/${project.version}/jar</bundle> + <bundle>mvn:org.apache.tamaya/tamaya-api/${project.version}/jar</bundle> + <bundle>mvn:org.apache.tamaya/tamaya-core/${project.version}/jar</bundle> + <bundle>mvn:org.apache.geronimo.specs/geronimo-annotation_1.2_spec/1.0-alpha-1/jar</bundle> + </feature> +</features> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/Hello.java ---------------------------------------------------------------------- diff --git a/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/Hello.java b/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/Hello.java new file mode 100644 index 0000000..0aef1ad --- /dev/null +++ b/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/Hello.java @@ -0,0 +1,10 @@ +package org.apache.tamaya.osgi; + +/** + * Created by atsticks on 27.12.16. + */ +public interface Hello { + + String sayHello(); + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/HelloImpl.java ---------------------------------------------------------------------- diff --git a/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/HelloImpl.java b/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/HelloImpl.java new file mode 100644 index 0000000..98f5702 --- /dev/null +++ b/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/HelloImpl.java @@ -0,0 +1,17 @@ +package org.apache.tamaya.osgi; + +import org.apache.tamaya.inject.api.Config; + +/** + * Created by atsticks on 27.12.16. + */ +public class HelloImpl implements Hello{ + + @Config("java.version") + private String javaVersion; + + @Override + public String sayHello() { + return "Hello: " + javaVersion; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/InjectionKarafTest.java ---------------------------------------------------------------------- diff --git a/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/InjectionKarafTest.java b/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/InjectionKarafTest.java new file mode 100644 index 0000000..14e83ed --- /dev/null +++ b/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/InjectionKarafTest.java @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.osgi; + +import org.apache.karaf.features.Feature; +import org.apache.karaf.features.FeaturesService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.ConfigurationManager; +import org.ops4j.pax.exam.CoreOptions; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.karaf.options.KarafDistributionOption; +import org.ops4j.pax.exam.options.MavenUrlReference; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerMethod; +import org.osgi.framework.*; +import org.osgi.service.cm.ConfigurationAdmin; + +import javax.inject.Inject; + +import java.io.File; +import java.util.Dictionary; +import java.util.Hashtable; + +import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.ops4j.pax.exam.CoreOptions.*; + +/** + * Created by atsticks on 10.12.16. + */ +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerMethod.class) +public class InjectionKarafTest { + + @Inject + private BundleContext bundleContext; + + @Inject + protected FeaturesService featuresService; + + @org.ops4j.pax.exam.Configuration + public Option[] config() { + MavenUrlReference karafStandardRepo = maven() + .groupId("org.apache.karaf.features") + .artifactId("standard") + .classifier("features") + .type("xml") + .version(getKarafVersion()); + MavenUrlReference tamayaRepo = maven() + .groupId("org.apache.tamaya.ext") + .artifactId("tamaya-osgi-features") + .type("xml") + .classifier("features") + .version("0.3-incubating-SNAPSHOT"); + return options( + KarafDistributionOption.karafDistributionConfiguration() + .frameworkUrl(CoreOptions.maven() + .groupId("org.apache.karaf") + .artifactId("apache-karaf") + .type("zip") + .version(getKarafVersion())) + .karafVersion(getKarafVersion()) + .name("ApacheKaraf") + .useDeployFolder(false) + .unpackDirectory(new File("target/karaf")), + // if activated, the remote karaf instance will stop and wait for + // debugger to connect to. +// KarafDistributionOption.debugConfiguration("5006", true), + KarafDistributionOption.configureConsole().ignoreLocalConsole(), + KarafDistributionOption.configureConsole().ignoreRemoteShell(), + // keep runtime folder allowing analysing results + KarafDistributionOption.keepRuntimeFolder(), + // use custom logging configuration file with a custom appender + KarafDistributionOption.replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", new File( + "src/test/resources/org.ops4j.pax.logging.cfg")), + + mavenBundle("org.apache.geronimo.specs", "geronimo-annotation_1.2_spec", "1.0-alpha-1"), + mavenBundle("org.apache.tamaya", "tamaya-api", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya", "tamaya-core", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya.ext", "tamaya-spisupport", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya.ext", "tamaya-functions", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya.ext", "tamaya-osgi", "0.3-incubating-SNAPSHOT"), + // injection libs + mavenBundle("org.apache.geronimo.specs", "geronimo-atinject_1.0_spec", "1.0"), + mavenBundle("org.apache.tamaya.ext", "tamaya-injection-api", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya.ext", "tamaya-injection", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya.ext", "tamaya-osgi-injection", "0.3-incubating-SNAPSHOT"), + KarafDistributionOption.features( + karafStandardRepo, "scr"), + KarafDistributionOption.features( + tamayaRepo, "tamaya-osgi-features/0.3.0.incubating-SNAPSHOT"), + junitBundles() + ); + } + + public static String getKarafVersion() { + ConfigurationManager cm = new ConfigurationManager(); + String karafVersion = cm.getProperty("pax.exam.karaf.version", "4.0.7"); + return karafVersion; + } + + @Before + public void beforeTest()throws Exception { + featuresService.installFeature("config/4.0.7"); + featuresService.installFeature("tamaya-osgi-features/0.3.0.incubating-SNAPSHOT"); + bundleContext.getService(bundleContext.getServiceReference(ConfigurationAdmin.class)); + } + + @Test + public void checkTamayaInjectionOnService() throws Exception { + Hashtable<String,String> config = new Hashtable<>(); + bundleContext.registerService(Hello.class, new ServiceFactory<Hello>() { + @Override + public Hello getService(Bundle bundle, ServiceRegistration<Hello> registration) { + return new HelloImpl(); + } + + @Override + public void ungetService(Bundle bundle, ServiceRegistration<Hello> registration, Hello service) { + } + }, + config); + ServiceReference<Hello> helloServiceRef = bundleContext.getServiceReference(Hello.class); + assertNotNull(helloServiceRef); + Hello hello = bundleContext.getService(helloServiceRef); + assertNotNull(hello); + assertEquals(hello.sayHello(), "Hello: "); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java ---------------------------------------------------------------------- diff --git a/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java b/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java new file mode 100644 index 0000000..4cc8b90 --- /dev/null +++ b/osgi/karaf-features/src/test/java/org/apache/tamaya/osgi/OSGIKarafTest.java @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.osgi; + +import org.apache.karaf.features.Feature; +import org.apache.karaf.features.FeaturesService; +import org.apache.tamaya.spi.ServiceContextManager; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.ConfigurationManager; +import org.ops4j.pax.exam.CoreOptions; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +//import org.ops4j.pax.exam.karaf.options.KarafDistributionOption; +import org.ops4j.pax.exam.options.BootClasspathLibraryOption; +import org.ops4j.pax.exam.options.MavenUrlReference; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; +import org.ops4j.pax.exam.spi.reactors.PerMethod; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.ConfigurationAdmin; +import org.slf4j.Logger; + +import javax.inject.Inject; +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.Enumeration; + +import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.ops4j.pax.exam.CoreOptions.*; + +@Ignore("20170123: deactivated temporarily in order to allow 0.3 release") +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerMethod.class) +public class OSGIKarafTest { + + @Inject + private BundleContext bundleContext; + + @Inject +// protected FeaturesService featuresService; + private ConfigurationAdmin configAdmin; + + @Configuration + public Option[] config() { + MavenUrlReference karafStandardRepo = maven() + .groupId("org.apache.karaf.features") + .artifactId("standard") + .classifier("features") + .type("xml") + .version(getKarafVersion()); + MavenUrlReference tamayaRepo = maven() + .groupId("org.apache.tamaya.ext") + .artifactId("tamaya-osgi-features") + .type("xml") + .classifier("features") + .version("0.3-incubating-SNAPSHOT"); + return options( +// KarafDistributionOption.karafDistributionConfiguration() +// .frameworkUrl(CoreOptions.maven() +// .groupId("org.apache.karaf") +// .artifactId("apache-karaf") +// .type("zip") +// .version(getKarafVersion())) +// .karafVersion(getKarafVersion()) +// .name("ApacheKaraf") +// .useDeployFolder(false) +// .unpackDirectory(new File("target/karaf")), +// // if activated, the remote karaf instance will stop and wait for +// // debugger to connect to. +//// KarafDistributionOption.debugConfiguration("5006", true), +// KarafDistributionOption.configureConsole().ignoreLocalConsole(), +// KarafDistributionOption.configureConsole().ignoreRemoteShell(), +// // keep runtime folder allowing analysing results +// KarafDistributionOption.keepRuntimeFolder(), +// // use custom logging configuration file with a custom appender +// KarafDistributionOption.replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", new File( +// "src/test/resources/org.ops4j.pax.logging.cfg")), + + mavenBundle("org.apache.geronimo.specs", "geronimo-annotation_1.2_spec", "1.0-alpha-1"), + mavenBundle("org.apache.tamaya", "tamaya-api", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya", "tamaya-core", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya.ext", "tamaya-spisupport", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya.ext", "tamaya-functions", "0.3-incubating-SNAPSHOT"), + mavenBundle("org.apache.tamaya.ext", "tamaya-osgi", "0.3-incubating-SNAPSHOT"), +// KarafDistributionOption.features( +// karafStandardRepo, "scr"), +// KarafDistributionOption.features( +// tamayaRepo, "tamaya-osgi-features/0.3.0.incubating-SNAPSHOT"), + junitBundles() + ); + } + + public static String getKarafVersion() { + ConfigurationManager cm = new ConfigurationManager(); + String karafVersion = cm.getProperty("pax.exam.karaf.version", "4.0.7"); + return karafVersion; + } + +// @Before +// public void beforeTest()throws Exception { +// featuresService.installFeature("config/4.0.7"); +// featuresService.installFeature("tamaya-osgi-features/0.3.0.incubating-SNAPSHOT"); +// } +// +// @Test +// public void ensureFeatureIsInstalled() throws Exception { +// Feature feature = featuresService.getFeature("tamaya-osgi-features/0.3.0.incubating-SNAPSHOT"); +// assertNotNull(feature); +// for (Feature feat : featuresService.listFeatures()){ +// System.out.println(feat); +// } +// } + + @Test + public void ensureEnvironmentIsWorkingAndTamayaIsActive() { + ConfigurationAdmin configAdmin = getConfigAdmin(); + assertNotNull(configAdmin); + assertTrue(configAdmin instanceof TamayaConfigAdminImpl); + System.out.println("ConfigAdmin found in Karaf OSGI Container: " + configAdmin); + } + + @Test + public void getConfiguration() throws Exception { + ConfigurationAdmin configAdmin = getConfigAdmin(); + org.osgi.service.cm.Configuration config = configAdmin.getConfiguration("tamaya"); + assertNotNull(config); + assertNotNull(config.getProperties()); + assertFalse(config.getProperties().isEmpty()); + assertEquals(config.getProperties().size(), 4); + assertEquals(config.getProperties().get("my.testProperty1"), "success1"); + assertEquals(config.getProperties().get("my.testProperty2"), "success2"); + assertEquals(config.getProperties().get("my.testProperty3"), "success3"); + assertEquals(config.getProperties().get("my.testProperty4"), "success4"); + StringBuilder b = new StringBuilder(); + b.append("Print all configs....\n\n"); + org.osgi.service.cm.Configuration[] configs = configAdmin.listConfigurations(null); + for (org.osgi.service.cm.Configuration cfg : configs) { + b.append("\nConfiguration found in Karaf OSGI Container: " + cfg); + b.append("\n-------------------------------------------------"); + } + System.out.println(b.toString()); + } + + @Test + public void testResourceIsVisible(){ + assertNotNull(ServiceContextManager.getServiceContext() + .getResource("META-INF/javaconfiguration.properties", null)); + } + + @Test + public void testResourcesAreVisible() throws IOException { + Enumeration<URL> urls = ServiceContextManager.getServiceContext() + .getResources("META-INF/javaconfiguration.properties", null); + assertNotNull(urls); + assertTrue(urls.hasMoreElements()); + URL url = urls.nextElement(); + assertNotNull(url); + } + + public ConfigurationAdmin getConfigAdmin() { + return bundleContext.getService(bundleContext.getServiceReference(ConfigurationAdmin.class)); + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/karaf-features/src/test/resources/META-INF/OSGIResource ---------------------------------------------------------------------- diff --git a/osgi/karaf-features/src/test/resources/META-INF/OSGIResource b/osgi/karaf-features/src/test/resources/META-INF/OSGIResource new file mode 100644 index 0000000..20989a6 --- /dev/null +++ b/osgi/karaf-features/src/test/resources/META-INF/OSGIResource @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/karaf-features/src/test/resources/META-INF/javaconfiguration.properties ---------------------------------------------------------------------- diff --git a/osgi/karaf-features/src/test/resources/META-INF/javaconfiguration.properties b/osgi/karaf-features/src/test/resources/META-INF/javaconfiguration.properties new file mode 100644 index 0000000..f2879a0 --- /dev/null +++ b/osgi/karaf-features/src/test/resources/META-INF/javaconfiguration.properties @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +[tamaya]my.testProperty1=success1 +[tamaya]my.testProperty2=success2 +[tamaya]my.testProperty3=success3 +[tamaya]my.testProperty4=success4 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/karaf-features/src/test/resources/org.ops4j.pax.logging.cfg ---------------------------------------------------------------------- diff --git a/osgi/karaf-features/src/test/resources/org.ops4j.pax.logging.cfg b/osgi/karaf-features/src/test/resources/org.ops4j.pax.logging.cfg new file mode 100644 index 0000000..6683438 --- /dev/null +++ b/osgi/karaf-features/src/test/resources/org.ops4j.pax.logging.cfg @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#updated by pax-exam +#Sun Nov 27 20:55:11 CET 2016 +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.sift.appender.append=true +log4j.appender.out.maxFileSize=1MB +log4j.appender.audit.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n +log4j.appender.sift.appender.file=${karaf.data}/log/$\\{bundle.name\\}.log +log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout +log4j.appender.out.append=true +log4j.appender.sift.appender=org.apache.log4j.FileAppender +log4j.appender.out.layout=org.apache.log4j.PatternLayout +log4j.appender.out=org.apache.log4j.RollingFileAppender +log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n +log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer +log4j.appender.out.file=${karaf.data}/log/karaf.log +log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender +log4j.appender.audit.append=true +log4j.appender.audit.maxBackupIndex=10 +log4j.appender.audit.layout=org.apache.log4j.PatternLayout +log4j.appender.sift.key=bundle.name +log4j.appender.audit.maxFileSize=1MB +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.additivity.org.apache.karaf.jaas.modules.audit=false +log4j.logger.org.apache.karaf.jaas.modules.audit=INFO, audit +log4j.appender.audit.file=${karaf.data}/security/audit.log +log4j.appender.sift.default=karaf +log4j.appender.sift.appender.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %m%n +log4j.appender.out.maxBackupIndex=10 +log4j.appender.audit=org.apache.log4j.RollingFileAppender +log4j.rootLogger=WARN, out, stdout, osgi\:* +log4j.appender.out.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/7251f41c/osgi/pom.xml ---------------------------------------------------------------------- diff --git a/osgi/pom.xml b/osgi/pom.xml index 9d6fd24..07a5a3b 100644 --- a/osgi/pom.xml +++ b/osgi/pom.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <!-- + + <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -17,36 +18,371 @@ See the License for the specific language governing permissions and limitations under the License. --> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tamaya.ext</groupId> - <artifactId>tamaya-sandbox</artifactId> - <version>0.3-incubating-SNAPSHOT</version> - <relativePath>..</relativePath> - </parent> - <artifactId>tamaya-osgi-all</artifactId> - <packaging>pom</packaging> - <name>Apache Tamaya Modules - OSGi Integration :: all</name> - <description>Tamaya OSGI Integration</description> - <properties> - <karaf.version>4.0.7</karaf.version> - <osgi.version>6.0.0</osgi.version> - <pax.exam.version>4.5.0</pax.exam.version> - </properties> - <modules> - <module>common</module> - <module>features</module> - </modules> - <!-- In order to avoid JVM crashes we explicitly downgrade to 2.18 following advice on: -http://maven.40175.n5.nabble.com/surefire-forked-vm-failed-td5858900.html ---> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.18</version> - </plugin> - </plugins> - </build> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-sandbox</artifactId> + <version>0.3-incubating-SNAPSHOT</version> + <relativePath>..</relativePath> + </parent> + + <artifactId>tamaya-osgi-all</artifactId> + <packaging>pom</packaging> + <name>Apache Tamaya :: OSGi Integration :: ALL</name> + <description>Tamaya OSGI Integration</description> + + <properties> + <osgi.config.version>1.5.0</osgi.config.version> + <osgi.tracker.version>1.5.1</osgi.tracker.version> + + <dependency.pax.exam.version>4.7.0</dependency.pax.exam.version> + <dependency.paxurl.version>2.5.2</dependency.paxurl.version> + <dependency.pax.logging.version>1.8.4</dependency.pax.logging.version> + <dependency.swissbox.version>1.8.2</dependency.swissbox.version> + <dependency.tinybundles.version>2.1.1</dependency.tinybundles.version> + <dependency.base.version>1.5.0</dependency.base.version> + <dependency.slf4j.version>1.6.6</dependency.slf4j.version> + <dependency.mockito.version>1.9.5</dependency.mockito.version> + <dependency.asm.version>3.0</dependency.asm.version> + <dependency.atinject.version>1.0</dependency.atinject.version> + <dependency.karaf.version>4.0.7</dependency.karaf.version> + <dependency.felix.version>5.6.1</dependency.felix.version> + <!-- 1.0.8 and higher require slf4j 1.7 --> + <dependency.logback.version>1.0.7</dependency.logback.version> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.18</version> + </plugin> + </plugins> + </build> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.service.cm</artifactId> + <version>${osgi.config.version}</version> + <!--<scope>provided</scope>--> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <version>${osgi.version}</version> + <!--<scope>provided</scope>--> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> + <version>${osgi.compendium.version}</version> + <!--<scope>provided</scope>--> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.util.tracker</artifactId> + <version>${osgi.tracker.version}</version> + </dependency> + + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>${dependency.mockito.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam</artifactId> + <version>${dependency.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-junit4</artifactId> + <version>${dependency.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-native</artifactId> + <version>${dependency.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-forked</artifactId> + <version>${dependency.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-karaf</artifactId> + <version>${dependency.pax.exam.version}</version> + <scope>test</scope> + </dependency> + <!-- URL Handlers are runtime artifacts. --> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-aether</artifactId> + <version>${dependency.paxurl.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-reference</artifactId> + <version>${dependency.paxurl.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-classpath</artifactId> + <version>${dependency.paxurl.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-assembly</artifactId> + <version>${dependency.paxurl.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-wrap</artifactId> + <version>${dependency.paxurl.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-link</artifactId> + <version>${dependency.paxurl.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.url</groupId> + <artifactId>pax-url-mvn</artifactId> + <version>${dependency.paxurl.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-link-mvn</artifactId> + <version>4.9.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.logging</groupId> + <artifactId>pax-logging-api</artifactId> + <version>${dependency.pax.logging.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${dependency.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-ext</artifactId> + <version>${dependency.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>${dependency.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>${dependency.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jul-to-slf4j</artifactId> + <version>${dependency.slf4j.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>${dependency.slf4j.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>${dependency.logback.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${dependency.logback.version}</version> + </dependency> + + <dependency> + <groupId>org.kohsuke.metainf-services</groupId> + <artifactId>metainf-services</artifactId> + <version>1.2</version> + </dependency> + + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-atinject_1.0_spec</artifactId> + <version>${dependency.atinject.version}</version> + </dependency> + + <dependency> + <groupId>org.ops4j.pax.swissbox</groupId> + <artifactId>pax-swissbox-core</artifactId> + <version>${dependency.swissbox.version}</version> + </dependency> + <dependency> + <groupId>org.ops4j.pax.swissbox</groupId> + <artifactId>pax-swissbox-extender</artifactId> + <version>${dependency.swissbox.version}</version> + </dependency> + <dependency> + <groupId>org.ops4j.pax.swissbox</groupId> + <artifactId>pax-swissbox-optional-jcl</artifactId> + <version>${dependency.swissbox.version}</version> + </dependency> + <dependency> + <groupId>org.ops4j.pax.swissbox</groupId> + <artifactId>pax-swissbox-property</artifactId> + <version>${dependency.swissbox.version}</version> + </dependency> + <dependency> + <groupId>org.ops4j.pax.swissbox</groupId> + <artifactId>pax-swissbox-tracker</artifactId> + <version>${dependency.swissbox.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + <version>${dependency.felix.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.tamaya</groupId> + <artifactId>tamaya-api</artifactId> + <version>0.3-incubating-SNAPSHOT</version> + </dependency> + </dependencies> + + <modules> + <module>common</module> + <!--<module>karaf-features</module>--> + </modules> + + <profiles> + <profile> + <id>felix-osgi6</id> + <activation> + <activeByDefault>true</activeByDefault> + <property> + <name>pax.exam.framework</name> + <value>felix</value> + </property> + </activation> + <properties> + <pax.exam.framework>felix</pax.exam.framework> + </properties> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + <version>4.6.1</version> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + </dependency> + </dependencies> + </profile> + <profile> + <id>equinox</id> + <activation> + <activeByDefault>false</activeByDefault> + <property> + <name>pax.exam.framework</name> + <value>equinox</value> + </property> + </activation> + <properties> + <pax.exam.framework>equinox</pax.exam.framework> + </properties> + <dependencies> + <dependency> + <groupId>org.eclipse.tycho</groupId> + <artifactId>org.eclipse.osgi</artifactId> + </dependency> + </dependencies> + </profile> + <profile> + <id>equinox-osgi6</id> + <activation> + <activeByDefault>false</activeByDefault> + <property> + <name>pax.exam.framework</name> + <value>equinox</value> + </property> + </activation> + <properties> + <pax.exam.framework>equinox</pax.exam.framework> + </properties> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.eclipse.tycho</groupId> + <artifactId>org.eclipse.osgi</artifactId> + <version>3.10.0.v20140606-1445</version> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>org.eclipse.tycho</groupId> + <artifactId>org.eclipse.osgi</artifactId> + </dependency> + </dependencies> + </profile> + <!--<profile>--> + <!--<id>knopflerfish</id>--> + <!--<activation>--> + <!--<activeByDefault>false</activeByDefault>--> + <!--<property>--> + <!--<name>pax.exam.framework</name>--> + <!--<value>knopflerfish</value>--> + <!--</property>--> + <!--</activation>--> + <!--<properties>--> + <!--<pax.exam.framework>knopflerfish</pax.exam.framework>--> + <!--</properties>--> + <!--<repositories>--> + <!--<repository>--> + <!--<id>knopflerfish-releases</id>--> + <!--<url>http://www.knopflerfish.org/maven2</url>--> + <!--</repository>--> + <!--</repositories>--> + <!--<dependencies>--> + <!--<dependency>--> + <!--<groupId>org.knopflerfish</groupId>--> + <!--<artifactId>framework</artifactId>--> + <!--<version>6.0.4</version>--> + <!--</dependency>--> + <!--</dependencies>--> + <!--</profile>--> + </profiles> + </project>