[jboss-cvs] JBossAS SVN: r95391 - in projects/jboss-osgi: projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp and 19 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 22 07:39:24 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-22 07:39:22 -0400 (Thu, 22 Oct 2009)
New Revision: 95391
Added:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ExportedPackageHelper.java
projects/jboss-osgi/trunk/reactor/testing/
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
Removed:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/logging/
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/FrameworkException.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/NotImplementedException.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/OSGiConstants.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/capability/
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/framework/
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/internal/
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/logging/
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/management/
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/package.html
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/service/
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/util/
Modified:
projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java
projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/WebAppCapability.java
projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml
projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml
projects/jboss-osgi/projects/spi/trunk/pom.xml
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/CompendiumCapability.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/ConfigAdminCapability.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/HttpServiceCapability.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/LogServiceCapability.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegrationBean.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
projects/jboss-osgi/trunk/reactor/deployment/pom.xml
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
projects/jboss-osgi/trunk/reactor/framework/pom.xml
projects/jboss-osgi/trunk/reactor/pom.xml
projects/jboss-osgi/trunk/reactor/testing/pom.xml
projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedBundle.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java
Log:
Separate testing from spi
Modified: projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/bundles/microcontainer/trunk/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerCapability.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -26,7 +26,6 @@
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.capability.CompendiumCapability;
import org.jboss.osgi.spi.service.MicrocontainerService;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
/**
* Adds the Microcontainer capability to the {@link OSGiRuntime}
Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/WebAppCapability.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/WebAppCapability.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/WebAppCapability.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -25,7 +25,6 @@
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.capability.HttpServiceCapability;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
/**
* Adds the WebApp (WAR) capability to the {@link OSGiRuntime}
Modified: projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/runtime/equinox/trunk/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
@@ -41,6 +41,7 @@
<version.eclipse.equinox>3.5</version.eclipse.equinox>
<version.jboss.osgi.deployment>0.0.1-SNAPSHOT</version.jboss.osgi.deployment>
<version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
+ <version.jboss.osgi.testing>0.0.1-SNAPSHOT</version.jboss.osgi.testing>
</properties>
<!-- Dependencies -->
@@ -66,7 +67,14 @@
<artifactId>org.eclipse.osgi.services</artifactId>
<version>${version.eclipse.equinox}</version>
</dependency>
+
<dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-testing</artifactId>
+ <version>${version.jboss.osgi.testing}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
Modified: projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
@@ -40,6 +40,7 @@
<version.felix.framework>2.0.1</version.felix.framework>
<version.jboss.osgi.deployment>0.0.1-SNAPSHOT</version.jboss.osgi.deployment>
<version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
+ <version.jboss.osgi.testing>0.0.1-SNAPSHOT</version.jboss.osgi.testing>
</properties>
<!-- Dependencies -->
@@ -60,7 +61,14 @@
<artifactId>org.apache.felix.framework</artifactId>
<version>${version.felix.framework}</version>
</dependency>
+
<dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-testing</artifactId>
+ <version>${version.jboss.osgi.testing}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
Modified: projects/jboss-osgi/projects/spi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/pom.xml 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/spi/trunk/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
@@ -61,11 +61,6 @@
<artifactId>jboss-vfs</artifactId>
<version>${version.jboss.vfs}</version>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${version.junit}</version>
- </dependency>
<!-- Provided Dependencies -->
<dependency>
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/Capability.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -29,8 +29,6 @@
import java.util.List;
import java.util.Map;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-
/**
* An abstract OSGi capability that can be installed in an {@link OSGiRuntime}.
*
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/CompendiumCapability.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/CompendiumCapability.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/CompendiumCapability.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -23,11 +23,9 @@
//$Id$
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiTestHelper;
/**
- * Adds the OSGi compedium capability to the {@link OSGiRuntime}
+ * Adds the OSGi compedium capability to the OSGiRuntime
* under test.
*
* Installed bundle: org.osgi.compendium.jar
@@ -41,7 +39,7 @@
{
super(null);
- if (new OSGiTestHelper().isFrameworkEquinox())
+ if ("equinox".equals(System.getProperty("framework")))
addBundle("bundles/org.eclipse.osgi.services.jar");
else
addBundle("bundles/org.osgi.compendium.jar");
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/ConfigAdminCapability.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/ConfigAdminCapability.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/ConfigAdminCapability.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -23,7 +23,6 @@
//$Id$
-import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.osgi.service.cm.ConfigurationAdmin;
/**
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/HttpServiceCapability.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/HttpServiceCapability.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/HttpServiceCapability.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -23,7 +23,6 @@
//$Id$
-import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.osgi.service.http.HttpService;
/**
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/LogServiceCapability.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/LogServiceCapability.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/capability/LogServiceCapability.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -21,7 +21,6 @@
*/
package org.jboss.osgi.spi.capability;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.osgi.service.log.LogService;
/**
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegrationBean.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegrationBean.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegrationBean.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -30,7 +30,7 @@
import java.util.Map;
import org.jboss.osgi.spi.FrameworkException;
-import org.jboss.osgi.spi.logging.ExportedPackageHelper;
+import org.jboss.osgi.spi.util.ExportedPackageHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -40,7 +40,7 @@
import org.jboss.osgi.spi.FrameworkException;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.internal.StringPropertyReplacer;
-import org.jboss.osgi.spi.logging.ExportedPackageHelper;
+import org.jboss.osgi.spi.util.ExportedPackageHelper;
import org.jboss.osgi.spi.util.ServiceLoader;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ExportedPackageHelper.java (from rev 95382, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/logging/ExportedPackageHelper.java)
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ExportedPackageHelper.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ExportedPackageHelper.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.spi.util;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A helper the logs the exported packages for a bundle.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public final class ExportedPackageHelper
+{
+ // Provide logging
+ final Logger log = LoggerFactory.getLogger(ExportedPackageHelper.class);
+
+ private PackageAdmin packageAdmin;
+
+ public ExportedPackageHelper(BundleContext context)
+ {
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ if (sref != null)
+ packageAdmin = (PackageAdmin)context.getService(sref);
+ }
+
+ public boolean resolveBundle(Bundle bundle)
+ {
+ return packageAdmin != null ? packageAdmin.resolveBundles(new Bundle[] { bundle }) : false;
+ }
+
+ public boolean resolveBundles(Bundle[] bundles)
+ {
+ return packageAdmin != null ? packageAdmin.resolveBundles(bundles) : false;
+ }
+
+ /*
+ * * Log the list of exported packages
+ */
+ public void logExportedPackages(Bundle bundle)
+ {
+ if (packageAdmin != null)
+ {
+ log.debug("Exported-Packages: " + bundle.getSymbolicName());
+
+ ExportedPackage[] exportedPackages = packageAdmin.getExportedPackages(bundle);
+ if (exportedPackages != null)
+ {
+ List<String> packages = new ArrayList<String>();
+ for (ExportedPackage exp : exportedPackages)
+ packages.add(" " + exp.getName() + ";version=" + exp.getVersion());
+
+ Collections.sort(packages);
+ for (String exp : packages)
+ log.debug(exp);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/trunk/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
@@ -67,6 +67,7 @@
<version.jboss.osgi.runtime.felix>2.0.1-SNAPSHOT</version.jboss.osgi.runtime.felix>
<version.jboss.osgi.runtime.jbossas>1.0.2-SNAPSHOT</version.jboss.osgi.runtime.jbossas>
<version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
+ <version.jboss.osgi.testing>0.0.1-SNAPSHOT</version.jboss.osgi.testing>
<version.jboss.osgi.webapp>0.7.1-SNAPSHOT</version.jboss.osgi.webapp>
<version.jboss.osgi.webconsole>1.0.2</version.jboss.osgi.webconsole>
<version.jboss.osgi.xml.binding>2.0.1.SP1</version.jboss.osgi.xml.binding>
@@ -95,6 +96,11 @@
<artifactId>jboss-osgi-spi</artifactId>
<version>${version.jboss.osgi.spi}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-testing</artifactId>
+ <version>${version.jboss.osgi.testing}</version>
+ </dependency>
<!-- jboss.osgi.bundles -->
<dependency>
Modified: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/BlueprintCapability.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -26,7 +26,6 @@
import org.jboss.osgi.jbossxb.XMLBindingCapability;
import org.jboss.osgi.microcontainer.MicrocontainerCapability;
import org.jboss.osgi.spi.capability.Capability;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
/**
* Adds the Blueprint capability to the {@link OSGiRuntime}
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
@@ -43,12 +43,16 @@
<artifactId>bnd</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-testing</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-blueprint</artifactId>
- <version>${version}</version>
<scope>provided</scope>
</dependency>
-
+
<!-- Bundle Dependencies -->
<dependency>
<groupId>org.apache.felix</groupId>
Modified: projects/jboss-osgi/trunk/reactor/deployment/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/pom.xml 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/trunk/reactor/deployment/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
@@ -59,6 +59,11 @@
<!-- Test Dependecies -->
<dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/SystemDeployerService.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -38,8 +38,8 @@
import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.deployment.deployer.AbstractDeployerService;
import org.jboss.osgi.deployment.deployer.DeploymentRegistryService;
-import org.jboss.osgi.spi.logging.ExportedPackageHelper;
import org.jboss.osgi.spi.management.ManagedBundleService;
+import org.jboss.osgi.spi.util.ExportedPackageHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
@@ -135,6 +135,10 @@
<artifactId>jboss-osgi-spi</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-testing</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.runtime</groupId>
<artifactId>jboss-osgi-deployers</artifactId>
</dependency>
Modified: projects/jboss-osgi/trunk/reactor/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/pom.xml 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/trunk/reactor/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
@@ -44,6 +44,7 @@
<modules>
<module>deployment</module>
+ <module>testing</module>
<module>framework</module>
<module>blueprint</module>
</modules>
Copied: projects/jboss-osgi/trunk/reactor/testing (from rev 95382, projects/jboss-osgi/projects/spi/trunk)
Modified: projects/jboss-osgi/trunk/reactor/testing/pom.xml
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/pom.xml 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/pom.xml 2009-10-22 11:39:22 UTC (rev 95391)
@@ -14,70 +14,45 @@
<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>
- <name>JBossOSGi SPI</name>
+ <name>JBossOSGi Testing</name>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-spi</artifactId>
+ <artifactId>jboss-osgi-testing</artifactId>
<packaging>jar</packaging>
- <version>1.0.3-SNAPSHOT</version>
+ <version>0.0.1-SNAPSHOT</version>
<!-- Parent -->
<parent>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-parent</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <artifactId>jboss-osgi</artifactId>
+ <version>1.0.0.Beta5</version>
</parent>
- <!-- Subversion -->
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/spi/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/spi/trunk</developerConnection>
- <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
- </scm>
-
<!-- Properties -->
<properties>
- <version.args4j>2.0.12</version.args4j>
- <version.jboss.vfs>2.1.3.SP1</version.jboss.vfs>
- <version.osgi>4.2.0</version.osgi>
</properties>
<!-- Dependencies -->
<dependencies>
-
- <!-- Compile Dependencies -->
<dependency>
- <groupId>args4j</groupId>
- <artifactId>args4j</artifactId>
- <version>${version.args4j}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-spi</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-vfs</artifactId>
- <version>${version.jboss.vfs}</version>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>${version.junit}</version>
</dependency>
<!-- Provided Dependencies -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <version>${version.osgi}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
- <version>${version.osgi}</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -111,26 +86,4 @@
</plugins>
</build>
- <!-- Repositories -->
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshots Repository</name>
- <url>http://snapshots.jboss.org/maven2/</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
</project>
Deleted: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/FrameworkException.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/FrameworkException.java 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/FrameworkException.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi;
-
-// $Id$
-
-/**
- * An OSGi Framework Exception that should be thrown on unrecoverable errors.
- *
- * @author thomas.diesler at jboss.com
- * @since 18-Jan-2009
- */
- at SuppressWarnings("serial")
-public class FrameworkException extends RuntimeException
-{
- public FrameworkException(String message)
- {
- super(message);
- }
-
- public FrameworkException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- public FrameworkException(Throwable cause)
- {
- super(cause);
- }
-}
Deleted: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/NotImplementedException.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/NotImplementedException.java 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/NotImplementedException.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi;
-
-// $Id$
-
-/**
- * A RuntimeException that should be thrown for unimplemented features
- *
- * @author thomas.diesler at jboss.com
- * @since 18-Jun-2008
- */
- at SuppressWarnings("serial")
-public class NotImplementedException extends RuntimeException
-{
- public NotImplementedException()
- {
- }
-
- public NotImplementedException(String message)
- {
- super(message);
- }
-
- public NotImplementedException(String jiraIssue, String message)
- {
- super("[" + jiraIssue + "] " + message);
- }
-}
Deleted: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/OSGiConstants.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/OSGiConstants.java 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/OSGiConstants.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi;
-
-//$Id$
-
-/**
- * JBossOSGi Constants
- *
- * @author thomas.diesler at jboss.com
- * @since 04-Mar-2009
- */
-public interface OSGiConstants
-{
- /** The JBossOSGi domain 'jboss.osgi' */
- String DOMAIN_NAME = "jboss.osgi";
-
- /**
- * If set to 'true' bundles can be deployed in any order. Deployed bundle will get started when their dependencies can be resolved.
- * If set to 'false' bundles must be deployed in the order that is required to start them.
- *
- * The default is 'true'
- */
- String PROPERTY_DEFERRED_START = "org.jboss.osgi.deferred.start";
-
- /**
- * If set to 'true' bundles are started automatically.
- *
- * The default is 'false'
- */
- String PROPERTY_AUTO_START = "org.jboss.osgi.auto.start";
-
- /**
- * Specifies the start level for a bundle.
- *
- * The default is '0'
- */
- String PROPERTY_START_LEVEL = "org.jboss.osgi.start.level";
-
- /**
- * The JBossOSGi runtime system property that denotes the path to the runtime
- */
- String OSGI_HOME = "osgi.home";
-
- /**
- * The JBossOSGi runtime system property that denotes the path to the active runtime profile
- */
- String OSGI_SERVER_HOME = "osgi.server.home";
-
- /**
- * A JBossOSGi deployment unit attachment key that containe the bundle's symbolic name.
- */
- String KEY_BUNDLE_SYMBOLIC_NAME = "org.jboss.osgi.bundle.symbolic.name";
-
-}
Deleted: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/package.html
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/package.html 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/package.html 2009-10-22 11:39:22 UTC (rev 95391)
@@ -1,5 +0,0 @@
-<html>
-<body>
-Common classes and interfaces.
-</body>
-</html>
Deleted: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -1,235 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi.testing;
-
-import java.io.File;
-import java.net.URL;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.virtual.VFS;
-import org.junit.After;
-import org.junit.Before;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An abstract OSGi Test.
- *
- * {@link OSGiTest} is a convenience wrapper for the functionality provided
- * by {@link OSGiTestHelper}.
- *
- * @author Thomas.Diesler at jboss.org
- * @since 25-Sep-2008
- */
-public abstract class OSGiTest
-{
- // Provide logging
- final Logger log = LoggerFactory.getLogger(OSGiTest.class);
-
- private OSGiTestHelper helper;
-
- protected OSGiTest()
- {
- // Prevent unknown protocol: vfsfile
- VFS.init();
- }
-
- /**
- * Get the test helper used by this test
- *
- * Overwrite if you need to supply another helper
- * i.e. one that you have statically setup
- */
- protected OSGiTestHelper getTestHelper()
- {
- if (helper == null)
- helper = new OSGiTestHelper();
-
- return helper;
- }
-
- /**
- * Writes a a debug start messge
- */
- @Before
- public void setUp() throws Exception
- {
- log.debug("### START " + getLongName());
- }
-
- /**
- * Writes a a debug stop messge
- */
- @After
- public void tearDown() throws Exception
- {
- log.debug("### END " + getLongName());
- }
-
- /**
- * Get the last token in the FQN of this test class.
- */
- protected String getShortName()
- {
- String shortName = getClass().getName();
- shortName = shortName.substring(shortName.lastIndexOf(".") + 1);
- return shortName;
- }
-
- /**
- * Get the the FQN of this test class.
- */
- protected String getLongName()
- {
- return getClass().getName();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getDefaultRuntime()}
- */
- protected OSGiRuntime getDefaultRuntime()
- {
- return getTestHelper().getDefaultRuntime();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getEmbeddedRuntime()}
- */
- protected OSGiRuntime getEmbeddedRuntime()
- {
- return getTestHelper().getEmbeddedRuntime();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getRemoteRuntime()}
- */
- public OSGiRuntime getRemoteRuntime()
- {
- return getTestHelper().getRemoteRuntime();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getResourceURL(String)}
- */
- protected URL getResourceURL(String resource)
- {
- return getTestHelper().getResourceURL(resource);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getResourceFile(String)}
- */
- protected File getResourceFile(String resource)
- {
- return getTestHelper().getResourceFile(resource);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getTestArchiveURL(String)}
- */
- protected URL getTestArchiveURL(String archive)
- {
- return getTestHelper().getTestArchiveURL(archive);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getTestArchivePath(String)}
- */
- protected String getTestArchivePath(String archive)
- {
- return getTestHelper().getTestArchivePath(archive);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getTestArchiveFile(String)}
- */
- protected File getTestArchiveFile(String archive)
- {
- return getTestHelper().getTestArchiveFile(archive);
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getInitialContext()}
- */
- public InitialContext getInitialContext() throws NamingException
- {
- return getTestHelper().getInitialContext();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getJndiPort()}
- */
- public Integer getJndiPort()
- {
- return getTestHelper().getJndiPort();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getServerHost()}
- */
- public String getServerHost()
- {
- return getTestHelper().getServerHost();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getTargetContainer()}
- */
- public String getTargetContainer()
- {
- return getTestHelper().getTargetContainer();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#getFramework()}
- */
- public String getFramework()
- {
- return getTestHelper().getFramework();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#isFrameworkEquinox()}
- */
- public boolean isFrameworkEquinox()
- {
- return getTestHelper().isFrameworkEquinox();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#isFrameworkFelix()}
- */
- public boolean isFrameworkFelix()
- {
- return getTestHelper().isFrameworkFelix();
- }
-
- /**
- * Delegates to {@link OSGiTestHelper#isFrameworkJBossMC()}
- */
- public boolean isFrameworkJBossMC()
- {
- return getTestHelper().isFrameworkJBossMC();
- }
-}
Copied: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java (from rev 95389, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.spi.testing;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.virtual.VFS;
+import org.junit.After;
+import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An abstract OSGi Test.
+ *
+ * {@link OSGiTest} is a convenience wrapper for the functionality provided
+ * by {@link OSGiTestHelper}.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public abstract class OSGiTest
+{
+ // Provide logging
+ final Logger log = LoggerFactory.getLogger(OSGiTest.class);
+
+ private OSGiTestHelper helper;
+
+ protected OSGiTest()
+ {
+ // Prevent unknown protocol: vfsfile
+ VFS.init();
+ }
+
+ /**
+ * Get the test helper used by this test
+ *
+ * Overwrite if you need to supply another helper
+ * i.e. one that you have statically setup
+ */
+ protected OSGiTestHelper getTestHelper()
+ {
+ if (helper == null)
+ helper = new OSGiTestHelper();
+
+ return helper;
+ }
+
+ /**
+ * Writes a a debug start messge
+ */
+ @Before
+ public void setUp() throws Exception
+ {
+ log.debug("### START " + getLongName());
+ }
+
+ /**
+ * Writes a a debug stop messge
+ */
+ @After
+ public void tearDown() throws Exception
+ {
+ log.debug("### END " + getLongName());
+ }
+
+ /**
+ * Get the last token in the FQN of this test class.
+ */
+ protected String getShortName()
+ {
+ String shortName = getClass().getName();
+ shortName = shortName.substring(shortName.lastIndexOf(".") + 1);
+ return shortName;
+ }
+
+ /**
+ * Get the the FQN of this test class.
+ */
+ protected String getLongName()
+ {
+ return getClass().getName();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getDefaultRuntime()}
+ */
+ protected OSGiRuntime getDefaultRuntime()
+ {
+ return getTestHelper().getDefaultRuntime();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getEmbeddedRuntime()}
+ */
+ protected OSGiRuntime getEmbeddedRuntime()
+ {
+ return getTestHelper().getEmbeddedRuntime();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getRemoteRuntime()}
+ */
+ public OSGiRuntime getRemoteRuntime()
+ {
+ return getTestHelper().getRemoteRuntime();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getResourceURL(String)}
+ */
+ protected URL getResourceURL(String resource)
+ {
+ return getTestHelper().getResourceURL(resource);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getResourceFile(String)}
+ */
+ protected File getResourceFile(String resource)
+ {
+ return getTestHelper().getResourceFile(resource);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTestArchiveURL(String)}
+ */
+ protected URL getTestArchiveURL(String archive)
+ {
+ return getTestHelper().getTestArchiveURL(archive);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTestArchivePath(String)}
+ */
+ protected String getTestArchivePath(String archive)
+ {
+ return getTestHelper().getTestArchivePath(archive);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTestArchiveFile(String)}
+ */
+ protected File getTestArchiveFile(String archive)
+ {
+ return getTestHelper().getTestArchiveFile(archive);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getInitialContext()}
+ */
+ public InitialContext getInitialContext() throws NamingException
+ {
+ return getTestHelper().getInitialContext();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getJndiPort()}
+ */
+ public Integer getJndiPort()
+ {
+ return getTestHelper().getJndiPort();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getServerHost()}
+ */
+ public String getServerHost()
+ {
+ return getTestHelper().getServerHost();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTargetContainer()}
+ */
+ public String getTargetContainer()
+ {
+ return getTestHelper().getTargetContainer();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getFramework()}
+ */
+ public String getFramework()
+ {
+ return getTestHelper().getFramework();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#isFrameworkEquinox()}
+ */
+ public boolean isFrameworkEquinox()
+ {
+ return getTestHelper().isFrameworkEquinox();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#isFrameworkFelix()}
+ */
+ public boolean isFrameworkFelix()
+ {
+ return getTestHelper().isFrameworkFelix();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#isFrameworkJBossMC()}
+ */
+ public boolean isFrameworkJBossMC()
+ {
+ return getTestHelper().isFrameworkJBossMC();
+ }
+}
Deleted: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -1,215 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi.testing;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Hashtable;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.testing.internal.EmbeddedRuntime;
-import org.jboss.osgi.spi.testing.internal.RemoteRuntime;
-
-/**
- * An OSGi Test Helper
- *
- * @author Thomas.Diesler at jboss.org
- * @since 25-Sep-2008
- */
-public class OSGiTestHelper
-{
- private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
- private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
-
- // The OSGiBootstrapProvider is a lazy property of the helper
- private OSGiBootstrapProvider bootProvider;
- private boolean skipCreateBootstrapProvider;
-
- private static String testResourcesDir;
- private static String testArchiveDir;
-
- public OSGiTestHelper()
- {
- testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-classes");
- testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
- }
-
- public OSGiBootstrapProvider getBootstrapProvider()
- {
- if (bootProvider == null && skipCreateBootstrapProvider == false)
- {
- try
- {
- bootProvider = OSGiBootstrap.getBootstrapProvider();
- }
- catch (RuntimeException rte)
- {
- skipCreateBootstrapProvider = true;
- throw rte;
- }
- }
- return bootProvider;
- }
-
- public OSGiRuntime getDefaultRuntime()
- {
- OSGiRuntime runtime;
-
- String target = System.getProperty("target.container");
- if (target == null)
- {
- runtime = getEmbeddedRuntime();
- }
- else
- {
- runtime = getRemoteRuntime();
- }
- return runtime;
- }
-
- public OSGiRuntime getEmbeddedRuntime()
- {
- return new EmbeddedRuntime(this);
- }
-
- public OSGiRuntime getRemoteRuntime()
- {
- return new RemoteRuntime(this);
- }
-
- /** Try to discover the URL for the test resource */
- public URL getResourceURL(String resource)
- {
- URL resURL = null;
- try
- {
- File resourceFile = getResourceFile(resource);
- resURL = resourceFile.toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- return resURL;
- }
-
- /** Try to discover the File for the test resource */
- public File getResourceFile(String resource)
- {
- File file = new File(resource);
- if (file.exists())
- return file;
-
- file = new File(testResourcesDir + "/" + resource);
- if (file.exists())
- return file;
-
- throw new IllegalArgumentException("Cannot obtain '" + testResourcesDir + "/" + resource + "'");
- }
-
- /** Try to discover the URL for the deployment archive */
- public URL getTestArchiveURL(String archive)
- {
- try
- {
- return getTestArchiveFile(archive).toURL();
- }
- catch (MalformedURLException ex)
- {
- throw new IllegalStateException(ex);
- }
- }
-
- /** Try to discover the absolute path for the deployment archive */
- public String getTestArchivePath(String archive)
- {
- return getTestArchiveFile(archive).getAbsolutePath();
- }
-
- /** Try to discover the File for the deployment archive */
- public File getTestArchiveFile(String archive)
- {
- File file = new File(archive);
- if (file.exists())
- return file;
-
- file = new File(testArchiveDir + "/" + archive);
- if (file.exists())
- return file;
-
- throw new IllegalArgumentException("Cannot obtain '" + testArchiveDir + "/" + archive + "'.");
- }
-
- @SuppressWarnings("unchecked")
- public InitialContext getInitialContext() throws NamingException
- {
- Hashtable env = new Hashtable();
- env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
- env.put("java.naming.provider.url", "jnp://" + getServerHost() + ":" + getJndiPort());
- return new InitialContext(env);
- }
-
- public Integer getJndiPort()
- {
- String port = System.getProperty("jndi.server.port", "1099");
- return new Integer(port);
- }
-
- public String getServerHost()
- {
- String bindAddress = System.getProperty("jboss.bind.address", "localhost");
- return bindAddress;
- }
-
- public String getTargetContainer()
- {
- String targetContainer = System.getProperty("target.container");
- return targetContainer;
- }
-
- public String getFramework()
- {
- String framework = System.getProperty("framework", "jbossmc");
- return framework;
- }
-
- public boolean isFrameworkEquinox()
- {
- return "equinox".equals(getFramework());
- }
-
- public boolean isFrameworkFelix()
- {
- return "felix".equals(getFramework());
- }
-
- public boolean isFrameworkJBossMC()
- {
- return "jbossmc".equals(getFramework());
- }
-}
Copied: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java (from rev 95389, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.spi.testing;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.testing.internal.EmbeddedRuntime;
+import org.jboss.osgi.spi.testing.internal.RemoteRuntime;
+
+/**
+ * An OSGi Test Helper
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class OSGiTestHelper
+{
+ private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+ private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+
+ // The OSGiBootstrapProvider is a lazy property of the helper
+ private OSGiBootstrapProvider bootProvider;
+ private boolean skipCreateBootstrapProvider;
+
+ private static String testResourcesDir;
+ private static String testArchiveDir;
+
+ public OSGiTestHelper()
+ {
+ testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-classes");
+ testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
+ }
+
+ public OSGiBootstrapProvider getBootstrapProvider()
+ {
+ if (bootProvider == null && skipCreateBootstrapProvider == false)
+ {
+ try
+ {
+ bootProvider = OSGiBootstrap.getBootstrapProvider();
+ }
+ catch (RuntimeException rte)
+ {
+ skipCreateBootstrapProvider = true;
+ throw rte;
+ }
+ }
+ return bootProvider;
+ }
+
+ public void ungetBootstrapProvider()
+ {
+ bootProvider = null;
+ }
+
+ public OSGiRuntime getDefaultRuntime()
+ {
+ OSGiRuntime runtime;
+
+ String target = System.getProperty("target.container");
+ if (target == null)
+ {
+ runtime = getEmbeddedRuntime();
+ }
+ else
+ {
+ runtime = getRemoteRuntime();
+ }
+ return runtime;
+ }
+
+ public OSGiRuntime getEmbeddedRuntime()
+ {
+ return new EmbeddedRuntime(this);
+ }
+
+ public OSGiRuntime getRemoteRuntime()
+ {
+ return new RemoteRuntime(this);
+ }
+
+ /** Try to discover the URL for the test resource */
+ public URL getResourceURL(String resource)
+ {
+ URL resURL = null;
+ try
+ {
+ File resourceFile = getResourceFile(resource);
+ resURL = resourceFile.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ return resURL;
+ }
+
+ /** Try to discover the File for the test resource */
+ public File getResourceFile(String resource)
+ {
+ File file = new File(resource);
+ if (file.exists())
+ return file;
+
+ file = new File(testResourcesDir + "/" + resource);
+ if (file.exists())
+ return file;
+
+ throw new IllegalArgumentException("Cannot obtain '" + testResourcesDir + "/" + resource + "'");
+ }
+
+ /** Try to discover the URL for the deployment archive */
+ public URL getTestArchiveURL(String archive)
+ {
+ try
+ {
+ return getTestArchiveFile(archive).toURL();
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ /** Try to discover the absolute path for the deployment archive */
+ public String getTestArchivePath(String archive)
+ {
+ return getTestArchiveFile(archive).getAbsolutePath();
+ }
+
+ /** Try to discover the File for the deployment archive */
+ public File getTestArchiveFile(String archive)
+ {
+ File file = new File(archive);
+ if (file.exists())
+ return file;
+
+ file = new File(testArchiveDir + "/" + archive);
+ if (file.exists())
+ return file;
+
+ throw new IllegalArgumentException("Cannot obtain '" + testArchiveDir + "/" + archive + "'.");
+ }
+
+ @SuppressWarnings("unchecked")
+ public InitialContext getInitialContext() throws NamingException
+ {
+ Hashtable env = new Hashtable();
+ env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+ env.put("java.naming.provider.url", "jnp://" + getServerHost() + ":" + getJndiPort());
+ return new InitialContext(env);
+ }
+
+ public Integer getJndiPort()
+ {
+ String port = System.getProperty("jndi.server.port", "1099");
+ return new Integer(port);
+ }
+
+ public String getServerHost()
+ {
+ String bindAddress = System.getProperty("jboss.bind.address", "localhost");
+ return bindAddress;
+ }
+
+ public String getTargetContainer()
+ {
+ String targetContainer = System.getProperty("target.container");
+ return targetContainer;
+ }
+
+ public String getFramework()
+ {
+ String framework = System.getProperty("framework", "jbossmc");
+ return framework;
+ }
+
+ public boolean isFrameworkEquinox()
+ {
+ return "equinox".equals(getFramework());
+ }
+
+ public boolean isFrameworkFelix()
+ {
+ return "felix".equals(getFramework());
+ }
+
+ public boolean isFrameworkJBossMC()
+ {
+ return "jbossmc".equals(getFramework());
+ }
+}
Modified: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedBundle.java 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedBundle.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -23,8 +23,8 @@
import java.util.Dictionary;
-import org.jboss.osgi.spi.logging.ExportedPackageHelper;
import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.util.ExportedPackageHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
Deleted: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -1,199 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi.testing.internal;
-
-// $Id$
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-
-import org.jboss.osgi.spi.capability.Capability;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.testing.OSGiBundle;
-import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiServiceReference;
-import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.launch.Framework;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * An embedded implementation of the {@link OSGiRuntime}
- *
- * @author Thomas.Diesler at jboss.org
- * @since 25-Sep-2008
- */
-public class EmbeddedRuntime extends OSGiRuntimeImpl
-{
- public EmbeddedRuntime(OSGiTestHelper helper)
- {
- super(helper);
- }
-
- public OSGiBundle installBundle(String location) throws BundleException
- {
- URL url = getTestHelper().getTestArchiveURL(location);
-
- BundleContext context = getBundleContext();
- Bundle auxBundle = context.installBundle(url.toExternalForm());
- OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
-
- return registerBundle(location, bundle);
- }
-
- public OSGiBundle[] getBundles()
- {
- List<OSGiBundle> absBundles = new ArrayList<OSGiBundle>();
- for (Bundle bundle : getBundleContext().getBundles())
- {
- absBundles.add(new EmbeddedBundle(this, bundle));
- }
- OSGiBundle[] bundleArr = new OSGiBundle[absBundles.size()];
- absBundles.toArray(bundleArr);
- return bundleArr;
- }
-
- public OSGiBundle getBundle(long bundleId)
- {
- Bundle bundle = getBundleContext().getBundle(bundleId);
- return bundle != null ? new EmbeddedBundle(this, bundle) : null;
- }
-
- public OSGiServiceReference getServiceReference(String clazz)
- {
- ServiceReference sref = getBundleContext().getServiceReference(clazz);
- return (sref != null ? new EmbeddedServiceReference(sref) : null);
- }
-
- public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
- {
- OSGiServiceReference[] retRefs = null;
-
- ServiceReference[] srefs;
- try
- {
- srefs = getBundleContext().getServiceReferences(clazz, filter);
- }
- catch (InvalidSyntaxException e)
- {
- throw new IllegalArgumentException("Invalid filter syntax: " + filter);
- }
-
- if (srefs != null)
- {
- retRefs = new OSGiServiceReference[srefs.length];
- for(int i=0; i < srefs.length; i++)
- retRefs[i] = new EmbeddedServiceReference(srefs[i]);
- }
- return retRefs;
- }
-
- @Override
- public void addCapability(Capability capability) throws BundleException
- {
- // Copy the properties to the System props
- Map<String, String> props = capability.getSystemProperties();
- for (Entry<String, String> entry : props.entrySet())
- {
- String value = System.getProperty(entry.getKey());
- if (value == null)
- System.setProperty(entry.getKey(), entry.getValue());
- }
-
- super.addCapability(capability);
- }
-
- @Override
- public void shutdown()
- {
- OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
- if (bootProvider != null)
- {
- super.shutdown();
- try
- {
- Framework framework = bootProvider.getFramework();
- framework.stop();
- framework.waitForStop(5000);
- }
- catch (Exception ex)
- {
- log.error("Cannot stop the framework", ex);
- }
- }
- }
-
- public BundleContext getBundleContext()
- {
- OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
- Framework framework = bootProvider.getFramework();
- if (framework.getState() != Bundle.ACTIVE)
- {
- try
- {
- framework.start();
- }
- catch (BundleException ex)
- {
- throw new IllegalStateException("Cannot start framework", ex);
- }
- }
- return framework.getBundleContext();
- }
-
- @SuppressWarnings("unchecked")
- public MBeanServerConnection getMBeanServer()
- {
- ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
- if (serverArr.size() > 1)
- throw new IllegalStateException("Multiple MBeanServer instances not supported");
-
- MBeanServer server = null;
- if (serverArr.size() == 1)
- server = serverArr.get(0);
-
- if (server == null)
- server = MBeanServerFactory.createMBeanServer();
-
- return server;
- }
-
- public OSGiPackageAdmin getPackageAdmin()
- {
- BundleContext context = getBundleContext();
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin packAdmin = (PackageAdmin)context.getService(sref);
- return new EmbeddedPackageAdmin(packAdmin);
- }
-}
Copied: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java (from rev 95389, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.spi.testing.internal;
+
+// $Id$
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanServerFactory;
+
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An embedded implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class EmbeddedRuntime extends OSGiRuntimeImpl
+{
+ public EmbeddedRuntime(OSGiTestHelper helper)
+ {
+ super(helper);
+ }
+
+ public OSGiBundle installBundle(String location) throws BundleException
+ {
+ URL url = getTestHelper().getTestArchiveURL(location);
+
+ BundleContext context = getBundleContext();
+ Bundle auxBundle = context.installBundle(url.toExternalForm());
+ OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
+
+ return registerBundle(location, bundle);
+ }
+
+ public OSGiBundle[] getBundles()
+ {
+ List<OSGiBundle> absBundles = new ArrayList<OSGiBundle>();
+ for (Bundle bundle : getBundleContext().getBundles())
+ {
+ absBundles.add(new EmbeddedBundle(this, bundle));
+ }
+ OSGiBundle[] bundleArr = new OSGiBundle[absBundles.size()];
+ absBundles.toArray(bundleArr);
+ return bundleArr;
+ }
+
+ public OSGiBundle getBundle(long bundleId)
+ {
+ Bundle bundle = getBundleContext().getBundle(bundleId);
+ return bundle != null ? new EmbeddedBundle(this, bundle) : null;
+ }
+
+ public OSGiServiceReference getServiceReference(String clazz)
+ {
+ ServiceReference sref = getBundleContext().getServiceReference(clazz);
+ return (sref != null ? new EmbeddedServiceReference(sref) : null);
+ }
+
+ public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
+ {
+ OSGiServiceReference[] retRefs = null;
+
+ ServiceReference[] srefs;
+ try
+ {
+ srefs = getBundleContext().getServiceReferences(clazz, filter);
+ }
+ catch (InvalidSyntaxException e)
+ {
+ throw new IllegalArgumentException("Invalid filter syntax: " + filter);
+ }
+
+ if (srefs != null)
+ {
+ retRefs = new OSGiServiceReference[srefs.length];
+ for(int i=0; i < srefs.length; i++)
+ retRefs[i] = new EmbeddedServiceReference(srefs[i]);
+ }
+ return retRefs;
+ }
+
+ @Override
+ public void addCapability(Capability capability) throws BundleException
+ {
+ // Copy the properties to the System props
+ Map<String, String> props = capability.getSystemProperties();
+ for (Entry<String, String> entry : props.entrySet())
+ {
+ String value = System.getProperty(entry.getKey());
+ if (value == null)
+ System.setProperty(entry.getKey(), entry.getValue());
+ }
+
+ super.addCapability(capability);
+ }
+
+ @Override
+ public void shutdown()
+ {
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
+ if (bootProvider != null)
+ {
+ super.shutdown();
+ try
+ {
+ Framework framework = bootProvider.getFramework();
+ framework.stop();
+ framework.waitForStop(5000);
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot stop the framework", ex);
+ }
+ getTestHelper().ungetBootstrapProvider();
+ }
+ }
+
+ public BundleContext getBundleContext()
+ {
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
+ Framework framework = bootProvider.getFramework();
+ if (framework.getState() != Bundle.ACTIVE)
+ {
+ try
+ {
+ framework.start();
+ }
+ catch (BundleException ex)
+ {
+ throw new IllegalStateException("Cannot start framework", ex);
+ }
+ }
+ return framework.getBundleContext();
+ }
+
+ @SuppressWarnings("unchecked")
+ public MBeanServerConnection getMBeanServer()
+ {
+ ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
+ if (serverArr.size() > 1)
+ throw new IllegalStateException("Multiple MBeanServer instances not supported");
+
+ MBeanServer server = null;
+ if (serverArr.size() == 1)
+ server = serverArr.get(0);
+
+ if (server == null)
+ server = MBeanServerFactory.createMBeanServer();
+
+ return server;
+ }
+
+ public OSGiPackageAdmin getPackageAdmin()
+ {
+ BundleContext context = getBundleContext();
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packAdmin = (PackageAdmin)context.getService(sref);
+ return new EmbeddedPackageAdmin(packAdmin);
+ }
+}
Deleted: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-10-22 06:54:15 UTC (rev 95382)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -1,297 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi.testing.internal;
-
-// $Id$
-
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.management.MBeanException;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.management.MBeanProxy;
-import org.jboss.osgi.spi.management.MBeanProxyException;
-import org.jboss.osgi.spi.management.ManagedBundleMBean;
-import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
-import org.jboss.osgi.spi.management.ManagedServiceReference;
-import org.jboss.osgi.spi.testing.OSGiBundle;
-import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiServiceReference;
-import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.jboss.osgi.spi.util.BundleInfo;
-import org.osgi.framework.BundleException;
-
-/**
- * A remote implementation of the {@link OSGiRuntime}
- *
- * @author Thomas.Diesler at jboss.org
- * @since 25-Sep-2008
- */
-public class RemoteRuntime extends OSGiRuntimeImpl
-{
- private MBeanServerConnection mbeanServer;
- private ManagedFrameworkMBean managedFramework;
-
- public RemoteRuntime(OSGiTestHelper helper)
- {
- super(helper);
- }
-
- public OSGiBundle installBundle(String location) throws BundleException
- {
- try
- {
- URL bundleURL = getTestHelper().getTestArchiveURL(location);
- BundleInfo bundleInfo = BundleInfo.createBundleInfo(bundleURL);
-
- deployInternal(location, true);
-
- String symbolicName = bundleInfo.getSymbolicName();
- String version = bundleInfo.getVersion().toString();
- ManagedBundleMBean bundleMBean = getRemoteFramework().getBundle(symbolicName, version);
- RemoteBundle bundle = new RemoteBundle(this, bundleMBean, location);
- return registerBundle(location, bundle);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (MBeanException ex)
- {
- Exception target = ex.getTargetException();
- if (target instanceof BundleException)
- throw (BundleException)target;
-
- throw new BundleException("Cannot install: " + location, target);
- }
- catch (Exception ex)
- {
- throw new BundleException("Cannot install: " + location, ex);
- }
- }
-
- public void deploy(String location) throws Exception
- {
- deployInternal(location, false);
- }
-
- private void deployInternal(String location, boolean isBundle) throws Exception
- {
- URL archiveURL = getTestHelper().getTestArchiveURL(location);
- if (isBundle)
- invokeDeployerService("deploy", archiveURL);
- else
- invokeMainDeployer("deploy", archiveURL);
- }
-
- public void undeploy(String location) throws Exception
- {
- URL archiveURL = getTestHelper().getTestArchiveURL(location);
- if (isBundleArchive(location))
- invokeDeployerService("undeploy", archiveURL);
- else
- invokeMainDeployer("undeploy", archiveURL);
- }
-
- private boolean isBundleArchive(String location)
- {
- try
- {
- URL archiveURL = getTestHelper().getTestArchiveURL(location);
- BundleInfo.createBundleInfo(archiveURL);
- return true;
- }
- catch (RuntimeException ex)
- {
- return false;
- }
- }
-
- public OSGiBundle[] getBundles()
- {
- try
- {
- Set<ManagedBundleMBean> remoteBundles = getRemoteFramework().getBundles();
- Set<OSGiBundle> bundles = new HashSet<OSGiBundle>();
- for (ManagedBundleMBean remoteBundle : remoteBundles)
- bundles.add(new RemoteBundle(this, remoteBundle, null));
-
- OSGiBundle[] bundleArr = new OSGiBundle[bundles.size()];
- bundles.toArray(bundleArr);
-
- return bundleArr;
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Cannot obtain remote bundles", ex);
- }
- }
-
- public OSGiBundle getBundle(long bundleId)
- {
- ManagedBundleMBean bundle = getRemoteFramework().getBundle(bundleId);
- return bundle != null ? new RemoteBundle(this, bundle, null) : null;
- }
-
- public OSGiServiceReference getServiceReference(String clazz)
- {
- ManagedServiceReference manref = getRemoteFramework().getServiceReference(clazz);
- return manref != null ? new RemoteServiceReference(manref) : null;
- }
-
- public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
- {
- OSGiServiceReference[] srefs = null;
-
- ManagedServiceReference[] manrefs = getRemoteFramework().getServiceReferences(clazz, filter);
- if (manrefs != null)
- {
- srefs = new OSGiServiceReference[manrefs.length];
- for (int i = 0; i < manrefs.length; i++)
- srefs[i] = new RemoteServiceReference(manrefs[i]);
- }
-
- return srefs;
- }
-
- public MBeanServerConnection getMBeanServer()
- {
- if (mbeanServer == null)
- {
- try
- {
- InitialContext iniCtx = getInitialContext();
- mbeanServer = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
- }
- catch (NamingException ex)
- {
- throw new IllegalStateException("Cannot obtain MBeanServerConnection", ex);
- }
- }
- return mbeanServer;
- }
-
- public OSGiPackageAdmin getPackageAdmin()
- {
- return new RemotePackageAdmin(this);
- }
-
- @Override
- public void shutdown()
- {
- OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
- if (bootProvider != null)
- {
- super.shutdown();
- getPackageAdmin().refreshPackages(null);
- }
- }
-
- private RemoteFramework getRemoteFramework()
- {
- try
- {
- if (managedFramework == null)
- managedFramework = MBeanProxy.get(ManagedFrameworkMBean.class, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, getMBeanServer());
- }
- catch (MBeanProxyException ex)
- {
- throw new RemoteFrameworkException(ex);
- }
-
- return new RemoteFramework()
- {
- public ManagedBundleMBean getBundle(String symbolicName, String version)
- {
- ObjectName oname = managedFramework.getBundle(symbolicName, version);
- if (oname == null)
- throw new IllegalArgumentException("Cannot get remote bundle for: " + symbolicName);
-
- try
- {
- return MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
- }
- catch (MBeanProxyException ex)
- {
- throw new RemoteFrameworkException(ex);
- }
- }
-
- public ManagedBundleMBean getBundle(long bundleId)
- {
- ObjectName oname = managedFramework.getBundle(bundleId);
- if (oname == null)
- throw new IllegalArgumentException("Cannot get remote bundle for: " + bundleId);
-
- try
- {
- return MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
- }
- catch (MBeanProxyException ex)
- {
- throw new RemoteFrameworkException(ex);
- }
- }
-
- public Set<ManagedBundleMBean> getBundles()
- {
- Set<ManagedBundleMBean> remBundles = new HashSet<ManagedBundleMBean>();
- for (ObjectName bundleOName : managedFramework.getBundles())
- {
- try
- {
- ManagedBundleMBean remBundle = MBeanProxy.get(ManagedBundleMBean.class, bundleOName, getMBeanServer());
- remBundles.add(remBundle);
- }
- catch (MBeanProxyException ex)
- {
- throw new RemoteFrameworkException(ex);
- }
- }
- return remBundles;
- }
-
- public ManagedServiceReference getServiceReference(String clazz)
- {
- return managedFramework.getServiceReference(clazz);
- }
-
- public ManagedServiceReference[] getServiceReferences(String clazz, String filter)
- {
- return managedFramework.getServiceReferences(clazz, filter);
- }
- };
- }
-
- private void invokeMainDeployer(String method, URL archiveURL) throws Exception
- {
- ObjectName oname = new ObjectName("jboss.system:service=MainDeployer");
- getMBeanServer().invoke(oname, method, new Object[] { archiveURL }, new String[] { URL.class.getName() });
- }
-}
Copied: projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java (from rev 95389, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/testing/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -0,0 +1,298 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.spi.testing.internal;
+
+// $Id$
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.MBeanException;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.management.MBeanProxyException;
+import org.jboss.osgi.spi.management.ManagedBundleMBean;
+import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
+import org.jboss.osgi.spi.management.ManagedServiceReference;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.osgi.framework.BundleException;
+
+/**
+ * A remote implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class RemoteRuntime extends OSGiRuntimeImpl
+{
+ private MBeanServerConnection mbeanServer;
+ private ManagedFrameworkMBean managedFramework;
+
+ public RemoteRuntime(OSGiTestHelper helper)
+ {
+ super(helper);
+ }
+
+ public OSGiBundle installBundle(String location) throws BundleException
+ {
+ try
+ {
+ URL bundleURL = getTestHelper().getTestArchiveURL(location);
+ BundleInfo bundleInfo = BundleInfo.createBundleInfo(bundleURL);
+
+ deployInternal(location, true);
+
+ String symbolicName = bundleInfo.getSymbolicName();
+ String version = bundleInfo.getVersion().toString();
+ ManagedBundleMBean bundleMBean = getRemoteFramework().getBundle(symbolicName, version);
+ RemoteBundle bundle = new RemoteBundle(this, bundleMBean, location);
+ return registerBundle(location, bundle);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (MBeanException ex)
+ {
+ Exception target = ex.getTargetException();
+ if (target instanceof BundleException)
+ throw (BundleException)target;
+
+ throw new BundleException("Cannot install: " + location, target);
+ }
+ catch (Exception ex)
+ {
+ throw new BundleException("Cannot install: " + location, ex);
+ }
+ }
+
+ public void deploy(String location) throws Exception
+ {
+ deployInternal(location, false);
+ }
+
+ private void deployInternal(String location, boolean isBundle) throws Exception
+ {
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+ if (isBundle)
+ invokeDeployerService("deploy", archiveURL);
+ else
+ invokeMainDeployer("deploy", archiveURL);
+ }
+
+ public void undeploy(String location) throws Exception
+ {
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+ if (isBundleArchive(location))
+ invokeDeployerService("undeploy", archiveURL);
+ else
+ invokeMainDeployer("undeploy", archiveURL);
+ }
+
+ private boolean isBundleArchive(String location)
+ {
+ try
+ {
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+ BundleInfo.createBundleInfo(archiveURL);
+ return true;
+ }
+ catch (RuntimeException ex)
+ {
+ return false;
+ }
+ }
+
+ public OSGiBundle[] getBundles()
+ {
+ try
+ {
+ Set<ManagedBundleMBean> remoteBundles = getRemoteFramework().getBundles();
+ Set<OSGiBundle> bundles = new HashSet<OSGiBundle>();
+ for (ManagedBundleMBean remoteBundle : remoteBundles)
+ bundles.add(new RemoteBundle(this, remoteBundle, null));
+
+ OSGiBundle[] bundleArr = new OSGiBundle[bundles.size()];
+ bundles.toArray(bundleArr);
+
+ return bundleArr;
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot obtain remote bundles", ex);
+ }
+ }
+
+ public OSGiBundle getBundle(long bundleId)
+ {
+ ManagedBundleMBean bundle = getRemoteFramework().getBundle(bundleId);
+ return bundle != null ? new RemoteBundle(this, bundle, null) : null;
+ }
+
+ public OSGiServiceReference getServiceReference(String clazz)
+ {
+ ManagedServiceReference manref = getRemoteFramework().getServiceReference(clazz);
+ return manref != null ? new RemoteServiceReference(manref) : null;
+ }
+
+ public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
+ {
+ OSGiServiceReference[] srefs = null;
+
+ ManagedServiceReference[] manrefs = getRemoteFramework().getServiceReferences(clazz, filter);
+ if (manrefs != null)
+ {
+ srefs = new OSGiServiceReference[manrefs.length];
+ for (int i = 0; i < manrefs.length; i++)
+ srefs[i] = new RemoteServiceReference(manrefs[i]);
+ }
+
+ return srefs;
+ }
+
+ public MBeanServerConnection getMBeanServer()
+ {
+ if (mbeanServer == null)
+ {
+ try
+ {
+ InitialContext iniCtx = getInitialContext();
+ mbeanServer = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
+ }
+ catch (NamingException ex)
+ {
+ throw new IllegalStateException("Cannot obtain MBeanServerConnection", ex);
+ }
+ }
+ return mbeanServer;
+ }
+
+ public OSGiPackageAdmin getPackageAdmin()
+ {
+ return new RemotePackageAdmin(this);
+ }
+
+ @Override
+ public void shutdown()
+ {
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
+ if (bootProvider != null)
+ {
+ super.shutdown();
+ getPackageAdmin().refreshPackages(null);
+ getTestHelper().ungetBootstrapProvider();
+ }
+ }
+
+ private RemoteFramework getRemoteFramework()
+ {
+ try
+ {
+ if (managedFramework == null)
+ managedFramework = MBeanProxy.get(ManagedFrameworkMBean.class, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, getMBeanServer());
+ }
+ catch (MBeanProxyException ex)
+ {
+ throw new RemoteFrameworkException(ex);
+ }
+
+ return new RemoteFramework()
+ {
+ public ManagedBundleMBean getBundle(String symbolicName, String version)
+ {
+ ObjectName oname = managedFramework.getBundle(symbolicName, version);
+ if (oname == null)
+ throw new IllegalArgumentException("Cannot get remote bundle for: " + symbolicName);
+
+ try
+ {
+ return MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
+ }
+ catch (MBeanProxyException ex)
+ {
+ throw new RemoteFrameworkException(ex);
+ }
+ }
+
+ public ManagedBundleMBean getBundle(long bundleId)
+ {
+ ObjectName oname = managedFramework.getBundle(bundleId);
+ if (oname == null)
+ throw new IllegalArgumentException("Cannot get remote bundle for: " + bundleId);
+
+ try
+ {
+ return MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
+ }
+ catch (MBeanProxyException ex)
+ {
+ throw new RemoteFrameworkException(ex);
+ }
+ }
+
+ public Set<ManagedBundleMBean> getBundles()
+ {
+ Set<ManagedBundleMBean> remBundles = new HashSet<ManagedBundleMBean>();
+ for (ObjectName bundleOName : managedFramework.getBundles())
+ {
+ try
+ {
+ ManagedBundleMBean remBundle = MBeanProxy.get(ManagedBundleMBean.class, bundleOName, getMBeanServer());
+ remBundles.add(remBundle);
+ }
+ catch (MBeanProxyException ex)
+ {
+ throw new RemoteFrameworkException(ex);
+ }
+ }
+ return remBundles;
+ }
+
+ public ManagedServiceReference getServiceReference(String clazz)
+ {
+ return managedFramework.getServiceReference(clazz);
+ }
+
+ public ManagedServiceReference[] getServiceReferences(String clazz, String filter)
+ {
+ return managedFramework.getServiceReferences(clazz, filter);
+ }
+ };
+ }
+
+ private void invokeMainDeployer(String method, URL archiveURL) throws Exception
+ {
+ ObjectName oname = new ObjectName("jboss.system:service=MainDeployer");
+ getMBeanServer().invoke(oname, method, new Object[] { archiveURL }, new String[] { URL.class.getName() });
+ }
+}
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java 2009-10-22 10:28:59 UTC (rev 95390)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbossas/jbosgi36/OSGI36TestCase.java 2009-10-22 11:39:22 UTC (rev 95391)
@@ -54,7 +54,7 @@
@BeforeClass
public static void setUpClass() throws Exception
{
- runtime = new OSGiTestHelper().getRemoteRuntime();
+ runtime = (RemoteRuntime)new OSGiTestHelper().getRemoteRuntime();
runtime.addCapability(new JNDICapability());
runtime.addCapability(new JMXCapability());
runtime.addCapability(new MicrocontainerCapability());
More information about the jboss-cvs-commits
mailing list