You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2015/11/25 08:17:46 UTC
[2/4] incubator-tamaya git commit: Added arquilian tests.
Added arquilian tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/41132393
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/41132393
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/41132393
Branch: refs/heads/master
Commit: 411323931a542ac49ec01e0670ef7ffb536d154e
Parents: cb3eef4
Author: anatole <an...@apache.org>
Authored: Wed Nov 25 08:15:39 2015 +0100
Committer: anatole <an...@apache.org>
Committed: Wed Nov 25 08:15:39 2015 +0100
----------------------------------------------------------------------
.../tamaya/integration/osgi/base/Activator.java | 65 ++++++++
.../osgi/base/TamayaConfigAdminImpl.java | 156 +++++++++++++++++++
.../osgi/base/TamayaConfigurationImpl.java | 120 ++++++++++++++
.../osgi/general/TamayaConfigAdminImpl.java | 156 -------------------
.../osgi/general/TamayaConfigurationImpl.java | 120 --------------
.../osgi/base/TestConfigIntegration.java | 134 ++++++++++++++++
.../META-INF/javaconfiguration.properties | 18 +++
.../general/src/test/resource/arquilian.xml | 27 ++++
.../general/src/test/resource/felix.properties | 18 +++
9 files changed, 538 insertions(+), 276 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/41132393/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/Activator.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/Activator.java b/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/Activator.java
new file mode 100644
index 0000000..e015a47
--- /dev/null
+++ b/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/Activator.java
@@ -0,0 +1,65 @@
+/*
+ * 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.integration.osgi.base;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+/**
+ * Activator that registers the Tamaya based Service Class for {@link ConfigurationAdmin},
+ * using a default service priority of {@code 0}.
+ */
+public class Activator implements BundleActivator {
+
+ private static final String SERVICE_RANKING_PROP = "org.tamaya.integration.cm.ranking";
+
+ private static final Integer DEFAULT_RANKING = Integer.MIN_VALUE + 100;
+
+ private BundleContext context;
+
+ ServiceRegistration<ConfigurationAdmin> registration;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ Dictionary<String,Object> props = new Hashtable<>();
+ String ranking = context.getProperty(SERVICE_RANKING_PROP);
+ if (ranking == null) {
+ props.put(Constants.SERVICE_RANKING, DEFAULT_RANKING);
+ } else{
+ props.put(Constants.SERVICE_RANKING, Integer.valueOf(ranking));
+ }
+ this.context = context;
+ TamayaConfigAdminImpl cm = new TamayaConfigAdminImpl(context);
+ registration = context.registerService(ConfigurationAdmin.class, cm, null);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ if (registration != null) {
+ registration.unregister();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/41132393/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/TamayaConfigAdminImpl.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/TamayaConfigAdminImpl.java b/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/TamayaConfigAdminImpl.java
new file mode 100644
index 0000000..389c267
--- /dev/null
+++ b/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/TamayaConfigAdminImpl.java
@@ -0,0 +1,156 @@
+/*
+ * 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.integration.osgi.base;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.cm.ManagedServiceFactory;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Tamaya based implementation of an OSGI {@link ConfigurationAdmin}.
+ */
+public class TamayaConfigAdminImpl implements ConfigurationAdmin {
+ private final BundleContext context;
+ private ConfigurationAdmin parent;
+ private Map<String,Configuration> configs = new ConcurrentHashMap<>();
+ private static final Logger LOG = Logger.getLogger(TamayaConfigAdminImpl.class.getName());
+
+ public TamayaConfigAdminImpl(BundleContext context) throws IOException {
+ this.context = context;
+ ServiceReference<ConfigurationAdmin> ref = context.getServiceReference(ConfigurationAdmin.class);
+ this.parent = context.getService(ref);
+ ServiceTracker<ManagedService, ManagedService> serviceTracker = new ServiceTracker<ManagedService,
+ ManagedService>(context, ManagedService.class, null) {
+ @Override
+ public ManagedService addingService(ServiceReference<ManagedService> reference) {
+ ManagedService service = context.getService(reference);
+ Object pidObj = reference.getProperty(Constants.SERVICE_PID);
+ if (pidObj instanceof String) {
+ String pid = (String) pidObj;
+ try {
+ Configuration config = getConfiguration(pid);
+ if(config==null){
+ service.updated(null);
+ } else{
+ service.updated(config.getProperties());
+ }
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Error configuring ManagedService: " + service, e);
+ }
+ } else {
+ LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj);
+ }
+ return service;
+ }
+
+ @Override
+ public void removedService(ServiceReference<ManagedService> reference, ManagedService service) {
+ context.ungetService(reference);
+ }
+ };
+ serviceTracker.open();
+
+ ServiceTracker<ServiceFactory, ServiceFactory> factoryTracker
+ = new ServiceTracker<ServiceFactory, ServiceFactory>(context, ServiceFactory.class, null) {
+ @Override
+ public ServiceFactory addingService(ServiceReference<ServiceFactory> reference) {
+ ServiceFactory factory = context.getService(reference);
+ if(factory instanceof ManagedServiceFactory) {
+ Object pidObj = reference.getProperty(Constants.SERVICE_PID);
+ if (pidObj instanceof String) {
+ String pid = (String) pidObj;
+ try {
+ Configuration config = getConfiguration(pid);
+ if (config != null) {
+ ((ManagedServiceFactory) factory).updated(config.getFactoryPid(), config.getProperties());
+ }
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Error configuring ManagedServiceFactory: " + factory, e);
+ }
+ } else {
+ LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj);
+ }
+ }
+ return factory;
+ }
+
+ @Override
+ public void removedService(ServiceReference<ServiceFactory> reference, ServiceFactory service) {
+ super.removedService(reference, service);
+ }
+ };
+ factoryTracker.open();
+
+
+ }
+
+ @Override
+ public Configuration createFactoryConfiguration(String factoryPid) throws IOException {
+ return createFactoryConfiguration(factoryPid, null);
+ }
+
+ @Override
+ public Configuration createFactoryConfiguration(String factoryPid, String location) throws IOException {
+ return new TamayaConfigurationImpl(factoryPid, null, this.parent);
+ }
+
+ @Override
+ public Configuration getConfiguration(String pid, String location) throws IOException {
+ return getConfiguration(pid);
+ }
+
+ @Override
+ public Configuration getConfiguration(String pid) throws IOException {
+ return new TamayaConfigurationImpl(pid, null, this.parent);
+ }
+
+ @Override
+ public Configuration[] listConfigurations(String filter) throws IOException, InvalidSyntaxException {
+ Collection<Configuration> result;
+ if (filter == null) {
+ result = this.configs.values();
+ } else {
+ result = new ArrayList<>();
+ Filter flt = context.createFilter(filter);
+ for (Configuration config : this.configs.values()) {
+ if (flt.match(config.getProperties())) {
+ result.add(config);
+ }
+ }
+ }
+ return result.isEmpty() ? null : result.toArray(new Configuration[configs.size()]);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/41132393/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/TamayaConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/TamayaConfigurationImpl.java b/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/TamayaConfigurationImpl.java
new file mode 100644
index 0000000..8c7a747
--- /dev/null
+++ b/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/base/TamayaConfigurationImpl.java
@@ -0,0 +1,120 @@
+/*
+ * 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.integration.osgi.base;
+
+import java.io.IOException;
+import java.util.*;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.functions.PropertyMatcher;
+import org.apache.tamaya.functions.ConfigurationFunctions;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+/**
+ * Tamaya based implementation of an OSGI {@link Configuration}.
+ */
+public class TamayaConfigurationImpl implements Configuration {
+ private final String pid;
+ private final String factoryPid;
+ private Map<String, String> properties = new HashMap<>();
+ private org.apache.tamaya.Configuration config;
+
+ public TamayaConfigurationImpl(String confPid, String factoryPid, ConfigurationAdmin parent) {
+ this.pid = confPid;
+ this.factoryPid = factoryPid;
+ if(parent!=null){
+ try {
+ Dictionary<String, Object> conf = parent.getConfiguration(confPid, factoryPid).getProperties();
+ Enumeration<String> keys = conf.keys();
+ while(keys.hasMoreElements()){
+ String key = keys.nextElement();
+ this.properties.put(key, conf.get(key).toString());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ this.config = ConfigurationProvider.getConfiguration();
+ this.properties.putAll(
+ config.with(ConfigurationFunctions.filter(new PropertyMatcher() {
+ @Override
+ public boolean test(String key, String value) {
+ // TODO define name space / SPI
+ if (key.startsWith("bundle." + pid)) {
+ return true;
+ }
+ return false;
+ }
+ })).getProperties());
+ }
+
+ @Override
+ public String getPid() {
+ return pid;
+ }
+
+ @Override
+ public Dictionary<String, Object> getProperties() {
+ return new Hashtable<String, Object>(properties);
+ }
+
+ @Override
+ public void update(Dictionary<String, ?> properties) throws IOException {
+ throw new UnsupportedOperationException("Nuatability not yet supported.");
+ // ConfigChangeProvider.createChangeRequest(this.config)
+ }
+
+ @Override
+ public void delete() throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getFactoryPid() {
+ return factoryPid;
+ }
+
+ @Override
+ public void update() throws IOException {
+ this.config = ConfigurationProvider.getConfiguration();
+ this.properties = config.with(ConfigurationFunctions.filter(new PropertyMatcher() {
+ @Override
+ public boolean test(String key, String value) {
+// TODO define name space / SPI
+ return false;
+ }
+ })).getProperties();
+ }
+
+ @Override
+ public void setBundleLocation(String location) {
+ }
+
+ @Override
+ public String getBundleLocation() {
+ return null;
+ }
+
+ @Override
+ public long getChangeCount() {
+ return 0;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/41132393/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/general/TamayaConfigAdminImpl.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/general/TamayaConfigAdminImpl.java b/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/general/TamayaConfigAdminImpl.java
deleted file mode 100644
index 8454e08..0000000
--- a/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/general/TamayaConfigAdminImpl.java
+++ /dev/null
@@ -1,156 +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.integration.osgi.general;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ManagedService;
-import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Tamaya based implementation of an OSGI {@link ConfigurationAdmin}.
- */
-public class TamayaConfigAdminImpl implements ConfigurationAdmin {
- private final BundleContext context;
- private ConfigurationAdmin parent;
- private Map<String,Configuration> configs = new ConcurrentHashMap<>();
- private static final Logger LOG = Logger.getLogger(TamayaConfigAdminImpl.class.getName());
-
- public TamayaConfigAdminImpl(BundleContext context) throws IOException {
- this.context = context;
- ServiceReference<ConfigurationAdmin> ref = context.getServiceReference(ConfigurationAdmin.class);
- this.parent = context.getService(ref);
- ServiceTracker<ManagedService, ManagedService> serviceTracker = new ServiceTracker<ManagedService,
- ManagedService>(context, ManagedService.class, null) {
- @Override
- public ManagedService addingService(ServiceReference<ManagedService> reference) {
- ManagedService service = context.getService(reference);
- Object pidObj = reference.getProperty(Constants.SERVICE_PID);
- if (pidObj instanceof String) {
- String pid = (String) pidObj;
- try {
- Configuration config = getConfiguration(pid);
- if(config==null){
- service.updated(null);
- } else{
- service.updated(config.getProperties());
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Error configuring ManagedService: " + service, e);
- }
- } else {
- LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj);
- }
- return service;
- }
-
- @Override
- public void removedService(ServiceReference<ManagedService> reference, ManagedService service) {
- context.ungetService(reference);
- }
- };
- serviceTracker.open();
-
- ServiceTracker<ServiceFactory, ServiceFactory> factoryTracker
- = new ServiceTracker<ServiceFactory, ServiceFactory>(context, ServiceFactory.class, null) {
- @Override
- public ServiceFactory addingService(ServiceReference<ServiceFactory> reference) {
- ServiceFactory factory = context.getService(reference);
- if(factory instanceof ManagedServiceFactory) {
- Object pidObj = reference.getProperty(Constants.SERVICE_PID);
- if (pidObj instanceof String) {
- String pid = (String) pidObj;
- try {
- Configuration config = getConfiguration(pid);
- if (config != null) {
- ((ManagedServiceFactory) factory).updated(config.getFactoryPid(), config.getProperties());
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Error configuring ManagedServiceFactory: " + factory, e);
- }
- } else {
- LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj);
- }
- }
- return factory;
- }
-
- @Override
- public void removedService(ServiceReference<ServiceFactory> reference, ServiceFactory service) {
- super.removedService(reference, service);
- }
- };
- factoryTracker.open();
-
-
- }
-
- @Override
- public Configuration createFactoryConfiguration(String factoryPid) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Configuration createFactoryConfiguration(String factoryPid, String location) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Configuration getConfiguration(String pid, String location) throws IOException {
- return getConfiguration(pid);
- }
-
- @Override
- public Configuration getConfiguration(String pid) throws IOException {
- return new TamayaConfigurationImpl(pid, null, this.parent);
- }
-
- @Override
- public Configuration[] listConfigurations(String filter) throws IOException, InvalidSyntaxException {
- Collection<Configuration> result;
- if (filter == null) {
- result = this.configs.values();
- } else {
- result = new ArrayList<>();
- Filter flt = context.createFilter(filter);
- for (Configuration config : this.configs.values()) {
- if (flt.match(config.getProperties())) {
- result.add(config);
- }
- }
- }
- return result.isEmpty() ? null : result.toArray(new Configuration[configs.size()]);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/41132393/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/general/TamayaConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/general/TamayaConfigurationImpl.java b/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/general/TamayaConfigurationImpl.java
deleted file mode 100644
index 1a47611..0000000
--- a/modules/integration/osgi/general/src/main/java/org/apache/tamaya/integration/osgi/general/TamayaConfigurationImpl.java
+++ /dev/null
@@ -1,120 +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.integration.osgi.general;
-
-import java.io.IOException;
-import java.util.*;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.functions.PropertyMatcher;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-/**
- * Tamaya based implementation of an OSGI {@link Configuration}.
- */
-public class TamayaConfigurationImpl implements Configuration {
- private final String pid;
- private final String factoryPid;
- private Map<String, String> properties = new HashMap<>();
- private org.apache.tamaya.Configuration config;
-
- public TamayaConfigurationImpl(String confPid, String factoryPid, ConfigurationAdmin parent) {
- this.pid = confPid;
- this.factoryPid = factoryPid;
- if(parent!=null){
- try {
- Dictionary<String, Object> conf = parent.getConfiguration(confPid, factoryPid).getProperties();
- Enumeration<String> keys = conf.keys();
- while(keys.hasMoreElements()){
- String key = keys.nextElement();
- this.properties.put(key, conf.get(key).toString());
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- this.config = ConfigurationProvider.getConfiguration();
- this.properties.putAll(
- config.with(ConfigurationFunctions.filter(new PropertyMatcher() {
- @Override
- public boolean test(String key, String value) {
- // TODO define name space / SPI
- if (key.startsWith("bundle." + pid)) {
- return true;
- }
- return false;
- }
- })).getProperties());
- }
-
- @Override
- public String getPid() {
- return pid;
- }
-
- @Override
- public Dictionary<String, Object> getProperties() {
- return new Hashtable<String, Object>(properties);
- }
-
- @Override
- public void update(Dictionary<String, ?> properties) throws IOException {
- throw new UnsupportedOperationException("Nuatability not yet supported.");
- // ConfigChangeProvider.createChangeRequest(this.config)
- }
-
- @Override
- public void delete() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getFactoryPid() {
- return factoryPid;
- }
-
- @Override
- public void update() throws IOException {
- this.config = ConfigurationProvider.getConfiguration();
- this.properties = config.with(ConfigurationFunctions.filter(new PropertyMatcher() {
- @Override
- public boolean test(String key, String value) {
-// TODO define name space / SPI
- return false;
- }
- })).getProperties();
- }
-
- @Override
- public void setBundleLocation(String location) {
- }
-
- @Override
- public String getBundleLocation() {
- return null;
- }
-
- @Override
- public long getChangeCount() {
- return 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/41132393/modules/integration/osgi/general/src/test/java/org/apache/tamaya/integration/osgi/base/TestConfigIntegration.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/general/src/test/java/org/apache/tamaya/integration/osgi/base/TestConfigIntegration.java b/modules/integration/osgi/general/src/test/java/org/apache/tamaya/integration/osgi/base/TestConfigIntegration.java
new file mode 100644
index 0000000..1e78bfa
--- /dev/null
+++ b/modules/integration/osgi/general/src/test/java/org/apache/tamaya/integration/osgi/base/TestConfigIntegration.java
@@ -0,0 +1,134 @@
+/*
+ * 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.integration.osgi.base;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.spi.ServiceContext;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OperateOnDeployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.osgi.metadata.OSGiManifestBuilder;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.importer.ZipImporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+import java.io.File;
+import java.io.InputStream;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class TestConfigIntegration{
+
+ private static final String TAMAYA_VERSION = "0.2-incubating-SNAPSHOT";
+
+ @ArquillianResource BundleContext context;
+
+ //////////////////////////////////////////////////////// Test setup //////////////////////////////////
+
+ @Deployment(order=11)
+ public static JavaArchive createdeployment() {
+ final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "tamaya-osgi-base.jar");
+ archive.setManifest(new Asset() {
+ public InputStream openStream() {
+ OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
+ builder.addBundleSymbolicName(archive.getName());
+ builder.addBundleManifestVersion(2);
+ builder.addImportPackages("org.junit", "org.apache.tamaya", "org.apache.tamaya.spi", "org.apache.tamaya.core");
+ builder.addImportPackages(ServiceContext.class, ConfigurationProvider.class);
+// builder.addBundleActivator(Activator.class);
+ return builder.openStream();
+ }
+ });
+ archive.addClasses(TestConfigIntegration.class);
+// archive.addAsResource("META-INF/javaconfiguration.properties");
+ return archive;
+ }
+
+ @Deployment(name="felix.main",order=10)
+ public static JavaArchive deployMain() {
+ return ShrinkWrap.create(ZipImporter.class, "felix.main-5.4.0.jar")
+ .importFrom(new File("src/container/org.apache.felix.main-5.4.0.jar"))
+ .as(JavaArchive.class);
+ }
+
+ @Deployment(name="tamaya-api",order=1)
+ public static JavaArchive deployTamayaAPI() {
+ return ShrinkWrap.create(ZipImporter.class, "tamaya-api.jar")
+ .importFrom(getBundleFile("tamaya-api:"+TAMAYA_VERSION))
+ .as(JavaArchive.class);
+ }
+
+ @Deployment(name="tamaya-core",order=2)
+ public static JavaArchive deployTamayaCore() {
+ return ShrinkWrap.create(ZipImporter.class, "tamaya-core.jar")
+ .importFrom(getBundleFile("tamaya-core:"+TAMAYA_VERSION))
+ .as(JavaArchive.class);
+ }
+
+ @Deployment(name="javax.annotation",order=0)
+ public static JavaArchive deployJavaxAnnotation() {
+ return ShrinkWrap.create(ZipImporter.class, "javax.annotation.jar")
+ .importFrom(Maven.configureResolver()
+ .withMavenCentralRepo(false)
+ .withClassPathResolution(true)
+ .resolve("org.apache.geronimo.specs:geronimo-annotation_1.2_spec:1.0-alpha-1")
+ .withoutTransitivity().asSingleFile())
+ .as(JavaArchive.class);
+ }
+
+ private static File getBundleFile(String artifactId) {
+ // Check
+ return Maven.configureResolver()
+ .withMavenCentralRepo(false)
+ .withClassPathResolution(true)
+ .resolve("org.apache.tamaya:" + artifactId).withoutTransitivity().asSingleFile();
+ }
+
+
+ //////////////////////////////////////////////////////// Tests //////////////////////////////////
+
+
+// @Before
+// public void startBundles(){
+// for(Bundle bundle:context.getBundles()) {
+// try {
+// bundle.start();
+// } catch (BundleException e) {
+// e.printStackTrace();
+// }
+// }
+// }
+
+ @OperateOnDeployment("_DEFAULT_")
+ @Test
+ public void testTamayaAvailable() throws Exception {
+ assertNotNull(ConfigurationProvider.getConfiguration());
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/41132393/modules/integration/osgi/general/src/test/resource/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/general/src/test/resource/META-INF/javaconfiguration.properties b/modules/integration/osgi/general/src/test/resource/META-INF/javaconfiguration.properties
new file mode 100644
index 0000000..b2b0d69
--- /dev/null
+++ b/modules/integration/osgi/general/src/test/resource/META-INF/javaconfiguration.properties
@@ -0,0 +1,18 @@
+# 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-test__.tamaya-test-property=success!
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/41132393/modules/integration/osgi/general/src/test/resource/arquilian.xml
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/general/src/test/resource/arquilian.xml b/modules/integration/osgi/general/src/test/resource/arquilian.xml
new file mode 100644
index 0000000..d036dca
--- /dev/null
+++ b/modules/integration/osgi/general/src/test/resource/arquilian.xml
@@ -0,0 +1,27 @@
+<!--
+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 current 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.
+-->
+<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">/felix.properties</property>
+ </configuration>
+ </container>
+</arquillian>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/41132393/modules/integration/osgi/general/src/test/resource/felix.properties
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/general/src/test/resource/felix.properties b/modules/integration/osgi/general/src/test/resource/felix.properties
new file mode 100644
index 0000000..f81f6bc
--- /dev/null
+++ b/modules/integration/osgi/general/src/test/resource/felix.properties
@@ -0,0 +1,18 @@
+# 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.
+#
+org.osgi.framework.bootdelegation=org.osgi.service.cm;org.apache.felix.cm;org.apache.tamaya;org.apache.tamaya.spi;*
\ No newline at end of file