diff --git a/jmx/jmx-itests/pom.xml b/jmx/jmx-itests/pom.xml
index 0b9b15d972..c7ea352fdc 100644
--- a/jmx/jmx-itests/pom.xml
+++ b/jmx/jmx-itests/pom.xml
@@ -40,6 +40,7 @@
5.0.3
2.1.1
1.5.0
+ 1
1.0.0
1.0.0
1.0.0
@@ -103,12 +104,20 @@
org.osgi.compendium
provided
+
+
+
+ javax.inject
+ javax.inject
+ ${javax.inject.version}
+
org.apache.aries.blueprint
org.apache.aries.blueprint.sample
diff --git a/jmx/jmx-itests/src/test/java/org/apache/aries/itest/AbstractIntegrationTest.java b/jmx/jmx-itests/src/test/java/org/apache/aries/itest/AbstractIntegrationTest.java
new file mode 100644
index 0000000000..22714dee8a
--- /dev/null
+++ b/jmx/jmx-itests/src/test/java/org/apache/aries/itest/AbstractIntegrationTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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 WARRANTIESOR 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.aries.itest;
+
+import javax.inject.Inject;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+/**
+ * TODO ARIES-2165 Remove when testsupport is added in pom
+ *
+ * Base class for Pax Exam 1.2.x based unit tests
+ *
+ * Contains the injection point and various utilities used in most tests
+ */
+public abstract class AbstractIntegrationTest {
+
+ /** Gateway to the test OSGi framework */
+ @Inject
+ protected BundleContext bundleContext;
+
+ /**
+ * Get a richer version of {@link BundleContext}
+ */
+ public RichBundleContext context() {
+ return new RichBundleContext(bundleContext);
+ }
+
+ public String getLocalRepo() {
+ String localRepo = System.getProperty("maven.repo.local");
+ if (localRepo == null) {
+ localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+ }
+ return localRepo;
+ }
+
+
+ /**
+ * Help to diagnose bundles that did not start
+ *
+ * @throws BundleException
+ */
+ public void showBundles() throws BundleException {
+ Bundle[] bundles = bundleContext.getBundles();
+ for (Bundle bundle : bundles) {
+ System.out.println(bundle.getBundleId() + ":" + bundle.getSymbolicName() + ":" + bundle.getVersion() + ":" + bundle.getState());
+ }
+ }
+
+ /**
+ * Helps to diagnose bundles that are not resolved as it will throw a detailed exception
+ *
+ * @throws BundleException
+ */
+ public void resolveBundles() throws BundleException {
+ Bundle[] bundles = bundleContext.getBundles();
+ for (Bundle bundle : bundles) {
+ if (bundle.getState() == Bundle.INSTALLED) {
+ System.out.println("Found non resolved bundle " + bundle.getBundleId() + ":" + bundle.getSymbolicName() + ":" + bundle.getVersion());
+ bundle.start();
+ }
+ }
+ }
+}
diff --git a/jmx/jmx-itests/src/test/java/org/apache/aries/itest/RichBundleContext.java b/jmx/jmx-itests/src/test/java/org/apache/aries/itest/RichBundleContext.java
new file mode 100644
index 0000000000..f85dc97433
--- /dev/null
+++ b/jmx/jmx-itests/src/test/java/org/apache/aries/itest/RichBundleContext.java
@@ -0,0 +1,219 @@
+/*
+ * 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 WARRANTIESOR 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.aries.itest;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Dictionary;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * TODO ARIES-2165 Remove when testsupport is added in pom
+ *
+ * {@link BundleContext} wrapper that adds a couple of additional utilities
+ *
+ */
+public class RichBundleContext implements BundleContext {
+ public static final long DEFAULT_TIMEOUT = 15000;
+
+ private final BundleContext delegate;
+
+ public RichBundleContext(BundleContext delegate) {
+ this.delegate = delegate;
+ }
+
+
+ public T getService(Class type) {
+ return getService(type, null, DEFAULT_TIMEOUT);
+ }
+
+ public T getService(Class type, long timeout) {
+ return getService(type, null, timeout);
+ }
+
+ public T getService(Class type, String filter) {
+ return getService(type, filter, DEFAULT_TIMEOUT);
+ }
+
+ public T getService(Class type, String filter, long timeout) {
+ ServiceTracker tracker = null;
+ try {
+ String flt;
+ if (filter != null) {
+ if (filter.startsWith("(")) {
+ flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")" + filter + ")";
+ } else {
+ flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")(" + filter + "))";
+ }
+ } else {
+ flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
+ }
+ Filter osgiFilter = FrameworkUtil.createFilter(flt);
+ tracker = new ServiceTracker(delegate, osgiFilter, null);
+ tracker.open();
+
+ Object svc = type.cast(tracker.waitForService(timeout));
+ if (svc == null) {
+ System.out.println("Could not obtain a service in time, service-ref="+
+ tracker.getServiceReference()+
+ ", time="+System.currentTimeMillis());
+ throw new RuntimeException("Gave up waiting for service " + flt);
+ }
+ return type.cast(svc);
+ } catch (InvalidSyntaxException e) {
+ throw new IllegalArgumentException("Invalid filter", e);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public Bundle getBundleByName(String symbolicName) {
+ for (Bundle b : delegate.getBundles()) {
+ if (b.getSymbolicName().equals(symbolicName)) {
+ return b;
+ }
+ }
+ return null;
+ }
+
+ public String getProperty(String key) {
+ return delegate.getProperty(key);
+ }
+
+ public Bundle getBundle() {
+ return delegate.getBundle();
+ }
+
+ public Bundle getBundle(String filter) { return delegate.getBundle(filter); }
+
+ public Bundle installBundle(String location, InputStream input)
+ throws BundleException {
+ return delegate.installBundle(location, input);
+ }
+
+ public Bundle installBundle(String location) throws BundleException {
+ return delegate.installBundle(location);
+ }
+
+ public Bundle getBundle(long id) {
+ return delegate.getBundle(id);
+ }
+
+ public Bundle[] getBundles() {
+ return delegate.getBundles();
+ }
+
+ public void addServiceListener(ServiceListener listener, String filter)
+ throws InvalidSyntaxException {
+ delegate.addServiceListener(listener, filter);
+ }
+
+ public void addServiceListener(ServiceListener listener) {
+ delegate.addServiceListener(listener);
+ }
+
+ public void removeServiceListener(ServiceListener listener) {
+ delegate.removeServiceListener(listener);
+ }
+
+ public void addBundleListener(BundleListener listener) {
+ delegate.addBundleListener(listener);
+ }
+
+ public void removeBundleListener(BundleListener listener) {
+ delegate.removeBundleListener(listener);
+ }
+
+ public void addFrameworkListener(FrameworkListener listener) {
+ delegate.addFrameworkListener(listener);
+ }
+
+ public void removeFrameworkListener(FrameworkListener listener) {
+ delegate.removeFrameworkListener(listener);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public ServiceRegistration registerService(String[] clazzes,
+ Object service, Dictionary properties) {
+ return delegate.registerService(clazzes, service, properties);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public ServiceRegistration registerService(String clazz, Object service,
+ Dictionary properties) {
+ return delegate.registerService(clazz, service, properties);
+ }
+
+ public ServiceRegistration registerService(Class clazz, Object service, Dictionary props) {
+ return delegate.registerService(clazz, service, props);
+ }
+
+ public ServiceReference[] getServiceReferences(String clazz, String filter)
+ throws InvalidSyntaxException {
+ return delegate.getServiceReferences(clazz, filter);
+ }
+
+ public Collection getServiceReferences(Class clazz, String filter) throws InvalidSyntaxException {
+ return delegate.getServiceReferences(clazz, filter);
+ }
+
+ public ServiceReference[] getAllServiceReferences(String clazz,
+ String filter) throws InvalidSyntaxException {
+ return delegate.getAllServiceReferences(clazz, filter);
+ }
+
+ public ServiceReference getServiceReference(String clazz) {
+ return delegate.getServiceReference(clazz);
+ }
+
+ public ServiceReference getServiceReference(Class clazz) { return delegate.getServiceReference(clazz); }
+
+ public Object getService(ServiceReference reference) {
+ return delegate.getService(reference);
+ }
+
+ public boolean ungetService(ServiceReference reference) {
+ return delegate.ungetService(reference);
+ }
+
+ public File getDataFile(String filename) {
+ return delegate.getDataFile(filename);
+ }
+
+ public Filter createFilter(String filter) throws InvalidSyntaxException {
+ return delegate.createFilter(filter);
+ }
+
+
+}
diff --git a/jmx/jmx-itests/src/test/java/org/apache/aries/itest/packageinfo b/jmx/jmx-itests/src/test/java/org/apache/aries/itest/packageinfo
new file mode 100644
index 0000000000..733fd2bdc2
--- /dev/null
+++ b/jmx/jmx-itests/src/test/java/org/apache/aries/itest/packageinfo
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 2.0.0
diff --git a/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java b/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java
index 250d5ddafa..0bf23b953a 100644
--- a/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java
+++ b/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/AbstractIntegrationTest.java
@@ -84,7 +84,8 @@ protected Option jmxRuntime() {
mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.core.whiteboard").versionAsInProject(),
mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.api").versionAsInProject(),
mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.whiteboard").versionAsInProject(),
- mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
+ // TODO ARIES-2165 Bring back testsupport in maven
+ // mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
mavenBundle("org.apache.aries.jmx", "org.apache.aries.jmx.mbeanserver-platform").versionAsInProject()
);
}
@@ -201,4 +202,4 @@ protected Bundle getBundleByName(String symName) {
assertNotNull("Bundle " + symName + "should be installed", b);
return b;
}
-}
\ No newline at end of file
+}