Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLazar Kirchev2012-09-10 03:49:50 -0400
committerLazar Kirchev2012-09-10 04:05:36 -0400
commitfc0b09e29de83ef7f298644d85b07b5635a849c3 (patch)
treee34521aae1330d2105628217118c9c2f0b61b28b
parentadf989625b43d0a4d9f51eac06fe44d625b7ff44 (diff)
parente7afff18213d1ddd79aa022b78b3354d35b4fe59 (diff)
downloadorg.eclipse.virgo.kernel-fc0b09e29de83ef7f298644d85b07b5635a849c3.tar.gz
org.eclipse.virgo.kernel-fc0b09e29de83ef7f298644d85b07b5635a849c3.tar.xz
org.eclipse.virgo.kernel-fc0b09e29de83ef7f298644d85b07b5635a849c3.zip
Merge master with branch shell_bundles_merge_bug388518
-rw-r--r--build.properties4
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/.classpath20
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/.project35
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/.springBeans13
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/build.xml8
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/ivy.xml31
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/Activator.java159
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/helper/ClassLoadingHelper.java269
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoClassLoadingCommand.java188
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoKernelShellCommand.java242
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoLinePrinter.java46
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupport.java96
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportMBean.java59
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/main/resources/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/helper/ClassLoadingHelperTests.java248
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoClassLoadingCommandTests.java403
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportTests.java159
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/src/test/resources/.gitignore0
-rw-r--r--org.eclipse.virgo.kernel.osgicommand/template.mf19
-rw-r--r--org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgicommand/helper/test/ClassLoadingHelperIntegrationTests.java6
-rw-r--r--org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF18
-rw-r--r--org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties1
-rw-r--r--org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties1
-rw-r--r--org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/ConfigCommandsTests.java6
-rw-r--r--org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java2
-rw-r--r--org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/completers/ConfigCompleterTests.java6
27 files changed, 25 insertions, 2018 deletions
diff --git a/build.properties b/build.properties
index b44463ac..aa050fa7 100644
--- a/build.properties
+++ b/build.properties
@@ -12,5 +12,5 @@ project.name=Virgo Kernel
natural.name=virgo-kernel
project.key=VK
-#test.vm.args= -Xmx1024M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError
-test.vm.args= -Xmx1024M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
+test.vm.args= -Xmx1024M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError
+#test.vm.args= -Xmx1024M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
diff --git a/org.eclipse.virgo.kernel.osgicommand/.classpath b/org.eclipse.virgo.kernel.osgicommand/.classpath
deleted file mode 100644
index 8bb082d4..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/.classpath
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" path="src/main/resources"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/KERNEL_IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.osgi"/>
- <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.services"/>
- <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.virgo.kernel.shell"/>
- <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.mirrored/org.eclipse.osgi/3.8.0.v20120508-2119/org.eclipse.osgi-3.8.0.v20120508-2119.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.1.R37x_v20110808-1106/org.eclipse.osgi-sources-3.7.1.R37x_v20110808-1106.jar"/>
- <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.io/3.6.0.D-20120903162413/org.eclipse.virgo.util.io-3.6.0.D-20120903162413.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.5.0.D-20120615065828/org.eclipse.virgo.util.osgi-sources-3.5.0.D-20120615065828.jar"/>
- <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-2.3.0.jar" sourcepath="/KERNEL_IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-sources-2.3.0.jar"/>
- <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.mirrored/org.apache.felix.gogo.runtime/0.8.0.v201108120515/org.apache.felix.gogo.runtime-0.8.0.v201108120515.jar" sourcepath="/KERNEL_IVY_CACHE/org.apache.felix/org.apache.felix.gogo.runtime/0.8.0.v201107131313/org.apache.felix.gogo.runtime-sources-0.8.0.v201107131313.jar"/>
- <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.mirrored/org.apache.felix.gogo.shell/0.8.0.v201110170705/org.apache.felix.gogo.shell-0.8.0.v201110170705.jar" sourcepath="/KERNEL_IVY_CACHE/org.apache.felix/org.apache.felix.gogo.shell/0.8.0.v201107131313/org.apache.felix.gogo.shell-sources-0.8.0.v201107131313.jar"/>
- <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.mirrored/org.apache.felix.gogo.command/0.8.0.v201108120515/org.apache.felix.gogo.command-0.8.0.v201108120515.jar"/>
- <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.6.0.D-20120903162413/org.eclipse.virgo.util.osgi-3.6.0.D-20120903162413.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.virgo.util/org.eclipse.virgo.util.osgi/3.1.0.M01/org.eclipse.virgo.util.osgi-sources-3.1.0.M01.jar"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
diff --git a/org.eclipse.virgo.kernel.osgicommand/.project b/org.eclipse.virgo.kernel.osgicommand/.project
deleted file mode 100644
index 82aa4e6b..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/.project
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.virgo.kernel.osgicommand</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.wst.common.project.facet.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.springsource.server.ide.bundlor.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.springframework.ide.eclipse.core.springbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.springsource.server.ide.facet.core.bundlenature</nature>
- <nature>org.springframework.ide.eclipse.core.springnature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.virgo.kernel.osgicommand/.settings/org.eclipse.wst.common.project.facet.core.xml b/org.eclipse.virgo.kernel.osgicommand/.settings/org.eclipse.wst.common.project.facet.core.xml
deleted file mode 100644
index 92aa2909..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/.settings/org.eclipse.wst.common.project.facet.core.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<faceted-project>
- <installed facet="org.eclipse.virgo.server.bundle" version="1.0"/>
-</faceted-project>
diff --git a/org.eclipse.virgo.kernel.osgicommand/.springBeans b/org.eclipse.virgo.kernel.osgicommand/.springBeans
deleted file mode 100644
index 55e47c55..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/.springBeans
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beansProjectDescription>
- <version>1</version>
- <pluginVersion><![CDATA[2.5.0.201010141000-RC1]]></pluginVersion>
- <configSuffixes>
- <configSuffix><![CDATA[xml]]></configSuffix>
- </configSuffixes>
- <enableImports><![CDATA[false]]></enableImports>
- <configs>
- </configs>
- <configSets>
- </configSets>
-</beansProjectDescription>
diff --git a/org.eclipse.virgo.kernel.osgicommand/build.xml b/org.eclipse.virgo.kernel.osgicommand/build.xml
deleted file mode 100644
index 3d38210e..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/build.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="org.eclipse.virgo.kernel.osgicommand">
-
- <property file="${basedir}/../build.properties"/>
- <property file="${basedir}/../build.versions"/>
- <import file="${basedir}/../virgo-build/standard/default.xml"/>
-
-</project>
diff --git a/org.eclipse.virgo.kernel.osgicommand/ivy.xml b/org.eclipse.virgo.kernel.osgicommand/ivy.xml
deleted file mode 100644
index 3f95a37c..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/ivy.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<ivy-module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd" version="2.0">
-
- <info organisation='${project.organisation}' module='${ant.project.name}'/>
-
- <configurations>
- <include file='${virgo.build.dir}/common/default-ivy-configurations.xml'/>
- </configurations>
-
- <publications>
- <artifact name='${ant.project.name}'/>
- <artifact name='${ant.project.name}-sources' ext='jar' type='src'/>
- </publications>
-
- <dependencies>
- <dependency org="org.junit" name="com.springsource.org.junit" rev="${org.junit}" conf="test->runtime"/>
- <dependency org="org.eclipse.virgo.mirrored" name='org.eclipse.osgi' rev='${org.eclipse.osgi}' conf='compile->compile' />
- <dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.osgi" rev="latest.integration" conf="compile->compile"/>
- <dependency org="org.eclipse.virgo.kernel" name="org.eclipse.virgo.kernel.shell" rev="latest.integration" conf="compile->compile"/>
- <dependency org="org.eclipse.virgo.mirrored" name="org.apache.felix.gogo.runtime" rev="${org.apache.felix.gogo.runtime}" conf="compile->compile"/>
- <!-- TEST -->
- <dependency org="org.slf4j" name="com.springsource.slf4j.nop" rev="${org.slf4j}" conf="test->runtime"/>
- <dependency org="org.junit" name="com.springsource.org.junit" rev="${org.junit}" conf="test->runtime"/>
- <dependency org="org.easymock" name="com.springsource.org.easymock" rev="${org.easymock}" conf="test->runtime"/>
- <dependency org="org.eclipse.virgo.medic" name="org.eclipse.virgo.medic.test" rev="${org.eclipse.virgo.medic}" conf="test->runtime"/>
-
- <override org="org.springframework" rev="${org.springframework}"/>
- <override org="org.slf4j" rev="${org.slf4j}"/>
- </dependencies>
-
-</ivy-module>
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/Activator.java b/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/Activator.java
deleted file mode 100644
index 1d8369de..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/Activator.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * This file is part of the Virgo Kernel.
- *
- * Copyright (c) 2010 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgicommand;
-
-import java.lang.management.ManagementFactory;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.eclipse.virgo.kernel.osgi.framework.OsgiFrameworkUtils;
-import org.eclipse.virgo.kernel.osgi.framework.OsgiServiceHolder;
-import org.eclipse.virgo.kernel.osgicommand.internal.GogoClassLoadingCommand;
-import org.eclipse.virgo.kernel.osgicommand.internal.GogoKernelShellCommand;
-import org.eclipse.virgo.kernel.osgicommand.management.ClassLoadingSupport;
-import org.eclipse.virgo.kernel.shell.CommandExecutor;
-import org.eclipse.virgo.util.osgi.ServiceRegistrationTracker;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * {@link BundleActivator} for the Gogo shell command bundle.
- * <p/>
- * <strong>Concurrent Semantics</strong><br />
- * Not thread safe.
- */
-public class Activator implements BundleActivator {
-
- private static final String KERNEL_SHELL_COMMAND = "vsh";
-
- private static final String[] KERNEL_SHELL_SUBCOMMANDS = new String[] { "bundle", "config", "install", "packages", "par", "plan", "service",
- "shutdown" };
-
- private static final String[] CLASS_LOADING_SUBCOMMANDS = new String[] { "clhas", "clload", "clexport" };
-
- private static final int COMMAND_EXECUTOR_SERVICE_WAIT = 20 * 1000; // 20 seconds
-
- private static final int SERVICE_WAIT_PAUSE = 100; // 100 milliseconds
-
- private final ServiceRegistrationTracker registrationTracker = new ServiceRegistrationTracker();
-
- private final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
-
- private final ObjectName classLoadingObjectName;
-
- private ServiceRegistration<GogoClassLoadingCommand> classLoadingCommandRegistration;
-
- public Activator() throws MalformedObjectNameException {
- this.classLoadingObjectName = new ObjectName("org.eclipse.virgo.kernel:type=Classloading");
- }
-
- @Override
- public void start(BundleContext context) throws Exception {
- // Gogo binding
- Dictionary<String, Object> properties = new Hashtable<String, Object>();
- properties.put(org.apache.felix.service.command.CommandProcessor.COMMAND_SCOPE, KERNEL_SHELL_COMMAND);
- properties.put(org.apache.felix.service.command.CommandProcessor.COMMAND_FUNCTION, CLASS_LOADING_SUBCOMMANDS);
- this.classLoadingCommandRegistration = context.registerService(GogoClassLoadingCommand.class, new GogoClassLoadingCommand(context),
- properties);
-
- this.server.registerMBean(new ClassLoadingSupport(context), this.classLoadingObjectName);
-
- Runnable runnable = new PostStartInitialisationRunnable(context, this.registrationTracker);
- Thread thread = new Thread(runnable);
- thread.setDaemon(true);
- thread.start();
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- // Gogo binding
- if (this.classLoadingCommandRegistration != null) {
- this.classLoadingCommandRegistration.unregister();
- this.classLoadingCommandRegistration = null;
- }
-
- this.registrationTracker.unregisterAll();
-
- this.server.unregisterMBean(this.classLoadingObjectName);
- }
-
- /**
- * Get a service which might not be immediately available
- *
- * @param <T> type of service to get
- * @param context in which to search for service
- * @param serviceClass of service to locate
- * @param millis maximum time to delay in milliseconds
- * @return null if timeout before getting service, otherwise service
- */
- private static <T> T getPotentiallyDelayedService(BundleContext context, Class<T> serviceClass, long millis) {
- T service = null;
-
- while (service == null) {
- try {
- OsgiServiceHolder<T> serviceHolder = OsgiFrameworkUtils.getService(context, serviceClass);
- if (serviceHolder != null) {
- service = serviceHolder.getService();
- }
- } catch (IllegalStateException e) {
- try {
- millis -= SERVICE_WAIT_PAUSE;
- if (millis > 0) {
- Thread.sleep(SERVICE_WAIT_PAUSE);
- } else {
- return null;
- }
- } catch (InterruptedException ie) {
- }
- }
- }
-
- return service;
- }
-
- private static final class PostStartInitialisationRunnable implements Runnable {
-
- private final BundleContext context;
-
- private final ServiceRegistrationTracker registrationTracker;
-
- public PostStartInitialisationRunnable(BundleContext context, ServiceRegistrationTracker registrationTracker) {
- this.context = context;
- this.registrationTracker = registrationTracker;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- CommandExecutor commandExecutor = getPotentiallyDelayedService(this.context, CommandExecutor.class, COMMAND_EXECUTOR_SERVICE_WAIT);
- if (commandExecutor == null) {
- return; // TODO: report this failure -- but where?
- }
-
- // Gogo binding
- Dictionary<String, Object> properties = new Hashtable<String, Object>();
- properties.put(org.apache.felix.service.command.CommandProcessor.COMMAND_SCOPE, KERNEL_SHELL_COMMAND);
- properties.put(org.apache.felix.service.command.CommandProcessor.COMMAND_FUNCTION, KERNEL_SHELL_SUBCOMMANDS);
- this.registrationTracker.track(context.registerService(GogoKernelShellCommand.class, new GogoKernelShellCommand(commandExecutor),
- properties));
- }
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/helper/ClassLoadingHelper.java b/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/helper/ClassLoadingHelper.java
deleted file mode 100644
index 36286309..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/helper/ClassLoadingHelper.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 SAP AG
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Hristo Iliev, SAP AG - initial contribution
- *******************************************************************************/
-package org.eclipse.virgo.kernel.osgicommand.helper;
-
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.osgi.service.resolver.ExportPackageDescription;
-import org.eclipse.osgi.service.resolver.PlatformAdmin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-import java.net.URL;
-import java.util.*;
-
-/**
- * Helper for class loading supporting commands
- */
-@SuppressWarnings("deprecation")
-public class ClassLoadingHelper {
-
- /**
- * Determines if a class package is exported by a bundle
- *
- * @param bundleContext Bundle context for interaction with the OSGi framework
- * @param classPackage Class package to check for
- * @param testBundle The bundle that has to be tested
- * @return TRUE if the bundle is exported by the package, FALSE if the class is not exported or it does not have a package
- */
- public static boolean isPackageExported(BundleContext bundleContext, String classPackage, Bundle testBundle) {
- ServiceReference<PlatformAdmin> reference = bundleContext.getServiceReference(PlatformAdmin.class);
- PlatformAdmin platformAdmin = bundleContext.getService(reference);
- BundleDescription bundleDescription = platformAdmin.getState(false).getBundle(testBundle.getBundleId());
-
- ExportPackageDescription[] exportDescriptions = bundleDescription.getSelectedExports();
- for (ExportPackageDescription exportDescription : exportDescriptions) {
- if (exportDescription.getName().equals(convertToClassName(classPackage)))
- return true;
- }
-
- // not found
- return false;
- }
-
- /**
- * Returns the bundles that can load a class and the originating bundle in a map
- *
- * @param bundleContext Bundle context for interaction with the OSGi framework
- * @param className Fully qualified class name (in the form &lt;package&gt;.&lt;class name&gt;)
- * @return Map between the bundles that can load the class and the bundle that provides it in each case
- */
- public static Map<Bundle, Bundle> getBundlesLoadingClass(BundleContext bundleContext, String className) {
- Bundle[] bundles = bundleContext.getBundles();
- HashMap<Bundle, Bundle> foundBundles = new HashMap<Bundle, Bundle>();
- for (Bundle bundle : bundles) {
- Bundle originBundle = getOriginBundleOfClass(className, bundleContext, bundle);
- if (originBundle != null) {
- foundBundles.put(bundle, originBundle);
- }
- }
-
- return foundBundles;
- }
-
- /**
- * Find the originating bundle of a class loaded by a bundle
- *
- * @param className Fully qualified class name (in the form &lt;package&gt;.&lt;class name&gt; name)
- * @param bundleContext Bundle context for interaction with the OSGi framework
- * @param loadingBundle Bundle instance to load class from
- * @return originating {@link Bundle} or null if it cannot be loaded by <code>testBundle</code>
- */
- public static Bundle getOriginBundleOfClass(String className, BundleContext bundleContext, Bundle loadingBundle) {
- Class<?> clasz = tryToLoadClass(className, loadingBundle);
- Bundle originBundle = null;
- if (clasz != null) {
- originBundle = FrameworkUtil.getBundle(clasz);
- if (originBundle == null) {
- // this is the system bundle
- originBundle = bundleContext.getBundle(0);
- }
- }
- return originBundle;
- }
-
- /**
- * Tries to load a class
- *
- * @param className Fully qualified class name (in the form &lt;package&gt;.&lt;class name&gt;)
- * @param bundle Bundle instance that has to be checked
- * @return The loaded class or null if it cannot be loaded from this bundle
- */
- public static Class<?> tryToLoadClass(String className, Bundle bundle) {
- if (bundle == null)
- return null;
-
- try {
- return bundle.loadClass(convertToClassName(className));
- } catch (ClassNotFoundException e) {
- // do nothing - if the class is not found we don't care
- }
- return null;
- }
-
- /**
- * Converts resource path (/javax/servlet/Servlet.class) to class name (javax.servlet.Servlet)
- *
- * @param resourcePath Path to the resource
- * @return Class name
- */
- public static String convertToClassName(String resourcePath) {
- if (resourcePath == null)
- return null;
-
- resourcePath = resourcePath.replace("/", ".");
- if (resourcePath.startsWith(".")) {
- resourcePath = resourcePath.substring(1);
- }
- if (resourcePath.endsWith(".class")) {
- resourcePath = resourcePath.substring(0, resourcePath.length() - 6);
- }
-
- return resourcePath;
- }
-
- /**
- * Convert from package to path format (javax.servlet.Servlet --> javax/servlet/Servlet.class)
- *
- * @param className Class name
- * @return Path to a resource
- */
- public static String convertToResourcePath(String className) {
- if (className == null)
- return null;
-
- String result = className;
- if (!className.contains("/") && !className.contains("*")) {
- if (className.endsWith(".class")) {
- result = className.substring(0, className.length() - 6);
- }
- return result.replace(".", "/") + ".class";
- }
-
- return result;
- }
-
- /**
- * Returns all bundles that can load a class
- *
- * @param bundleContext Bundle context for interaction with the OSGi framework
- * @param className Fully qualified class name (in the form &lt;package&gt;.&lt;class name&gt;)
- * @param bundle Bundle name or ID that has to be checked
- * @return Map between the bundle that can load the class (key) and the one that provides it (value)
- * @throws IllegalArgumentException if there is no bundle with such name/id
- */
- public static Map<Bundle, Bundle> getBundlesLoadingClass(BundleContext bundleContext, String className, String bundle) throws IllegalArgumentException {
- HashMap<Bundle, Bundle> result = new HashMap<Bundle, Bundle>();
- long id = Long.MIN_VALUE;
- try {
- id = Long.parseLong(bundle);
- } catch (NumberFormatException e) {
- // not a number - then it is bundle name
- }
-
- if (id >= 0) {
- Bundle testBundle = bundleContext.getBundle(id);
- if (testBundle == null)
- throw new IllegalArgumentException("Bundle with ID [" + id + "] not found");
-
- Bundle originBundle = getOriginBundleOfClass(className, bundleContext, testBundle);
- if (originBundle != null) {
- result.put(testBundle, originBundle);
- }
- } else {
- ServiceReference<PackageAdmin> reference = bundleContext.getServiceReference(PackageAdmin.class);
- PackageAdmin packageAdmin = bundleContext.getService(reference);
- Bundle[] bundles = packageAdmin.getBundles(bundle, null);
- if (bundles == null)
- throw new IllegalArgumentException("Bundle with symbolic name [" + bundle + "] not found");
-
- for (Bundle testBundle : bundles) {
- Bundle originBundle = getOriginBundleOfClass(className, bundleContext, testBundle);
- if (originBundle != null) {
- result.put(testBundle, originBundle);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Returns all bundles that contain a class
- *
- * @param bundleContext Bundle context for interaction with the OSGi framework
- * @param resourcePattern Search pattern in the form &lt;package&gt;/&lt;class name&gt;. The pattern can contain wildcards
- * @return Map between the bundle (key) and the URL(s) of the resources (value)
- */
- public static Map<Bundle, List<String>> getBundlesContainingResource(BundleContext bundleContext, String resourcePattern) {
- Map<Bundle, List<String>> result = new HashMap<Bundle, List<String>>();
-
- Bundle[] bundles = bundleContext.getBundles();
- for (Bundle bundle : bundles) {
- List<String> entries = findEntries(bundle, resourcePattern);
- if (entries != null && entries.size() != 0) {
- result.put(bundle, entries);
- }
- }
-
- return result;
- }
-
- /**
- * Returns a list with bundle entries matching a resource pattern
- *
- * @param bundle Bundle to scan for entries
- * @param resourcePattern Pattern used for matching
- * @return List with found entries
- */
- private static List<String> findEntries(Bundle bundle, String resourcePattern) {
- HashSet<String> urls = new HashSet<String>();
-
- int index = resourcePattern.lastIndexOf("/");
- if (index != -1) {
- String resourcePath = resourcePattern.substring(0, index);
- String resourceEntity = resourcePattern.substring(index + 1);
- // Search the whole bundle for entity starting from the root. We need this since "the pattern is only
- // matched against the last element of the entry path" as stated in findEntries JavaDoc. This means that
- // web bundle that packages a class in WEB-INF/classes will not be found by findEntries since the path is
- // prepended with WEB-INF/classes. Therefore we search for a class everywhere in the bundle and then
- // filter the result.
- addURLs(urls, bundle.findEntries("/", resourceEntity, true), resourcePath);
- }
-
- // Search the root of the bundle for entity matching the specified pattern
- addURLs(urls, bundle.findEntries("/", resourcePattern, true), null);
- return new ArrayList<String>(urls);
- }
-
- /**
- * Adds all found resources eliminating the duplicates or the ones that do not contain the requested path
- *
- * @param urls Result set with URLs as string
- * @param foundURLs Enumeration to scan
- * @param path Expected path of the entities. The entities are not put in the result set unless they contain
- * this path.
- */
- private static void addURLs(HashSet<String> urls, Enumeration<URL> foundURLs, String path) {
- if (foundURLs != null) {
- while (foundURLs.hasMoreElements()) {
- String url = foundURLs.nextElement().getFile();
- if (path != null && !url.contains(path)) {
- continue;
- }
- urls.add(url);
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoClassLoadingCommand.java b/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoClassLoadingCommand.java
deleted file mode 100644
index fa4857e3..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoClassLoadingCommand.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 SAP AG and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Hristo Iliev, SAP AG - initial contribution
- * Glyn Normington, VMware Inc. - bind commands to Gogo
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgicommand.internal;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.service.command.Descriptor;
-import org.eclipse.virgo.kernel.osgicommand.helper.ClassLoadingHelper;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * Class loading commands for supportability and diagnostics
- */
-public class GogoClassLoadingCommand {
-
- private BundleContext bundleContext;
-
- public GogoClassLoadingCommand(BundleContext context) {
- this.bundleContext = context;
- }
-
- /**
- * Lists all bundles that contain a class
- *
- */
- @Descriptor("list all bundles that contain a class or resource with the specified name")
- public void clhas(@Descriptor("class or resource name") String className) {
- className = ClassLoadingHelper.convertToResourcePath(className);
-
- Map<Bundle, List<String>> foundBundles = ClassLoadingHelper.getBundlesContainingResource(bundleContext, className);
- if (foundBundles.size() == 0) {
- System.out.println("No bundle contains [" + className + "]");
- return;
- }
-
- outputBundlesAndResources("Bundles containing [" + className + "]:", foundBundles);
- }
-
- @Descriptor("list all bundles that can load the specified class")
- public void clload(@Descriptor("fully qualified class name") String className) {
- doClload(className, null);
- }
-
- @Descriptor("try to load the specified class using the specified bundle")
- public void clload(@Descriptor("fully qualified class name") String className, @Descriptor("bundle symbolic name") String bundleName) {
- doClload(className, bundleName);
- }
-
- @Descriptor("try to load the specified class using the specified bundle")
- public void clload(@Descriptor("fully qualified class name") String className, @Descriptor(" bundle id") long bundleId) {
- doClload(className, String.valueOf(bundleId));
- }
-
- private void doClload(String className, String bundle) {
- if (extractPackage(className) == null) {
- System.out.println("Warning: the class name [" + className + "] has no package and is assumed to belong to the default package");
- }
-
- Map<Bundle, Bundle> foundBundles;
- if (bundle == null) {
- foundBundles = ClassLoadingHelper.getBundlesLoadingClass(bundleContext, className);
- } else {
- foundBundles = ClassLoadingHelper.getBundlesLoadingClass(bundleContext, className, bundle);
- }
-
- if (foundBundles.size() == 0) {
- if (bundle == null) {
- System.out.println("No bundle can load class [" + className + "]");
- } else {
- System.out.println("Bundle [" + bundle + "] cannot load class [" + className + "]");
- }
- return;
- }
-
- outputFoundBundlesAndRelations("Successfully loaded [" + className + "] " + ((bundle != null) ? "using class loader from:" : "from:"),
- foundBundles, "provided by");
- }
-
- /**
- * Lists all bundles that export a class
- *
- */
- @Descriptor("list all bundles that export a class with the specified name")
- public void clexport(@Descriptor("fully qualified class name") String className) {
- String classPackage = extractPackage(className);
-
- if (classPackage == null) {
- System.out.println("The class name [" + className + "] contains no package");
- return;
- }
-
- Bundle[] bundles = bundleContext.getBundles();
- HashMap<Long, String> foundBundles = new HashMap<Long, String>();
- for (Bundle bundle : bundles) {
- if (ClassLoadingHelper.isPackageExported(bundleContext, classPackage, bundle)) {
- if (ClassLoadingHelper.tryToLoadClass(className, bundle) != null) {
- foundBundles.put(bundle.getBundleId(), bundle.getSymbolicName());
- } else {
- foundBundles.put(bundle.getBundleId(), bundle.getSymbolicName() + " [class not found, package only]");
- }
- }
- }
-
- if (foundBundles.size() == 0) {
- System.out.println("No bundle exports class [" + className + "]");
- return;
- }
-
- System.out.println();
- System.out.println("Bundles exporting [" + className + "]:");
- for (Map.Entry<Long, String> entry : foundBundles.entrySet()) {
- System.out.println(" " + entry.getKey() + "\t" + entry.getValue());
- }
- }
-
- private String extractPackage(String className) {
- int index = className.lastIndexOf(".");
- return index == -1 ? null : className.substring(0, index);
- }
-
- /**
- * Outputs a list with all found bundles
- *
- * @param message Message to print before the list
- * @param foundBundles A map with ID and bundle details
- * @param relation Relation between the bundles
- */
- private void outputFoundBundlesAndRelations(String message, Map<Bundle, Bundle> foundBundles, String relation) {
- System.out.println();
- System.out.println(message);
-
- for (Map.Entry<Bundle, Bundle> entry : foundBundles.entrySet()) {
- Bundle testBundle = entry.getKey();
- Bundle originalBundle = entry.getValue();
- if (testBundle.equals(originalBundle)) {
- System.out.println(" " + bundleToString(testBundle, false));
- } else {
- System.out.println(" " + bundleToString(testBundle, false));
- if (relation != null)
- System.out.println(" \t\t[" + relation + " " + bundleToString(originalBundle, true) + "]");
- }
- }
- }
-
- /**
- * Outputs a list with all found bundles
- *
- * @param message Message to print before the list
- * @param foundBundles A map with Bundle and found resources
- */
- private void outputBundlesAndResources(String message, Map<Bundle, List<String>> foundBundles) {
- System.out.println();
- System.out.println(message);
-
- for (Map.Entry<Bundle, List<String>> bundleListEntry : foundBundles.entrySet()) {
- System.out.println(" " + bundleToString(bundleListEntry.getKey(), false));
-
- for (String resource : bundleListEntry.getValue()) {
- System.out.println(" \t\t" + resource);
- }
- }
- }
-
- /**
- * Provides String representation of a Bundle
- *
- * @param b See {@link org.osgi.framework.Bundle}
- * @param space Separate ID and symbolic name with space instead of tab character
- * @return String containing ID and symbolic name of the bundle
- */
- private String bundleToString(Bundle b, boolean space) {
- return b.getBundleId() + (space ? " " : "\t") + b.getSymbolicName();
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoKernelShellCommand.java b/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoKernelShellCommand.java
deleted file mode 100644
index b040453c..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoKernelShellCommand.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgicommand.internal;
-
-import java.io.IOException;
-
-import org.eclipse.virgo.kernel.shell.CommandExecutor;
-import org.apache.felix.service.command.Descriptor;
-
-/**
- * {@link GogoKernelShellCommand} binds the vsh commands to the Gogo shell.
- * <p />
- * Thread safe.
- */
-public final class GogoKernelShellCommand {
-
- /*
- * The following operations must be listed in
- * org.eclipse.virgo.kernel.osgicommand.Activator#KERNEL_SHELL_SUBCOMMANDS.
- */
- private static final String BUNDLE_OP = "bundle";
-
- private static final String CONFIG_OP = "config";
-
- private static final String PACKAGE_OP = "package";
-
- private static final String PAR_OP = "par";
-
- private static final String PLAN_OP = "plan";
-
- private static final String SERVICE_OP = "service";
-
- private static final String INSTALL_OP = "install";
-
- private static final String SHUTDOWN_OP = "shutdown";
-
- private static final String NULL_STRING = "";
-
- private static final String SPACE = " ";
-
- private final CommandExecutor commandExecutor;
-
- public GogoKernelShellCommand(CommandExecutor commandExecutor) {
- this.commandExecutor = commandExecutor;
- }
-
- /*
- * Bundle commands
- */
-
- @Descriptor("list bundle artifacts")
- public void bundle(@Descriptor("operation (list)") String op) {
- doBundle(op, NULL_STRING);
- }
-
- @Descriptor("examine or manage a bundle artifact")
- public void bundle(@Descriptor("operation (examine|diag|headers|start|stop|refresh|uninstall)") String op,
- @Descriptor("bundle symbolic name") String bsn, @Descriptor("bundle version") String bv) {
- doBundle(op, bsn + SPACE + bv);
- }
-
- @Descriptor("examine or manage a bundle artifact")
- public void bundle(@Descriptor("operation (examine|diag|headers|start|stop|refresh|uninstall)") String op,
- @Descriptor(" bundle id") long bundleId) {
- doBundle(op, String.valueOf(bundleId));
- }
-
- public void doBundle(String op, String argList) {
- doOp(BUNDLE_OP, op, argList);
-
- }
-
- /*
- * Configuration commands
- */
-
- @Descriptor("list configuration artifacts")
- public void config(@Descriptor("operation (list)") String op) {
- doConfig(op, NULL_STRING);
- }
-
- @Descriptor("examine or manage a configuration artifact")
- public void config(@Descriptor("operation (examine|start|stop|refresh|uninstall)") String op, @Descriptor("configuration name") String configName) {
- doConfig(op, configName);
- }
-
- @Descriptor("examine or manage a configuration artifact")
- public void config(@Descriptor("operation (examine|start|stop|refresh|uninstall)") String op,
- @Descriptor("configuration name") String configName, @Descriptor("configuration version") String configVersion) {
- doConfig(op, configName + SPACE + configVersion);
- }
-
- public void doConfig(String op, String argList) {
- doOp(CONFIG_OP, op, argList);
-
- }
-
- /*
- * Package commands - renamed to "packages" to avoid clash with Java keyword
- */
-
- @Descriptor("list exported packages")
- public void packages(@Descriptor("operation (list)") String op) {
- doPackage(op, NULL_STRING);
- }
-
- @Descriptor("examine an exported package")
- public void packages(@Descriptor("operation (examine)") String op, @Descriptor("package name") String packageName,
- @Descriptor("package version") String packageVersion) {
- doPackage(op, packageName + SPACE + packageVersion);
- }
-
- public void doPackage(String op, String argList) {
- doOp(PACKAGE_OP, op, argList);
-
- }
-
- /*
- * Par commands
- */
-
- @Descriptor("list PAR artifacts")
- public void par(@Descriptor("operation (list)") String op) {
- doPar(op, NULL_STRING);
- }
-
- @Descriptor("examine or manage a PAR artifact")
- public void par(@Descriptor("operation (examine|start|stop|refresh|uninstall)") String op, @Descriptor("PAR name") String parName,
- @Descriptor("PAR version") String parVersion) {
- doPar(op, parName + SPACE + parVersion);
- }
-
- public void doPar(String op, String argList) {
- doOp(PAR_OP, op, argList);
-
- }
-
- /*
- * Plan commands
- */
-
- @Descriptor("list plan artifacts")
- public void plan(@Descriptor("operation (list)") String op) {
- doPlan(op, NULL_STRING);
- }
-
- @Descriptor("examine or manage a plan artifact")
- public void plan(@Descriptor("operation (examine|start|stop|refresh|uninstall)") String op, @Descriptor("plan name") String planName,
- @Descriptor("plan version") String planVersion) {
- doPlan(op, planName + SPACE + planVersion);
- }
-
- public void doPlan(String op, String argList) {
- doOp(PLAN_OP, op, argList);
-
- }
-
- /*
- * Service commands
- */
-
- @Descriptor("list all services in the service registry")
- public void service(@Descriptor("operation (list)") String op) {
- doService(op, NULL_STRING);
- }
-
- @Descriptor("examine a service in the service registry")
- public void service(@Descriptor("operation (examine)") String op, @Descriptor(" service id") long serviceId) {
- doService(op, String.valueOf(serviceId));
- }
-
- public void doService(String op, String argList) {
- doOp(SERVICE_OP, op, argList);
-
- }
-
- /*
- * Install command
- */
-
- @Descriptor("install (deploy) an artifact")
- public void install(@Descriptor("artifact URI") String configName) {
- doOp(INSTALL_OP, configName);
- }
-
- /*
- * Shutdown command
- */
-
- @Descriptor("shut down the kernel")
- public void shutdown() {
- doOp(SHUTDOWN_OP, "");
- }
-
- /*
- * Helper methods
- */
-
- private void doOp(String mainOp, String subOp, String argList) {
- String args = concatArgs(mainOp, subOp, argList);
- try {
- boolean continueCommands = this.commandExecutor.execute(args, new GogoLinePrinter());
- if (!continueCommands) {
- System.out.println("vsh: command '" + args + "' requested exit");
- }
- } catch (IOException e) {
- System.out.println("vsh: command '" + args + "' threw an exception...");
- e.printStackTrace(System.out);
- }
- }
-
- private void doOp(String op, String argList) {
- String args = concatArgs(op, argList);
- try {
- boolean continueCommands = this.commandExecutor.execute(args, new GogoLinePrinter());
- if (!continueCommands) {
- System.out.println("vsh: command '" + args + "' requested exit");
- }
- } catch (IOException e) {
- System.out.println("vsh: command '" + args + "' threw an exception...");
- e.printStackTrace(System.out);
- }
- }
-
- private String concatArgs(String cmd, String... args) {
- StringBuffer result = new StringBuffer(cmd).append(SPACE);
- for (String arg : args) {
- result.append(arg).append(SPACE);
- }
- return result.toString();
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoLinePrinter.java b/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoLinePrinter.java
deleted file mode 100644
index 4abb31e0..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoLinePrinter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 VMware Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgicommand.internal;
-
-
-import java.io.IOException;
-
-import org.eclipse.virgo.kernel.shell.LinePrinter;
-
-/**
- * {@link GogoLinePrinter} is an implementation of the Virgo shell {@link LinePrinter} for use with Gogo.
- * <p />
- *
- * <strong>Concurrent Semantics</strong><br />
- * Thread safe.
- */
-final class GogoLinePrinter implements LinePrinter {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public LinePrinter println(String line) throws IOException {
- System.out.println(line);
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public LinePrinter println() throws IOException {
- System.out.println();
- return null;
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupport.java b/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupport.java
deleted file mode 100644
index 6b276bd8..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupport.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Hristo Iliev, SAP AG - initial contribution
- ******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgicommand.management;
-
-import org.eclipse.virgo.kernel.osgicommand.helper.ClassLoadingHelper;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-import java.util.*;
-
-/**
- * MBean for class loading queries
- */
-public class ClassLoadingSupport implements ClassLoadingSupportMBean {
-
- private BundleContext bundleContext;
-
- public ClassLoadingSupport(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- @Override
- public Map<List<String>, List<String>> getBundlesContainingResource(String resourcePattern) {
- Map<Bundle, List<String>> resources = ClassLoadingHelper.getBundlesContainingResource(this.bundleContext, resourcePattern);
-
- Map<List<String>, List<String>> result = new HashMap<List<String>, List<String>>();
-
- for (Map.Entry<Bundle, List<String>> entry: resources.entrySet()) {
- result.put(getBundleInformation(entry.getKey()), entry.getValue());
- }
-
- return result;
- }
-
- @Override
- public Map<List<String>, List<String>> getBundlesLoadingClass(String className) {
- Map<Bundle, Bundle> bundles = ClassLoadingHelper.getBundlesLoadingClass(this.bundleContext, className);
-
- Map<List<String>, List<String>> result = new HashMap<List<String>, List<String>>();
-
- for (Map.Entry<Bundle, Bundle> entry : bundles.entrySet()) {
- Bundle loadingBundle = entry.getKey();
- Bundle originatingBundle = entry.getKey();
- result.put(getBundleInformation(loadingBundle), getBundleInformation(originatingBundle));
- }
-
- return result;
- }
-
- @Override
- public List<List<String>> getBundlesExportingPackage(String packageName) {
- Bundle[] allBundles = this.bundleContext.getBundles();
-
- List<List<String>> result = new ArrayList<List<String>>();
-
- for (Bundle bundle : allBundles) {
- if (ClassLoadingHelper.isPackageExported(this.bundleContext, packageName, bundle)) {
- result.add(getBundleInformation(bundle));
- }
- }
-
- return result;
- }
-
- @Override
- public boolean tryToLoadClassFromBundle(String className, long bundleId) {
- Class<?> result = ClassLoadingHelper.tryToLoadClass(className, this.bundleContext.getBundle(bundleId));
- return result != null;
- }
-
- /**
- * Builds bundle information (ID, symbolic name) to a collection
- *
- * @param bundle Bundle to obtain information for. If <code>null</code>, then the collection will be filled
- * with null elements
- * @return List with bundle information as string or <code>null</code> if the bundle is <code>null</code>
- */
- private List<String> getBundleInformation(Bundle bundle) {
- List<String> list = new ArrayList<String>(2);
-
- list.add(bundle != null ? "" + bundle.getBundleId() : null);
- list.add(bundle != null ? bundle.getSymbolicName() : null);
-
- return list;
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportMBean.java b/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportMBean.java
deleted file mode 100644
index d7e43781..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/main/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportMBean.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Hristo Iliev, SAP AG - initial contribution
- ******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgicommand.management;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * mBean interface for class loading queries
- */
-public interface ClassLoadingSupportMBean {
-
- /**
- * Returns list with all bundles that can load a class and the origin bundle
- *
- * @param resourcePattern Resource pattern (package.class) to search for. The pattern may contain wildcard (*)
- * @return Mapping between the bundle that contains the resource (possibly provided by fragment bundle) and the
- * resource URLs found in the bundle. The bundle information list contain the bundle ID and
- * symbolic name.
- */
- Map<List<String>, List<String>> getBundlesContainingResource(String resourcePattern);
-
- /**
- * Returns list with all bundles that can load a class and the origin bundle
- *
- * @param className Fully qualified class name (package.class) to load
- * @return Mapping between the bundle that can load the class (possibly delegating to another bundle) and the
- * origin bundle that actually performs the loading. The bundle information list contain the bundle ID and
- * symbolic name.
- */
- Map<List<String>, List<String>> getBundlesLoadingClass(String className);
-
- /**
- * Returns list with all bundles that export a package
- *
- * @param packageName Package to scan for
- * @return List with information (ID and symbolic name) about the bundles that export the package
- */
- List<List<String>> getBundlesExportingPackage(String packageName);
-
- /**
- * Tries to load a class from bundle
- *
- * @param className Fully qualified class name (package.class) to load
- * @param bundleId Bundle ID of the bundle, which loader will be used to load the class
- * @return <code>true</code> if the class can be loaded, <code>false</code> if the class cannot be loaded with the
- * bundle's loader
- */
- public boolean tryToLoadClassFromBundle(String className, long bundleId);
-}
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/main/resources/.gitignore b/org.eclipse.virgo.kernel.osgicommand/src/main/resources/.gitignore
deleted file mode 100644
index e69de29b..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/main/resources/.gitignore
+++ /dev/null
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/helper/ClassLoadingHelperTests.java b/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/helper/ClassLoadingHelperTests.java
deleted file mode 100644
index 2a25e195..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/helper/ClassLoadingHelperTests.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 SAP AG
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Hristo Iliev, SAP AG - initial contribution
- ******************************************************************************/
-package org.eclipse.virgo.kernel.osgicommand.helper;
-
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.osgi.service.resolver.ExportPackageDescription;
-import org.eclipse.osgi.service.resolver.PlatformAdmin;
-import org.eclipse.osgi.service.resolver.State;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-/**
- * Class for unit testing {@link ClassLoadingHelper}
- */
-@SuppressWarnings("deprecation")
-public class ClassLoadingHelperTests {
-
- private static final long BUNDLE_ID = 1234;
- private static final String BUNDLE_SYMBOLIC_NAME = "test";
- private static final String CLASS_NAME = ClassLoadingHelperTests.class.getName();
- private static final String CLASS_NAME_PATH = CLASS_NAME.replace(".", "/") + ".class";
- private static final String CLASS_PACKAGE = ClassLoadingHelperTests.class.getPackage().getName();
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Test
- public void testIsMissingPackageExported() throws Exception {
- PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- State bundleState = createMock(State.class);
- BundleDescription bundleDescription = createMock(BundleDescription.class);
-
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID);
- expect(bundleContext.getServiceReference(PlatformAdmin.class)).andReturn(platformAdminServiceReference);
- expect(bundleContext.getService(platformAdminServiceReference)).andReturn(platformAdmin);
- expect(bundleDescription.getSelectedExports()).andReturn(new ExportPackageDescription[0]);
- expect(platformAdmin.getState(false)).andReturn(bundleState);
- expect(bundleState.getBundle(BUNDLE_ID)).andReturn(bundleDescription);
-
- replay(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription);
-
- assertFalse("Class [" + CLASS_NAME + "] is reported as exported, while it is NOT",
- ClassLoadingHelper.isPackageExported(bundleContext, CLASS_NAME, bundle));
-
- verify(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription);
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Test
- public void testIsExistingPackageExported() throws Exception {
- PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- State bundleState = createMock(State.class);
- BundleDescription bundleDescription = createMock(BundleDescription.class);
- ExportPackageDescription exportPackageDescription = createMock(ExportPackageDescription.class);
-
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID);
- expect(bundleContext.getServiceReference(PlatformAdmin.class)).andReturn(platformAdminServiceReference);
- expect(bundleContext.getService(platformAdminServiceReference)).andReturn(platformAdmin);
- expect(exportPackageDescription.getName()).andReturn(CLASS_PACKAGE);
- expect(bundleDescription.getSelectedExports()).andReturn(new ExportPackageDescription[]{exportPackageDescription});
- expect(platformAdmin.getState(false)).andReturn(bundleState);
- expect(bundleState.getBundle(BUNDLE_ID)).andReturn(bundleDescription);
-
- replay(platformAdmin, platformAdminServiceReference,
- bundle, bundleContext, bundleState, bundleDescription,
- exportPackageDescription);
-
- assertTrue("Class [" + CLASS_NAME + "] is reported as NOT exported, while it is",
- ClassLoadingHelper.isPackageExported(bundleContext, CLASS_PACKAGE, bundle));
-
- verify(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription);
- }
-
- @Test
- public void testTryToLoadMissingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
-
- expect(bundle.loadClass(CLASS_NAME)).andReturn(null); // missing class
-
- replay(bundle);
-
- assertNull("Class [" + CLASS_NAME + "] found, while it is not existing",
- ClassLoadingHelper.tryToLoadClass(CLASS_NAME, bundle));
-
- verify(bundle);
- }
-
- @Test
- public void testTryToLoadMissingBundle() throws Exception {
- assertNull("Class [" + CLASS_NAME + "] found, while no bundle is specified",
- ClassLoadingHelper.tryToLoadClass(CLASS_NAME, null));
- }
-
- @Test
- public void testTryToLoadMissingClassWithException() throws Exception {
- Bundle bundle = createMock(Bundle.class);
-
- expect(bundle.loadClass(CLASS_NAME)).andThrow(new ClassNotFoundException("not found")); // missing class
-
- replay(bundle);
-
- assertNull("Class [" + CLASS_NAME + "] found, while it is not existing",
- ClassLoadingHelper.tryToLoadClass(CLASS_NAME, bundle));
-
- verify(bundle);
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testTryToLoadExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
-
- expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(ClassLoadingHelperTests.class);
-
- replay(bundle);
-
- assertNotNull("Class [" + CLASS_NAME + "] not found",
- ClassLoadingHelper.tryToLoadClass(CLASS_NAME, bundle));
-
- verify(bundle);
- }
-
- @Test
- public void testGetBundlesLoadingMissingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
-
- expect(bundle.loadClass(CLASS_NAME)).andReturn(null); // missing class
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
-
- replay(bundle, bundleContext);
-
- assertTrue("The bundle [" + BUNDLE_SYMBOLIC_NAME + "] should NOT be able to load class [" + CLASS_NAME + "]",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME).size() == 0);
-
- verify(bundle, bundleContext);
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testGetBundlesLoadingExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
-
- expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(ClassLoadingHelperTests.class);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
- expect(bundleContext.getBundle(0)).andReturn(bundle);
-
- replay(bundle, bundleContext);
-
- assertFalse("The bundle [" + BUNDLE_SYMBOLIC_NAME + "] should be able to load class [" + CLASS_NAME + "]",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME).size() == 0);
-
- verify(bundle, bundleContext);
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Test
- public void testGetBundleLoadingMissingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- PackageAdmin packageAdmin = createMock(PackageAdmin.class);
- ServiceReference packageAdminServiceReference = createMock(ServiceReference.class);
-
- expect(bundle.loadClass(CLASS_NAME)).andReturn(null); // missing class
- expect(bundleContext.getServiceReference(PackageAdmin.class)).andReturn(packageAdminServiceReference);
- expect(bundleContext.getService(packageAdminServiceReference)).andReturn(packageAdmin);
- expect(packageAdmin.getBundles(BUNDLE_SYMBOLIC_NAME, null)).andReturn(new Bundle[]{bundle});
-
- replay(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
-
- assertTrue("No bundle should be able to load class [" + CLASS_NAME + "]",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, BUNDLE_SYMBOLIC_NAME).size() == 0);
-
- verify(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Test
- public void testGetBundleByNameLoadingExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- PackageAdmin packageAdmin = createMock(PackageAdmin.class);
- ServiceReference packageAdminServiceReference = createMock(ServiceReference.class);
-
- expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(ClassLoadingHelperTests.class);
- expect(bundleContext.getBundle(0)).andReturn(bundle);
- expect(bundleContext.getServiceReference(PackageAdmin.class)).andReturn(packageAdminServiceReference);
- expect(bundleContext.getService(packageAdminServiceReference)).andReturn(packageAdmin);
- expect(packageAdmin.getBundles(BUNDLE_SYMBOLIC_NAME, null)).andReturn(new Bundle[]{bundle});
-
- replay(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
-
- assertTrue("The class [" + CLASS_NAME + "] should be successfully loaded",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, BUNDLE_SYMBOLIC_NAME).size() != 0);
-
- verify(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testGetBundleByIdLoadingExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
-
- expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(ClassLoadingHelperTests.class);
- expect(bundleContext.getBundle(BUNDLE_ID)).andReturn(bundle);
- expect(bundleContext.getBundle(0)).andReturn(bundle);
-
- replay(bundle, bundleContext);
-
- assertTrue("The class [" + CLASS_NAME + "] should be successfully loaded",
- ClassLoadingHelper.getBundlesLoadingClass(bundleContext, CLASS_NAME, "" + BUNDLE_ID).size() != 0);
-
- verify(bundle, bundleContext);
- }
-
- @Test
- public void testConvertToClassName() throws Exception {
- assertEquals("Path to resource [" + CLASS_NAME_PATH + "] not converted properly", CLASS_NAME, ClassLoadingHelper.convertToClassName(CLASS_NAME_PATH));
- assertEquals("Path to resource [" + CLASS_NAME + "] not converted properly", CLASS_NAME, ClassLoadingHelper.convertToClassName(CLASS_NAME));
- }
-
- @Test
- public void testConvertToResourcePath() throws Exception {
- assertEquals("Class name [" + CLASS_NAME + "] not converted properly", CLASS_NAME_PATH, ClassLoadingHelper.convertToResourcePath(CLASS_NAME));
- assertEquals("Class name [" + CLASS_NAME_PATH + "] not converted properly", CLASS_NAME_PATH, ClassLoadingHelper.convertToResourcePath(CLASS_NAME_PATH));
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoClassLoadingCommandTests.java b/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoClassLoadingCommandTests.java
deleted file mode 100644
index a232ec18..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/internal/GogoClassLoadingCommandTests.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 SAP AG
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Hristo Iliev, SAP AG - initial contribution
- ******************************************************************************/
-package org.eclipse.virgo.kernel.osgicommand.internal;
-
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.osgi.service.resolver.ExportPackageDescription;
-import org.eclipse.osgi.service.resolver.PlatformAdmin;
-import org.eclipse.osgi.service.resolver.State;
-import org.eclipse.virgo.kernel.osgicommand.internal.GogoClassLoadingCommand;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.net.URL;
-import java.util.Enumeration;
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Unit tests for class loading commands
- */
-@SuppressWarnings("deprecation")
-public class GogoClassLoadingCommandTests {
-
- private static final long BUNDLE_ID = 1234;
- private static final String BUNDLE_SYMBOLIC_NAME = "test";
-
- private static final String CLASS_NAME = GogoClassLoadingCommandTests.class.getName();
- private static final String CLASS_PACKAGE = GogoClassLoadingCommandTests.class.getPackage().getName();
-
- private static final String SHORT_CLASS_NAME = CLASS_NAME.substring(CLASS_NAME.lastIndexOf(".") + 1) + ".class";
- private static final String CLASS_NAME_PATH = CLASS_NAME.replace(".", "/") + ".class";
- private static final String CLASS_PACKAGE_PATH = CLASS_PACKAGE.replace(".", "/");
- private ByteArrayOutputStream baos;
- private PrintStream oldOut;
- private PrintStream output;
-
- @Before
- public void before() {
- this.oldOut = System.out;
- this.baos = new ByteArrayOutputStream();
- this.output = new PrintStream(baos);
- System.setOut(this.output);
- }
-
- private String getOutput() {
- this.output.flush();
- String output = new String(baos.toByteArray());
- return output;
- }
-
- @After
- public void after() {
- System.setOut(this.oldOut);
- }
-
- @Test
- public void testClHasWithExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- Enumeration<URL> urlEnum = this.getClass().getClassLoader().getResources(CLASS_NAME_PATH);
-
- expect(bundle.findEntries("/", SHORT_CLASS_NAME, true)).andReturn(urlEnum);
- expect(bundle.findEntries("/", CLASS_NAME_PATH, true)).andReturn(null); // class not found in root
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID);
- expect(bundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
-
- replay(bundle, bundleContext);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clhas(CLASS_NAME);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME_PATH));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE_PATH + "]",
- output.contains("" + CLASS_PACKAGE_PATH));
- assertTrue("Command output [" + output + "] does not contain bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertTrue("Command output [" + output + "] does not contain bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(bundle, bundleContext);
-
- }
-
- @Test
- public void testClHasWithNonExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
-
- expect(bundle.findEntries("/", SHORT_CLASS_NAME, true)).andReturn(null); // class does not exist
- expect(bundle.findEntries("/", CLASS_NAME_PATH, true)).andReturn(null); // class does not exist
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
-
- replay(bundle, bundleContext);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clhas(CLASS_NAME);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME_PATH));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
- output.contains("" + CLASS_PACKAGE_PATH));
- assertFalse("Command output [" + output + "] contains bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertFalse("Command output [" + output + "] contains bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(bundle, bundleContext);
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testClLoadWithExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
-
- expect((Class)bundle.loadClass(CLASS_NAME)).andReturn(GogoClassLoadingCommandTests.class);
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID);
- expect(bundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
- expect(bundleContext.getBundle(0)).andReturn(bundle); // system bundle is also our mockup
-
- replay(bundle, bundleContext);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clload(CLASS_NAME);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
- output.contains("" + CLASS_PACKAGE));
- assertTrue("Command output [" + output + "] does not contain bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertTrue("Command output [" + output + "] does not contain bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(bundle, bundleContext);
- }
-
- @Test
- public void testClLoadWithNonExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
-
- expect(bundle.loadClass(CLASS_NAME)).andReturn(null);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
-
- replay(bundle, bundleContext);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clload(CLASS_NAME);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
- output.contains("" + CLASS_PACKAGE));
- assertFalse("Command output [" + output + "] contains bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertFalse("Command output [" + output + "] contains bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(bundle, bundleContext);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testClLoadWithBundleNameAndExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- PackageAdmin packageAdmin = createMock(PackageAdmin.class);
- ServiceReference packageAdminServiceReference = createMock(ServiceReference.class);
-
- expect((Class)bundle.loadClass(CLASS_NAME)).andReturn(GogoClassLoadingCommandTests.class);
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID);
- expect(bundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME);
- expect(bundleContext.getBundle(0)).andReturn(bundle); // system bundle is also our mockup
- expect(bundleContext.getServiceReference(PackageAdmin.class)).andReturn(packageAdminServiceReference);
- expect(bundleContext.getService(packageAdminServiceReference)).andReturn(packageAdmin);
- expect(packageAdmin.getBundles(BUNDLE_SYMBOLIC_NAME, null)).andReturn(new Bundle[]{bundle});
-
- replay(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clload(CLASS_NAME, BUNDLE_SYMBOLIC_NAME);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
- output.contains("" + CLASS_PACKAGE));
- assertTrue("Command output [" + output + "] does not contain bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertTrue("Command output [" + output + "] does not contain bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(bundle, bundleContext, packageAdmin, packageAdminServiceReference);
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testClLoadWithBundleIdAndExistingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
-
- expect((Class)bundle.loadClass(CLASS_NAME)).andReturn(GogoClassLoadingCommandTests.class);
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID);
- expect(bundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME);
- expect(bundleContext.getBundle(0)).andReturn(bundle); // system bundle is also our mockup
- expect(bundleContext.getBundle(BUNDLE_ID)).andReturn(bundle);
-
- replay(bundle, bundleContext);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clload(CLASS_NAME, BUNDLE_ID);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
- output.contains("" + CLASS_PACKAGE));
- assertTrue("Command output [" + output + "] does not contain bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertTrue("Command output [" + output + "] does not contain bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(bundle, bundleContext);
- }
-
- @Test
- public void testClLoadWithBundleIdAndMissingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
-
- expect(bundle.loadClass(CLASS_NAME)).andReturn(null);
- expect(bundleContext.getBundle(BUNDLE_ID)).andReturn(bundle);
-
- replay(bundle, bundleContext);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clload(CLASS_NAME, BUNDLE_ID);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
- output.contains("" + CLASS_PACKAGE));
- assertTrue("Command output [" + output + "] does not contain bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertFalse("Command output [" + output + "] contains bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(bundle, bundleContext);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testClExportWithMissingPackage() throws Exception {
- PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- State bundleState = createMock(State.class);
- BundleDescription bundleDescription = createMock(BundleDescription.class);
-
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID);
- expect(bundleContext.getServiceReference(PlatformAdmin.class)).andReturn(platformAdminServiceReference);
- expect(bundleContext.getService(platformAdminServiceReference)).andReturn(platformAdmin);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
- expect(bundleDescription.getSelectedExports()).andReturn(new ExportPackageDescription[]{}); // nothing exported
- expect(platformAdmin.getState(false)).andReturn(bundleState);
- expect(bundleState.getBundle(BUNDLE_ID)).andReturn(bundleDescription);
-
- replay(platformAdmin, platformAdminServiceReference,
- bundle, bundleContext, bundleState, bundleDescription);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clexport(CLASS_NAME);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
- output.contains("" + CLASS_PACKAGE));
- assertFalse("Command output [" + output + "] contains bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertFalse("Command output [" + output + "] contains bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(platformAdmin, platformAdminServiceReference,
- bundle, bundleContext, bundleState, bundleDescription);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testClExportWithExportedPackage() throws Exception {
- PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- State bundleState = createMock(State.class);
- BundleDescription bundleDescription = createMock(BundleDescription.class);
- ExportPackageDescription exportPackageDescription = createMock(ExportPackageDescription.class);
-
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID).times(2);
- expect(bundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME);
- expect((Class)bundle.loadClass(CLASS_NAME)).andReturn(GogoClassLoadingCommandTests.class);
- expect(bundleContext.getServiceReference(PlatformAdmin.class)).andReturn(platformAdminServiceReference);
- expect(bundleContext.getService(platformAdminServiceReference)).andReturn(platformAdmin);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
- expect(exportPackageDescription.getName()).andReturn(CLASS_PACKAGE);
- expect(bundleDescription.getSelectedExports()).andReturn(new ExportPackageDescription[]{exportPackageDescription});
- expect(platformAdmin.getState(false)).andReturn(bundleState);
- expect(bundleState.getBundle(BUNDLE_ID)).andReturn(bundleDescription);
-
- replay(platformAdmin, platformAdminServiceReference,
- bundle, bundleContext, bundleState, bundleDescription,
- exportPackageDescription);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clexport(CLASS_NAME);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
- output.contains("" + CLASS_PACKAGE));
- assertTrue("Command output [" + output + "] does not contain bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertTrue("Command output [" + output + "] does not contain bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(platformAdmin, platformAdminServiceReference,
- bundle, bundleContext, bundleState, bundleDescription,
- exportPackageDescription);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Test
- public void testClExportWithExportedPackageMissingClass() throws Exception {
- PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- ServiceReference platformAdminServiceReference = createMock(ServiceReference.class);
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- State bundleState = createMock(State.class);
- BundleDescription bundleDescription = createMock(BundleDescription.class);
- ExportPackageDescription exportPackageDescription = createMock(ExportPackageDescription.class);
-
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID).times(2);
- expect(bundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME);
- expect(bundle.loadClass(CLASS_NAME)).andReturn(null); // class cannot be loaded
- expect(bundleContext.getServiceReference(PlatformAdmin.class)).andReturn(platformAdminServiceReference);
- expect(bundleContext.getService(platformAdminServiceReference)).andReturn(platformAdmin);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
- expect(exportPackageDescription.getName()).andReturn(CLASS_PACKAGE);
- expect(bundleDescription.getSelectedExports()).andReturn(new ExportPackageDescription[]{exportPackageDescription});
- expect(platformAdmin.getState(false)).andReturn(bundleState);
- expect(bundleState.getBundle(BUNDLE_ID)).andReturn(bundleDescription);
-
- replay(platformAdmin, platformAdminServiceReference,
- bundle, bundleContext, bundleState, bundleDescription,
- exportPackageDescription);
-
- GogoClassLoadingCommand command = new GogoClassLoadingCommand(bundleContext);
- command.clexport(CLASS_NAME);
- String output = getOutput();
-
- assertTrue("Command output [" + output + "] does not contain class name [" + CLASS_NAME + "]",
- output.contains("" + CLASS_NAME));
- assertTrue("Command output [" + output + "] does not contain class package [" + CLASS_PACKAGE + "]",
- output.contains("" + CLASS_PACKAGE));
- assertTrue("Command output [" + output + "] does not contain bundle ID [" + BUNDLE_ID + "]",
- output.contains("" + BUNDLE_ID));
- assertTrue("Command output [" + output + "] does not contain bundle symbolic name [" + BUNDLE_SYMBOLIC_NAME + "]",
- output.contains(BUNDLE_SYMBOLIC_NAME));
-
- verify(platformAdmin, platformAdminServiceReference,
- bundle, bundleContext, bundleState, bundleDescription,
- exportPackageDescription);
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportTests.java b/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportTests.java
deleted file mode 100644
index 42e9a7a2..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/test/java/org/eclipse/virgo/kernel/osgicommand/management/ClassLoadingSupportTests.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Hristo Iliev, SAP AG - initial contribution
- ******************************************************************************/
-
-package org.eclipse.virgo.kernel.osgicommand.management;
-
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.osgi.service.resolver.ExportPackageDescription;
-import org.eclipse.osgi.service.resolver.PlatformAdmin;
-import org.eclipse.osgi.service.resolver.State;
-import org.eclipse.virgo.kernel.osgicommand.helper.ClassLoadingHelperTests;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-import java.net.URL;
-import java.util.*;
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link ClassLoadingSupport}
- *
- */
-public class ClassLoadingSupportTests {
-
- private static final long BUNDLE_ID = 1234;
- private static final String BUNDLE_SYMBOLIC_NAME = "test";
-
- private static final String CLASS_NAME = ClassLoadingSupportTests.class.getName();
- private static final String CLASS_PACKAGE = ClassLoadingSupportTests.class.getPackage().getName();
-
- private static final String SHORT_CLASS_NAME = CLASS_NAME.substring(CLASS_NAME.lastIndexOf(".") + 1) + ".class";
- private static final String CLASS_NAME_PATH = CLASS_NAME.replace(".", "/") + ".class";
-
- private static final Map<List<String>, List<String>> RESULT_ORIGIN_LOAD_MAP = new HashMap<List<String>, List<String>>(2);
- private static final List<List<String>> RESULT_EXPORT_ARRAY = new ArrayList<List<String>>(1);
-
- static {
- List<String> loadingBundle = new ArrayList<String>();
- loadingBundle.add("" + BUNDLE_ID);
- loadingBundle.add(BUNDLE_SYMBOLIC_NAME);
-
- List<String> originBundle = new ArrayList<String>();
- originBundle.add("" + BUNDLE_ID);
- originBundle.add(BUNDLE_SYMBOLIC_NAME);
-
- RESULT_ORIGIN_LOAD_MAP.put(loadingBundle, originBundle);
- RESULT_EXPORT_ARRAY.add(loadingBundle);
- }
-
- @Test
- public void testGetBundlesContainingResource() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- Enumeration<URL> urlEnum = this.getClass().getClassLoader().getResources(CLASS_NAME_PATH);
-
- expect(bundle.findEntries("/", SHORT_CLASS_NAME, true)).andReturn(urlEnum);
- expect(bundle.findEntries("/", CLASS_NAME_PATH, true)).andReturn(null); // not found in the root
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID);
- expect(bundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
-
- replay(bundle, bundleContext);
-
- ClassLoadingSupport support = new ClassLoadingSupport(bundleContext);
-
- Map<List<String>, List<String>> map = support.getBundlesContainingResource(CLASS_NAME_PATH);
- assertEquals("More than one test URL found in the result " + map, 1, map.size());
- assertTrue("Test URL not found in the result: " + map, map.toString().contains(CLASS_NAME_PATH));
-
- verify(bundle, bundleContext);
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testGetBundlesLoadingClass() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
-
- expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(ClassLoadingHelperTests.class);
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID).times(2);
- expect(bundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME).times(2);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
- expect(bundleContext.getBundle(0)).andReturn(bundle);
-
- replay(bundle, bundleContext);
-
- ClassLoadingSupport support = new ClassLoadingSupport(bundleContext);
-
- Map<List<String>, List<String>> map = support.getBundlesLoadingClass(CLASS_NAME);
- assertEquals("Unexpected result length for map " + map, RESULT_ORIGIN_LOAD_MAP.size(), map.size());
- assertEquals("Unexpected result array: " + map, RESULT_ORIGIN_LOAD_MAP, map);
-
- verify(bundle, bundleContext);
- }
-
- @Test
- public void testGetBundlesExportingPackage() throws Exception {
- PlatformAdmin platformAdmin = createMock(PlatformAdmin.class);
- @SuppressWarnings("unchecked")
- ServiceReference<PlatformAdmin> platformAdminServiceReference = createMock(ServiceReference.class);
- Bundle bundle = createMock(Bundle.class);
- BundleContext bundleContext = createMock(BundleContext.class);
- State bundleState = createMock(State.class);
- BundleDescription bundleDescription = createMock(BundleDescription.class);
- ExportPackageDescription exportPackageDescription = createMock(ExportPackageDescription.class);
-
- expect(bundle.getBundleId()).andReturn(BUNDLE_ID).times(2);
- expect(bundle.getSymbolicName()).andReturn(BUNDLE_SYMBOLIC_NAME);
- expect(bundleContext.getServiceReference(PlatformAdmin.class)).andReturn(platformAdminServiceReference);
- expect(bundleContext.getService(platformAdminServiceReference)).andReturn(platformAdmin);
- expect(bundleContext.getBundles()).andReturn(new Bundle[]{bundle});
- expect(exportPackageDescription.getName()).andReturn(CLASS_PACKAGE);
- expect(bundleDescription.getSelectedExports()).andReturn(new ExportPackageDescription[]{exportPackageDescription});
- expect(platformAdmin.getState(false)).andReturn(bundleState);
- expect(bundleState.getBundle(BUNDLE_ID)).andReturn(bundleDescription);
-
- replay(platformAdmin, platformAdminServiceReference,
- bundle, bundleContext, bundleState, bundleDescription,
- exportPackageDescription);
-
- ClassLoadingSupport support = new ClassLoadingSupport(bundleContext);
-
- List<List<String>> list = support.getBundlesExportingPackage(CLASS_PACKAGE);
- assertEquals("Unexpected result length for list " + list, RESULT_EXPORT_ARRAY.size(), list.size());
- assertEquals("Unexpected result list " + list, RESULT_EXPORT_ARRAY, list);
-
- verify(platformAdmin, platformAdminServiceReference, bundle, bundleContext, bundleState, bundleDescription);
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void testTryToLoadClassFromBundle() throws Exception {
- Bundle bundle = createMock(Bundle.class);
- expect((Class) bundle.loadClass(CLASS_NAME)).andReturn(ClassLoadingHelperTests.class);
- expect((Class<?>) bundle.loadClass(CLASS_NAME + CLASS_NAME)).andReturn(null);
- BundleContext bundleContext = createMock(BundleContext.class);
- expect(bundleContext.getBundle(BUNDLE_ID)).andReturn(bundle).times(2);
-
- replay(bundle, bundleContext);
-
- ClassLoadingSupport support = new ClassLoadingSupport(bundleContext);
-
- assertTrue("Class [" + CLASS_NAME + "] not found", support.tryToLoadClassFromBundle(CLASS_NAME, BUNDLE_ID));
- assertFalse("Class [" + CLASS_NAME + CLASS_NAME + "] found", support.tryToLoadClassFromBundle(CLASS_NAME + CLASS_NAME, BUNDLE_ID));
-
- verify(bundle, bundleContext);
- }
-}
diff --git a/org.eclipse.virgo.kernel.osgicommand/src/test/resources/.gitignore b/org.eclipse.virgo.kernel.osgicommand/src/test/resources/.gitignore
deleted file mode 100644
index e69de29b..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/src/test/resources/.gitignore
+++ /dev/null
diff --git a/org.eclipse.virgo.kernel.osgicommand/template.mf b/org.eclipse.virgo.kernel.osgicommand/template.mf
deleted file mode 100644
index 8904eb3f..00000000
--- a/org.eclipse.virgo.kernel.osgicommand/template.mf
+++ /dev/null
@@ -1,19 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Virgo Kernel Gogo shell commands
-Bundle-SymbolicName: org.eclipse.virgo.kernel.osgicommand
-Bundle-Version: ${version}
-Import-Template:
- org.eclipse.virgo.kernel.*;version="${version:[=.=.=, =.+1)}",
- org.eclipse.virgo.util.*;version="${org.eclipse.virgo.util:[=.=.=, =.+1)}",
- org.eclipse.osgi.framework.*;version="0",
- org.eclipse.osgi.service.resolver.*;version="0",
- org.apache.felix.service.command;status=provisional;version="${org.apache.felix.gogo.runtime:[=.=.=, =.+1)}",
- org.osgi.framework.*;version="0",
- org.osgi.service.*;version="0",
- javax.management.*;version="0"
-Export-Template:
- org.eclipse.virgo.kernel.osgicommand.helper.*;version="${version}"
-Bundle-Activator: org.eclipse.virgo.kernel.osgicommand.Activator
-Excluded-Imports: org.easymock
-
diff --git a/org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgicommand/helper/test/ClassLoadingHelperIntegrationTests.java b/org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgicommand/helper/test/ClassLoadingHelperIntegrationTests.java
index b9a58f0c..8072e3d3 100644
--- a/org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgicommand/helper/test/ClassLoadingHelperIntegrationTests.java
+++ b/org.eclipse.virgo.kernel.test/src/test/java/org/eclipse/virgo/kernel/osgicommand/helper/test/ClassLoadingHelperIntegrationTests.java
@@ -29,12 +29,12 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
/**
- * Class for integration testing {@link org.eclipse.virgo.kernel.osgicommand.helper.ClassLoadingHelper}
+ * Class for integration testing {@link org.eclipse.virgo.shell.osgicommand.helper.ClassLoadingHelper}
*/
@RunWith(DmKernelTestRunner.class)
public class ClassLoadingHelperIntegrationTests extends AbstractKernelIntegrationTest {
- private static final String SHELL_COMMANDS_BUNDLE_NAME = "org.eclipse.virgo.kernel.osgicommand";
- private static final String CLASSLOADING_PACKAGE = "org.eclipse.virgo.kernel.osgicommand.helper";
+ private static final String SHELL_COMMANDS_BUNDLE_NAME = "org.eclipse.virgo.shell.command";
+ private static final String CLASSLOADING_PACKAGE = "org.eclipse.virgo.shell.osgicommand.helper";
private static final String TEST_CLASS_NAME = ClassLoadingHelperIntegrationTests.class.getName();
private static final String TEST_CLASS_PACKAGE = ClassLoadingHelperIntegrationTests.class.getPackage().getName();
diff --git a/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF b/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF
index c7bfdcd8..bca8d4a6 100644
--- a/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF
+++ b/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/MANIFEST.MF
@@ -21,12 +21,12 @@ Import-Package: javax.management;version="0",org.eclipse.virgo.nano.co
re;version="[3.0.0,4)",org.eclipse.virgo.nano.deployer.api.core;versi
on="[3.0.0,4)",org.eclipse.virgo.kernel.osgi.framework;version="[3.0.
0,4)",org.eclipse.virgo.kernel.osgi.quasi;version="[3.0.0,4)",org.ecl
- ipse.equinox.region;version="1",org.eclipse.virgo.kernel.osgicommand.
- helper;version="[3.0.0,4)",org.eclipse.virgo.util.io;version="[3.0.0,
- 4)",org.eclipse.virgo.util.osgi.manifest;version="[3.0.0,4)",org.juni
- t;version="[4.7.0,5)",org.junit.runner;version="[4.7.0,5)",org.osgi.f
- ramework;version="0",org.springframework.context;version="[2.5.6,4.1)
- ",org.springframework.jmx.export;version="[2.5.6,4.1)",org.eclipse.ge
- mini.blueprint.context.support;version="[1.0.0.RELEASE,1.1)",org.ecli
- pse.gemini.blueprint.service.importer.support;version="[1.0.0.RELEASE
- ,1.1)"
+ ipse.equinox.region;version="1",org.eclipse.virgo.shell.osgicommand.h
+ elper;version="[3.0.0,4)",org.eclipse.virgo.util.io;version="[3.0.0,4
+ )",org.eclipse.virgo.util.osgi.manifest;version="[3.0.0,4)",org.junit
+ ;version="[4.7.0,5)",org.junit.runner;version="[4.7.0,5)",org.osgi.fr
+ amework;version="0",org.springframework.context;version="[2.5.6,4.1)"
+ ,org.springframework.jmx.export;version="[2.5.6,4.1)",org.eclipse.gem
+ ini.blueprint.context.support;version="[1.0.0.RELEASE,1.1)",org.eclip
+ se.gemini.blueprint.service.importer.support;version="[1.0.0.RELEASE,
+ 1.1)"
diff --git a/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties b/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties
index ee563e08..956f93ca 100644
--- a/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties
+++ b/org.eclipse.virgo.kernel.test/src/test/resources/META-INF/test.config.properties
@@ -47,7 +47,6 @@ launcher.bundles =\
file:../org.eclipse.virgo.kernel.deployer/target/classes@start,\
file:../org.eclipse.virgo.kernel.model/target/classes@start,\
file:../org.eclipse.virgo.kernel.kerneldmfragment/target/classes,\
- file:../org.eclipse.virgo.shell.command/target/classes@start,\
file:../org.eclipse.virgo.kernel.osgi/target/classes@start,\
file:../org.eclipse.virgo.kernel.userregionfactory/target/classes@start
diff --git a/org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties b/org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
index 8f57ef44..52177e7e 100644
--- a/org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
+++ b/org.eclipse.virgo.kernel.test/src/test/resources/config/org.eclipse.virgo.kernel.userregion.properties
@@ -32,6 +32,7 @@ packageImports =\
org.eclipse.virgo.kernel.artifact.*;version="0",\
org.eclipse.virgo.nano.core;version="0",\
org.eclipse.virgo.nano.deployer.api.*;version="0",\
+ org.eclipse.virgo.nano.deployer.api;version="0",\
org.eclipse.virgo.kernel.deployer.core.event;version="0",\
org.eclipse.virgo.kernel.install.*;version="0",\
org.eclipse.virgo.kernel.osgi.*;version="0",\
diff --git a/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/ConfigCommandsTests.java b/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/ConfigCommandsTests.java
index cb7ec312..8252bd7b 100644
--- a/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/ConfigCommandsTests.java
+++ b/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/ConfigCommandsTests.java
@@ -24,14 +24,16 @@ import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
-import org.eclipse.virgo.kernel.shell.internal.formatting.StubManageableCompositeArtifact;
+import org.eclipse.virgo.shell.internal.formatting.StubManageableCompositeArtifact;
import org.eclipse.virgo.test.stubs.region.StubRegionDigraph;
-import org.eclipse.virgo.test.stubs.service.cm.StubConfigurationAdmin;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.BundleException;
+import org.eclipse.virgo.shell.internal.commands.ConfigCommands;
+import org.eclipse.virgo.test.stubs.service.cm.StubConfigurationAdmin;
+
public class ConfigCommandsTests {
private static final StubRegionDigraph REGION_DIGRAPH = new StubRegionDigraph();
diff --git a/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java b/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java
index e0b116e6..b290017c 100644
--- a/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java
+++ b/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java
@@ -12,7 +12,9 @@
package org.eclipse.virgo.shell.internal.commands;
import org.eclipse.virgo.kernel.model.management.ManageableCompositeArtifact;
+import org.eclipse.virgo.shell.internal.commands.AbstractInstallArtifactBasedCommands;
import org.eclipse.virgo.test.stubs.region.StubRegionDigraph;
+
import org.osgi.framework.BundleException;
final class StubAbstractCompositeInstallArtifactBasedCommands extends AbstractInstallArtifactBasedCommands<ManageableCompositeArtifact> {
diff --git a/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/completers/ConfigCompleterTests.java b/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/completers/ConfigCompleterTests.java
index 4a2312b4..5df39958 100644
--- a/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/completers/ConfigCompleterTests.java
+++ b/org.eclipse.virgo.shell.command/src/test/java/org/eclipse/virgo/shell/internal/completers/ConfigCompleterTests.java
@@ -22,9 +22,11 @@ import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
-import org.eclipse.virgo.kernel.shell.internal.commands.StubRuntimeArtifactModelObjectNameCreator;
-import org.eclipse.virgo.kernel.shell.internal.formatting.StubManageableCompositeArtifact;
+import org.eclipse.virgo.shell.internal.commands.StubRuntimeArtifactModelObjectNameCreator;
+import org.eclipse.virgo.shell.internal.completers.ConfigCompleter;
+import org.eclipse.virgo.shell.internal.formatting.StubManageableCompositeArtifact;
import org.eclipse.virgo.test.stubs.region.StubRegionDigraph;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

Back to the top