JBoss-OSGI SVN: r97236 - projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-01 09:29:43 -0500 (Tue, 01 Dec 2009)
New Revision: 97236
Modified:
projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java
projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
Log:
Fix NPEs in deployers due to missing Deployment attachment
Modified: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java 2009-12-01 14:23:16 UTC (rev 97235)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleMetaDataDeployer.java 2009-12-01 14:29:43 UTC (rev 97236)
@@ -23,6 +23,7 @@
//$Id$
+import java.net.URL;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -59,7 +60,8 @@
log.debug("Bundle-SymbolicName: " + symbolicName + " in " + file);
Deployment dep = unit.getAttachment(Deployment.class);
- metaData.setBundleLocation(dep.getLocation());
+ URL location = (dep != null ? dep.getLocation() : unit.getRoot().toURL());
+ metaData.setBundleLocation(location);
// Add a marker that this is an OSGi deployment
unit.addAttachment(OSGiConstants.KEY_BUNDLE_SYMBOLIC_NAME, symbolicName);
Modified: projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-12-01 14:23:16 UTC (rev 97235)
+++ projects/jboss-osgi/projects/runtime/deployers/trunk/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-12-01 14:29:43 UTC (rev 97236)
@@ -68,7 +68,7 @@
public void deploy(DeploymentUnit unit, Bundle bundle) throws DeploymentException
{
Deployment dep = unit.getAttachment(Deployment.class);
- boolean autoStart = dep.isAutoStart();
+ boolean autoStart = (dep != null ? dep.isAutoStart() : true);
if (autoStart == true)
{
16 years, 7 months
JBoss-OSGI SVN: r97235 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-12-01 09:23:16 -0500 (Tue, 01 Dec 2009)
New Revision: 97235
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/KernelDictionaryFactory.java
Log:
Dynamic OBJECTCLASS creation.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/KernelDictionaryFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/KernelDictionaryFactory.java 2009-12-01 14:22:49 UTC (rev 97234)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/KernelDictionaryFactory.java 2009-12-01 14:23:16 UTC (rev 97235)
@@ -21,10 +21,15 @@
*/
package org.jboss.osgi.framework.bundle;
+import java.util.Collections;
import java.util.Dictionary;
-import java.util.Hashtable;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.HashSet;
+import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.util.collection.Iterators;
import org.osgi.framework.Constants;
/**
@@ -34,6 +39,8 @@
*/
public class KernelDictionaryFactory implements DictionaryFactory<KernelControllerContext>
{
+ private static final String[] EMPTY = new String[0];
+
public Class<KernelControllerContext> getContextType()
{
return KernelControllerContext.class;
@@ -41,8 +48,97 @@
public Dictionary<String, Object> getDictionary(KernelControllerContext context)
{
- Dictionary<String, Object> table = new Hashtable<String, Object>();
- table.put(Constants.OBJECTCLASS, new String[0]);
- return table;
+ return new KernelDictionary(context);
}
+
+ private static class KernelDictionary extends Dictionary<String, Object>
+ {
+ private KernelControllerContext context;
+ private String[] classes = EMPTY;
+
+ private KernelDictionary(KernelControllerContext context)
+ {
+ this.context = context;
+ }
+
+ public int size()
+ {
+ return 1;
+ }
+
+ public boolean isEmpty()
+ {
+ return size() == 0;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public Enumeration<String> keys()
+ {
+ return Iterators.toEnumeration(Collections.singleton(Constants.OBJECTCLASS).iterator());
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public Enumeration<Object> elements()
+ {
+ return Iterators.toEnumeration(Collections.singleton(classes).iterator());
+ }
+
+ public Object get(Object key)
+ {
+ if (Constants.OBJECTCLASS.equals(key))
+ {
+ if (classes == EMPTY)
+ {
+ Class<?> clazz = null;
+ BeanInfo info = context.getBeanInfo();
+ if (info != null)
+ {
+ clazz = info.getClassInfo().getType();
+ }
+ else if (context.getTarget() != null)
+ {
+ clazz = context.getTarget().getClass();
+ }
+
+ if (clazz != null)
+ {
+ Set<String> clazzes = new HashSet<String>();
+ traverseClass(clazz, clazzes);
+ classes = clazzes.toArray(new String[clazzes.size()]);
+ }
+ }
+ return classes;
+ }
+ return null;
+ }
+
+ public Object put(String key, Object value)
+ {
+ return null;
+ }
+
+ public Object remove(Object key)
+ {
+ return null;
+ }
+
+ protected static void traverseClass(Class<?> clazz, Set<String> classes)
+ {
+ if (clazz == null || clazz == Object.class)
+ {
+ return;
+ }
+
+ classes.add(clazz.getName());
+
+ // traverse superclass
+ traverseClass(clazz.getSuperclass(), classes);
+ Class<?>[] interfaces = clazz.getInterfaces();
+ // traverse interfaces
+ for(Class<?> intface : interfaces)
+ {
+ traverseClass(intface, classes);
+ }
+ }
+ }
}
\ No newline at end of file
16 years, 7 months
JBoss-OSGI SVN: r97232 - projects/jboss-osgi/trunk/testsuite/functional.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-01 09:13:37 -0500 (Tue, 01 Dec 2009)
New Revision: 97232
Modified:
projects/jboss-osgi/trunk/testsuite/functional/pom.xml
Log:
[JBOSGI-212] Cannot refresh Microcontainer service
Modified: projects/jboss-osgi/trunk/testsuite/functional/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/pom.xml 2009-12-01 14:13:36 UTC (rev 97231)
+++ projects/jboss-osgi/trunk/testsuite/functional/pom.xml 2009-12-01 14:13:37 UTC (rev 97232)
@@ -150,8 +150,6 @@
<exclude>org/jboss/test/osgi/jbosgi39/**</exclude>
<!-- [JBOSGI-108] Investigate statics on PackageAdmin.refresh -->
<exclude>org/jboss/test/osgi/jbosgi108/**</exclude>
- <!-- [JBOSGI-212] Cannot refresh Microcontainer service -->
- <exclude>org/jboss/test/osgi/jbosgi212/**</exclude>
</excludes>
</configuration>
</plugin>
16 years, 7 months
JBoss-OSGI SVN: r97229 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-12-01 08:52:56 -0500 (Tue, 01 Dec 2009)
New Revision: 97229
Added:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/DictionaryFactory.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/InstanceMetaDataRetrievalFactory.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/KernelDictionaryFactory.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceStateDictionaryFactory.java
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/DescribeAction.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
Log:
Introduce instance metadata factory - adds OSGi's Dictionary to MDR.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/DescribeAction.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/DescribeAction.java 2009-12-01 13:48:30 UTC (rev 97228)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/DescribeAction.java 2009-12-01 13:52:56 UTC (rev 97229)
@@ -30,6 +30,7 @@
import org.jboss.metadata.spi.scope.CommonLevels;
import org.jboss.metadata.spi.scope.Scope;
import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
/**
* Describe osgi service.
@@ -47,6 +48,16 @@
ScopeKey key = new ScopeKey(scope);
MutableMetaDataRepository mutable = repository.getMetaDataRepository();
MetaDataRetrieval retrieval = mutable.getMetaDataRetrieval(key);
+ if (retrieval == null)
+ {
+ retrieval = new MemoryMetaDataLoader(key);
+ mutable.addMetaDataRetrieval(retrieval);
+ }
+ else if (retrieval.retrieveMetaData(Dictionary.class) != null)
+ {
+ return; // we already have Dictionary
+ }
+
if (retrieval instanceof MutableMetaDataLoader)
{
MutableMetaDataLoader mmdl = (MutableMetaDataLoader)retrieval;
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/DictionaryFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/DictionaryFactory.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/DictionaryFactory.java 2009-12-01 13:52:56 UTC (rev 97229)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.framework.bundle;
+
+import java.util.Dictionary;
+
+import org.jboss.dependency.spi.ControllerContext;
+
+/**
+ * Get OSGi's dictionary from controller context instance.
+ *
+ * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
+ */
+public interface DictionaryFactory<T extends ControllerContext>
+{
+ /**
+ * Get context type.
+ *
+ * @return the context type
+ */
+ Class<T> getContextType();
+
+ /**
+ * Get dictionary for context.
+ *
+ * @param context the context
+ * @return dictionary
+ */
+ Dictionary<String, Object> getDictionary(T context);
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/InstanceMetaDataRetrievalFactory.java (from rev 97217, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/DescribeAction.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/InstanceMetaDataRetrievalFactory.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/InstanceMetaDataRetrievalFactory.java 2009-12-01 13:52:56 UTC (rev 97229)
@@ -0,0 +1,115 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.framework.bundle;
+
+import java.util.Dictionary;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.Scope;
+import org.jboss.metadata.spi.scope.ScopeKey;
+
+/**
+ * Add OSGi's dictionary to MDR.
+ *
+ * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
+ */
+public class InstanceMetaDataRetrievalFactory implements MetaDataRetrievalFactory
+{
+ private Controller controller;
+ private Set<DictionaryFactory> factories = new CopyOnWriteArraySet<DictionaryFactory>();
+
+ public InstanceMetaDataRetrievalFactory(Controller controller)
+ {
+ if (controller == null)
+ throw new IllegalArgumentException("Null controller");
+ this.controller = controller;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public MetaDataRetrieval getMetaDataRetrieval(Scope scope)
+ {
+ if (scope == null)
+ throw new IllegalArgumentException("Null scope");
+ if (CommonLevels.INSTANCE.equals(scope.getScopeLevel()) == false)
+ throw new IllegalArgumentException("Not an instance scope: " + scope);
+
+ MemoryMetaDataLoader loader = new MemoryMetaDataLoader(new ScopeKey(scope));
+ Object qualifier = scope.getQualifier();
+ ControllerContext context = controller.getContext(qualifier, null);
+ if (context != null)
+ {
+ DictionaryFactory factory = null;
+ for (DictionaryFactory df : factories)
+ {
+ Class<?> contextType = df.getContextType();
+ if (contextType.isInstance(context))
+ {
+ factory = df;
+ break;
+ }
+ }
+ if (factory != null)
+ {
+ Dictionary<String, Object> dictionary = factory.getDictionary(context);
+ loader.addMetaData(dictionary, Dictionary.class);
+ }
+ }
+ return loader;
+ }
+
+ /**
+ * Add dictonary factory.
+ *
+ * @param factory the factory
+ * @return Set#add
+ */
+ public boolean addFactory(DictionaryFactory factory)
+ {
+ if (factory == null)
+ throw new IllegalArgumentException("Null factory");
+ if (factory.getContextType() == null)
+ throw new IllegalArgumentException("Null context type on factory: " + factory);
+
+ return factories.add(factory);
+ }
+
+ /**
+ * Remove dictonary factory.
+ *
+ * @param factory the factory
+ * @return Set#add
+ */
+ public boolean removeFactory(DictionaryFactory factory)
+ {
+ if (factory == null)
+ throw new IllegalArgumentException("Null factory");
+
+ return factories.remove(factory);
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/KernelDictionaryFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/KernelDictionaryFactory.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/KernelDictionaryFactory.java 2009-12-01 13:52:56 UTC (rev 97229)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.framework.bundle;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.osgi.framework.Constants;
+
+/**
+ * Kernel dictionary factory.
+ *
+ * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
+ */
+public class KernelDictionaryFactory implements DictionaryFactory<KernelControllerContext>
+{
+ public Class<KernelControllerContext> getContextType()
+ {
+ return KernelControllerContext.class;
+ }
+
+ public Dictionary<String, Object> getDictionary(KernelControllerContext context)
+ {
+ Dictionary<String, Object> table = new Hashtable<String, Object>();
+ table.put(Constants.OBJECTCLASS, new String[0]);
+ return table;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-01 13:48:30 UTC (rev 97228)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-01 13:52:56 UTC (rev 97229)
@@ -68,6 +68,8 @@
import org.jboss.metadata.spi.loader.MutableMetaDataLoader;
import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
+import org.jboss.metadata.spi.scope.CommonLevels;
import org.jboss.metadata.spi.scope.ScopeKey;
import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
@@ -151,6 +153,9 @@
/** The deployment registry */
private DeploymentRegistry registry;
+ /** The instance metadata factory */
+ private MetaDataRetrievalFactory factory;
+
/** The executor */
private Executor executor;
@@ -271,9 +276,38 @@
repository.removeMetaDataRetrieval(mmdl.getScope());
}
}
+
+ if (register)
+ {
+ MetaDataRetrievalFactory mdrFactory = factory;
+ if (mdrFactory == null)
+ {
+ Controller controller = kernel.getController();
+ InstanceMetaDataRetrievalFactory imdrf = new InstanceMetaDataRetrievalFactory(controller);
+ imdrf.addFactory(new OSGiServiceStateDictionaryFactory());
+ imdrf.addFactory(new KernelDictionaryFactory());
+ // TODO - JMX?
+ mdrFactory = imdrf;
+ }
+ repository.addMetaDataRetrievalFactory(CommonLevels.INSTANCE, mdrFactory);
+ }
+ else
+ {
+ repository.removeMetaDataRetrievalFactory(CommonLevels.INSTANCE);
+ }
}
/**
+ * Set instance metadata factory.
+ *
+ * @param factory the instance metadata factory
+ */
+ public void setInstanceMetaDataFactory(MetaDataRetrievalFactory factory)
+ {
+ this.factory = factory;
+ }
+
+ /**
* Get bundle for user tracker.
*
* @param user the user tracker object
Added: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceStateDictionaryFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceStateDictionaryFactory.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceStateDictionaryFactory.java 2009-12-01 13:52:56 UTC (rev 97229)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.framework.bundle;
+
+import java.util.Dictionary;
+
+/**
+ * OSGi controller context dictionary factory.
+ *
+ * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
+ */
+public class OSGiServiceStateDictionaryFactory implements DictionaryFactory<OSGiServiceState>
+{
+ public Class<OSGiServiceState> getContextType()
+ {
+ return OSGiServiceState.class;
+ }
+
+ public Dictionary<String, Object> getDictionary(OSGiServiceState context)
+ {
+ return new ServiceRefDictionary(context);
+ }
+}
\ No newline at end of file
16 years, 7 months
JBoss-OSGI SVN: r97228 - in projects/jboss-osgi: projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-01 08:48:30 -0500 (Tue, 01 Dec 2009)
New Revision: 97228
Modified:
projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml
projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/MicrocontainerServiceBean.java
projects/jboss-osgi/trunk/pom.xml
Log:
Fix reference to BEAN_BUNDLE_CONTEXT
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-12-01 13:37:57 UTC (rev 97227)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/pom.xml 2009-12-01 13:48:30 UTC (rev 97228)
@@ -20,7 +20,7 @@
<artifactId>jboss-osgi-runtime-jbossas</artifactId>
<packaging>jar</packaging>
- <version>1.0.3-SNAPSHOT</version>
+ <version>1.0.2-SNAPSHOT</version>
<!-- Parent -->
<parent>
@@ -38,8 +38,8 @@
<!-- Properties -->
<properties>
- <version.jboss.osgi.jta>1.0.0</version.jboss.osgi.jta>
- <version.jboss.osgi.microcontainer>2.0.9</version.jboss.osgi.microcontainer>
+ <version.jboss.osgi.jta>1.0.0-SNAPSHOT</version.jboss.osgi.jta>
+ <version.jboss.osgi.microcontainer>2.0.9-SNAPSHOT</version.jboss.osgi.microcontainer>
<version.osgi>4.2.0</version.osgi>
</properties>
Modified: projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/MicrocontainerServiceBean.java
===================================================================
--- projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/MicrocontainerServiceBean.java 2009-12-01 13:37:57 UTC (rev 97227)
+++ projects/jboss-osgi/projects/runtime/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/MicrocontainerServiceBean.java 2009-12-01 13:48:30 UTC (rev 97228)
@@ -46,13 +46,13 @@
// Provide logging
private static Logger log = Logger.getLogger(MicrocontainerServiceBean.class);
- private BundleContext bundleContext;
+ private BundleContext context;
private MBeanServer mbeanServer;
private Kernel kernel;
public void setBundleContext(BundleContext bundleContext)
{
- this.bundleContext = bundleContext;
+ this.context = bundleContext;
}
public void setMbeanServer(MBeanServer mbeanServer)
@@ -76,14 +76,14 @@
KernelController controller = kernel.getController();
// Preregister some MC beans
- installBean(controller, BEAN_SYSTEM_BUNDLE_CONTEXT, bundleContext);
+ installBean(controller, BEAN_BUNDLE_CONTEXT, context);
installBean(controller, BEAN_KERNEL, kernel);
installBean(controller, BEAN_KERNEL_CONTROLLER, controller);
installBean(controller, BEAN_MBEAN_SERVER, mbeanServer);
// Register the MicrocontainerService
log.debug("Register MicrocontainerService");
- bundleContext.registerService(MicrocontainerService.class.getName(), this, null);
+ context.registerService(MicrocontainerService.class.getName(), this, null);
log.debug("MicrocontainerService registered");
// Register the MicrocontainerServiceMBean
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-12-01 13:37:57 UTC (rev 97227)
+++ projects/jboss-osgi/trunk/pom.xml 2009-12-01 13:48:30 UTC (rev 97228)
@@ -66,7 +66,7 @@
<version.jboss.osgi.runtime.deployers>1.0.3-SNAPSHOT</version.jboss.osgi.runtime.deployers>
<version.jboss.osgi.runtime.equinox>3.5.1-SNAPSHOT</version.jboss.osgi.runtime.equinox>
<version.jboss.osgi.runtime.felix>2.0.2-SNAPSHOT</version.jboss.osgi.runtime.felix>
- <version.jboss.osgi.runtime.jbossas>1.0.2</version.jboss.osgi.runtime.jbossas>
+ <version.jboss.osgi.runtime.jbossas>1.0.2-SNAPSHOT</version.jboss.osgi.runtime.jbossas>
<version.jboss.osgi.spi>1.0.3-SNAPSHOT</version.jboss.osgi.spi>
<version.jboss.osgi.webapp>0.7.2-SNAPSHOT</version.jboss.osgi.webapp>
<version.jboss.osgi.webconsole>1.0.2</version.jboss.osgi.webconsole>
16 years, 7 months
JBoss-OSGI SVN: r97227 - in projects/jboss-osgi/trunk/testsuite: example/src/test/java/org/jboss/test/osgi/example/webapp and 12 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-01 08:37:57 -0500 (Tue, 01 Dec 2009)
New Revision: 97227
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGI112TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGI142TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi151/OSGI151TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/OSGI161TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi212/OSGI212TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/OSGI37TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/startlevel/StartLevelTestCase.java
Log:
Pull up test assertions
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -32,7 +32,7 @@
import org.jboss.osgi.husky.RuntimeContext;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.testing.OSGiTest;
import org.jboss.test.osgi.example.simple.bundle.SimpleService;
import org.junit.After;
import org.junit.Before;
@@ -49,7 +49,7 @@
* @author thomas.diesler(a)jboss.com
* @since 12-Feb-2009
*/
-public class SimpleHuskyTestCase
+public class SimpleHuskyTestCase extends OSGiTest
{
@RuntimeContext
public BundleContext context;
@@ -64,7 +64,7 @@
if (context == null)
{
// Get the default runtime
- runtime = new OSGiTestHelper().getDefaultRuntime();
+ runtime = getDefaultRuntime();
runtime.addCapability(new HuskyCapability());
// Install the bundle
@@ -72,7 +72,7 @@
// Start the bundle
bundle.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+ assertBundleState(Bundle.ACTIVE, bundle.getState());
}
}
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,11 +23,9 @@
//$Id$
-import static org.junit.Assert.assertEquals;
-
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.osgi.testing.OSGiTest;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -37,13 +35,13 @@
* @author thomas.diesler(a)jboss.com
* @since 12-Feb-2009
*/
-public class SimpleTestCase
+public class SimpleTestCase extends OSGiTest
{
@Test
public void testSimpleBundle() throws Exception
{
// Get the default runtime
- OSGiRuntime runtime = new OSGiTestHelper().getDefaultRuntime();
+ OSGiRuntime runtime = getDefaultRuntime();
try
{
@@ -52,7 +50,7 @@
// Start the bundle
bundle.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+ assertBundleState(Bundle.ACTIVE, bundle.getState());
// Uninstall the bundle
bundle.uninstall();
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/webapp/WebAppNegativeTestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,7 +23,6 @@
// $Id$
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -68,7 +67,7 @@
public void testServletAccess() throws Exception
{
OSGiBundle bundle = runtime.installBundle("example-webapp-negative.war");
- assertEquals(Bundle.INSTALLED, bundle.getState());
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
try
{
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGI112TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGI112TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi112/OSGI112TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,10 +23,9 @@
//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
-import static org.junit.Assert.assertEquals;
-
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiTest;
import org.jboss.osgi.testing.OSGiTestHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -43,7 +42,7 @@
* @author thomas.diesler(a)jboss.com
* @since 19-Jun-2009
*/
-public class OSGI112TestCase
+public class OSGI112TestCase extends OSGiTest
{
private static OSGiRuntime runtime;
@@ -81,6 +80,6 @@
// If the BP extender detects some issue with the BP configuration, it can/should log this information
// but it cannot prevent the bundle from starting.
- assertEquals("ACTIVE expected", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGI142TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGI142TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGI142TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,8 +23,6 @@
//$Id: OSGI142TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
@@ -66,26 +64,26 @@
Bundle bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi142-bundleX.jar").toExternalForm());
bundleX.start();
- assertBundleLoadClass(bundleX, BeanX.class, true);
+ assertBundleLoadClass(bundleX, BeanX.class.getName(), true);
Bundle bundleA = sysContext.installBundle(getTestArchiveURL("jbosgi142-bundleA.jar").toExternalForm());
bundleA.start();
- assertBundleLoadClass(bundleA, BeanA.class, true);
+ assertBundleLoadClass(bundleA, BeanA.class.getName(), true);
Bundle bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi142-bundleB.jar").toExternalForm());
bundleB.start();
- assertBundleLoadClass(bundleB, BeanB.class, true);
+ assertBundleLoadClass(bundleB, BeanB.class.getName(), true);
- assertBundleLoadClass(bundleA, BeanX.class, true);
- assertBundleLoadClass(bundleB, BeanX.class, true);
+ assertBundleLoadClass(bundleA, BeanX.class.getName(), true);
+ assertBundleLoadClass(bundleB, BeanX.class.getName(), true);
- assertBundleLoadClass(bundleX, BeanA.class, false);
- assertBundleLoadClass(bundleX, BeanB.class, false);
+ assertBundleLoadClass(bundleX, BeanA.class.getName(), false);
+ assertBundleLoadClass(bundleX, BeanB.class.getName(), false);
- assertBundleLoadClass(bundleA, BeanB.class, false);
- assertBundleLoadClass(bundleB, BeanA.class, false);
+ assertBundleLoadClass(bundleA, BeanB.class.getName(), false);
+ assertBundleLoadClass(bundleB, BeanA.class.getName(), false);
}
finally
{
@@ -93,28 +91,4 @@
framework.waitForStop(1000);
}
}
-
- private void assertBundleLoadClass(Bundle bundle, Class<?> expClazz, boolean success)
- {
- String message = bundle.getSymbolicName() + " loads " + expClazz.getName();
-
- Class<?> wasClass;
- try
- {
- wasClass = bundle.loadClass(expClazz.getName());
- if (success)
- {
- assertEquals(message, expClazz.getName(), wasClass.getName());
- }
- else
- {
- fail("ClassNotFoundException expected for: " + message + "\nLoaded from " + wasClass.getClassLoader());
- }
- }
- catch (ClassNotFoundException ex)
- {
- if (success)
- fail("Unexpected ClassNotFoundException for: " + message);
- }
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi151/OSGI151TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi151/OSGI151TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi151/OSGI151TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -90,14 +90,14 @@
BundleContext sysContext = framework.getBundleContext();
Bundle bundleA = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleA.jar").toExternalForm());
- assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleA.getState());
+ assertBundleState(Bundle.INSTALLED, bundleA.getState());
Bundle bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleB.jar").toExternalForm());
- assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleB.getState());
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
bundleB.start();
- assertEquals("ACTIVE expected", Bundle.ACTIVE, bundleB.getState());
- assertEquals("RESOLVED expected", Bundle.RESOLVED, bundleA.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleA.getState());
Class<?> classAA = bundleA.loadClass(BeanA.class.getName());
Class<?> classAB = bundleB.loadClass(BeanA.class.getName());
@@ -117,14 +117,14 @@
BundleContext sysContext = framework.getBundleContext();
Bundle bundleC = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleC.jar").toExternalForm());
- assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleC.getState());
+ assertBundleState(Bundle.INSTALLED, bundleC.getState());
Bundle bundleD = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleD.jar").toExternalForm());
- assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleD.getState());
+ assertBundleState(Bundle.INSTALLED, bundleD.getState());
bundleD.start();
- assertEquals("ACTIVE expected", Bundle.ACTIVE, bundleD.getState());
- assertEquals("RESOLVED expected", Bundle.RESOLVED, bundleC.getState());
+ assertBundleState(Bundle.ACTIVE, bundleD.getState());
+ assertBundleState(Bundle.RESOLVED, bundleC.getState());
Class<?> classBC = bundleC.loadClass(BeanB.class.getName());
Class<?> classBD = bundleD.loadClass(BeanB.class.getName());
@@ -144,14 +144,14 @@
BundleContext sysContext = framework.getBundleContext();
Bundle bundleD = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleD.jar").toExternalForm());
- assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleD.getState());
+ assertBundleState(Bundle.INSTALLED, bundleD.getState());
Bundle bundleC = sysContext.installBundle(getTestArchiveURL("jbosgi151-bundleC.jar").toExternalForm());
- assertEquals("INSTALLED expected", Bundle.INSTALLED, bundleC.getState());
+ assertBundleState(Bundle.INSTALLED, bundleC.getState());
bundleD.start();
- assertEquals("ACTIVE expected", Bundle.ACTIVE, bundleD.getState());
- assertEquals("RESOLVED expected", Bundle.RESOLVED, bundleC.getState());
+ assertBundleState(Bundle.ACTIVE, bundleD.getState());
+ assertBundleState(Bundle.RESOLVED, bundleC.getState());
Class<?> classBC = bundleC.loadClass(BeanB.class.getName());
Class<?> classBD = bundleD.loadClass(BeanB.class.getName());
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/OSGI161TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/OSGI161TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi161/OSGI161TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,8 +23,6 @@
//$Id:$
-import static org.junit.Assert.assertEquals;
-
import org.jboss.osgi.spi.capability.LogServiceCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
@@ -53,7 +51,7 @@
OSGiBundle bundleA = runtime.installBundle("jbosgi161-bundle.jar");
bundleA.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+ assertBundleState(Bundle.ACTIVE, bundleA.getState());
bundleA.uninstall();
}
finally
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi212/OSGI212TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi212/OSGI212TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi212/OSGI212TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,7 +23,6 @@
//$Id:$
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.jboss.osgi.microcontainer.MicrocontainerCapability;
@@ -58,7 +57,7 @@
if (bundle != null)
{
assertNotNull("MicrocontainerService available", bundle);
- assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
+ assertBundleState(Bundle.ACTIVE, bundle.getState());
// Update the MC bundle
bundle.stop();
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/OSGI37TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/OSGI37TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/OSGI37TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -56,7 +56,7 @@
OSGiBundle bundleA = runtime.installBundle("jbosgi37-bundleA.jar");
bundleA.start();
- assertEquals("Bundle started", Bundle.ACTIVE, bundleA.getState());
+ assertBundleState(Bundle.ACTIVE, bundleA.getState());
List<String> relevant = new ArrayList<String>();
for (OSGiBundle bundle : runtime.getBundles())
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -24,10 +24,8 @@
//$Id: OSGI38TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
import static org.junit.Assert.fail;
-import static org.junit.Assert.assertEquals;
import org.jboss.osgi.spi.capability.CompendiumCapability;
-import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTest;
@@ -271,11 +269,4 @@
}
}
- private void assertBundleState(int expState, int wasState)
- {
- String expstr = ConstantsHelper.bundleState(expState);
- String wasstr = ConstantsHelper.bundleState(wasState);
- assertEquals("Bundle " + expstr, expstr, wasstr);
- }
-
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,7 +23,6 @@
//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.jboss.osgi.testing.OSGiBundle;
@@ -71,7 +70,7 @@
public void testVerifyUnresolved() throws Exception
{
OSGiBundle bundleB = runtime.installBundle("jbosgi39-bundleB.jar");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
try
{
@@ -87,8 +86,8 @@
bundleB.start();
- assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
bundleB.uninstall();
bundleX.uninstall();
@@ -113,8 +112,8 @@
bundleB.start();
- assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
// Uninstall X before B
bundleX.uninstall();
@@ -125,7 +124,7 @@
bundleB.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
bundleB.uninstall();
}
@@ -138,8 +137,8 @@
bundleB.start();
- assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
// Uninstall X before B
bundleX.uninstall();
@@ -166,8 +165,8 @@
bundleB.start();
- assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
bundleB.uninstall();
bundleX.uninstall();
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/OSGI41TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -59,7 +59,7 @@
OSGiBundle bundleA = runtime.installBundle("jbosgi41-bundleA.jar");
bundleA.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+ assertBundleState(Bundle.ACTIVE, bundleA.getState());
File dataFile = getBundleDataFile(bundleA, "config/jbosgi41.txt");
assertTrue("File exists: " + dataFile, dataFile.exists());
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -31,6 +31,7 @@
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiServiceReference;
+import org.jboss.osgi.testing.OSGiTest;
import org.jboss.osgi.testing.OSGiTestHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -47,7 +48,7 @@
* @author thomas.diesler(a)jboss.com
* @since 21-Jul-2009
*/
-public class OSGI92TestCase
+public class OSGI92TestCase extends OSGiTest
{
private static OSGiRuntime runtime;
@@ -74,7 +75,7 @@
OSGiBundle bundleA = runtime.installBundle("jbosgi92-bundleA.jar");
bundleA.start();
- assertEquals(Bundle.ACTIVE, bundleA.getState());
+ assertBundleState(Bundle.ACTIVE, bundleA.getState());
String filter = "(parser.factoryname=org.jboss.test.osgi.jbosgi92.bundleA.*)";
OSGiServiceReference[] domRefs = runtime.getServiceReferences(DocumentBuilderFactory.class.getName(), filter);
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,7 +23,6 @@
//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.jboss.osgi.spi.util.ConstantsHelper;
@@ -74,22 +73,22 @@
public void testAllGood() throws Exception
{
OSGiBundle bundle = runtime.installBundle("jbosgi99-allgood.jar");
- assertBundleState(bundle, Bundle.INSTALLED);
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
bundle.start();
- assertBundleState(bundle, Bundle.ACTIVE);
+ assertBundleState(Bundle.ACTIVE, bundle.getState());
bundle.uninstall();
if (runtime.isRemoteRuntime() == false)
- assertBundleState(bundle, Bundle.UNINSTALLED);
+ assertBundleState(Bundle.UNINSTALLED, bundle.getState());
}
@Test
public void testFailOnResolve() throws Exception
{
OSGiBundle bundle = runtime.installBundle("jbosgi99-failonresolve.jar");
- assertBundleState(bundle, Bundle.INSTALLED);
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
try
{
@@ -99,20 +98,20 @@
catch (BundleException ex)
{
log.error("State on error: " + ConstantsHelper.bundleState(bundle.getState()), ex);
- assertBundleState(bundle, Bundle.INSTALLED);
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
}
bundle.uninstall();
if (runtime.isRemoteRuntime() == false)
- assertBundleState(bundle, Bundle.UNINSTALLED);
+ assertBundleState(Bundle.UNINSTALLED, bundle.getState());
}
@Test
public void testFailOnStart() throws Exception
{
OSGiBundle bundle = runtime.installBundle("jbosgi99-failonstart.jar");
- assertBundleState(bundle, Bundle.INSTALLED);
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
try
{
@@ -122,19 +121,12 @@
catch (BundleException ex)
{
log.error("State on error: " + ConstantsHelper.bundleState(bundle.getState()), ex);
- assertBundleState(bundle, Bundle.RESOLVED);
+ assertBundleState(Bundle.RESOLVED, bundle.getState());
}
bundle.uninstall();
if (runtime.isRemoteRuntime() == false)
- assertBundleState(bundle, Bundle.UNINSTALLED);
+ assertBundleState(Bundle.UNINSTALLED, bundle.getState());
}
-
- private void assertBundleState(OSGiBundle bundle, int expState)
- {
- String exp = ConstantsHelper.bundleState(expState);
- String was = ConstantsHelper.bundleState(bundle.getState());
- assertEquals("Bundle " + exp, exp, was);
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/startlevel/StartLevelTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/startlevel/StartLevelTestCase.java 2009-12-01 13:36:31 UTC (rev 97226)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/startlevel/StartLevelTestCase.java 2009-12-01 13:37:57 UTC (rev 97227)
@@ -23,8 +23,6 @@
//$Id: StartLevelRemoteTestCase.java 87336 2009-04-15 11:31:26Z thomas.diesler(a)jboss.com $
-import static org.junit.Assert.assertEquals;
-
import org.jboss.osgi.spi.capability.CompendiumCapability;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
@@ -51,7 +49,7 @@
OSGiBundle bundle = runtime.installBundle("service/startlevel.jar");
bundle.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+ assertBundleState(Bundle.ACTIVE, bundle.getState());
bundle.uninstall();
}
16 years, 7 months
JBoss-OSGI SVN: r97226 - projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-01 08:36:31 -0500 (Tue, 01 Dec 2009)
New Revision: 97226
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
Log:
Pull up test assertions
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2009-12-01 13:12:44 UTC (rev 97225)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2009-12-01 13:36:31 UTC (rev 97226)
@@ -31,6 +31,7 @@
import org.jboss.virtual.VirtualFile;
import org.junit.After;
import org.junit.Before;
+import org.osgi.framework.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -211,4 +212,14 @@
{
return getTestHelper().assembleBundle(name, resources, packages);
}
+
+ public void assertBundleState(int expState, int wasState)
+ {
+ getTestHelper().assertBundleState(expState, wasState);
+ }
+
+ public void assertBundleLoadClass(Bundle bundle, String expClazz, boolean success)
+ {
+ getTestHelper().assertBundleLoadClass(bundle, expClazz, success);
+ }
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-12-01 13:12:44 UTC (rev 97225)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-12-01 13:36:31 UTC (rev 97226)
@@ -21,6 +21,9 @@
*/
package org.jboss.osgi.testing;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
@@ -33,11 +36,13 @@
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.osgi.testing.internal.EmbeddedRuntime;
import org.jboss.osgi.testing.internal.RemoteRuntime;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
/**
* An OSGi Test Helper
@@ -223,6 +228,37 @@
return assembledDirectory;
}
+ public void assertBundleState(int expState, int wasState)
+ {
+ String expstr = ConstantsHelper.bundleState(expState);
+ String wasstr = ConstantsHelper.bundleState(wasState);
+ assertEquals("Bundle " + expstr, expstr, wasstr);
+ }
+
+ public void assertBundleLoadClass(Bundle bundle, String expClazz, boolean success)
+ {
+ String message = bundle.getSymbolicName() + " loads " + expClazz;
+
+ Class<?> wasClass;
+ try
+ {
+ wasClass = bundle.loadClass(expClazz);
+ if (success)
+ {
+ assertEquals(message, expClazz, wasClass.getName());
+ }
+ else
+ {
+ fail("ClassNotFoundException expected for: " + message + "\nLoaded from " + wasClass.getClassLoader());
+ }
+ }
+ catch (ClassNotFoundException ex)
+ {
+ if (success)
+ fail("Unexpected ClassNotFoundException for: " + message);
+ }
+ }
+
private void addPath(AssembledDirectory dir, String path, String name) throws Exception
{
URL url = getClass().getResource(path);
16 years, 7 months
JBoss-OSGI SVN: r97225 - in projects/jboss-osgi: trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38 and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-01 08:12:44 -0500 (Tue, 01 Dec 2009)
New Revision: 97225
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
Log:
[JBOSGI-213] Unexpected dependee state changes
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-12-01 12:36:58 UTC (rev 97224)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-12-01 13:12:44 UTC (rev 97225)
@@ -201,7 +201,10 @@
public String getFramework()
{
- String framework = System.getProperty("framework", "jbossmc");
+ String framework = System.getProperty("framework");
+ if (framework == null || framework.length() == 0 || framework.equals("${framework}"))
+ framework = "jbossmc";
+
return framework;
}
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java 2009-12-01 12:36:58 UTC (rev 97224)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java 2009-12-01 13:12:44 UTC (rev 97225)
@@ -23,11 +23,11 @@
//$Id: OSGI38TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
+import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import org.jboss.osgi.spi.capability.CompendiumCapability;
+import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiTest;
@@ -45,14 +45,13 @@
* A ---> B
* A ---> X <--- B
*
+ * [TODO] Use default runtime for in container testing
+ *
* @author thomas.diesler(a)jboss.com
* @since 02-Mar-2009
*/
public class OSGI38TestCase extends OSGiTest
{
- /*
- * Install/Start the common bundle
- */
@Test
public void testInstallStartX() throws Exception
{
@@ -62,12 +61,13 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
bundleX.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleX.getState());
bundleX.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundleX.getState());
}
finally
{
@@ -87,13 +87,14 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
- assertTrue("Bundle installed", bundleB.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
bundleB.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
bundleB.uninstall();
bundleX.uninstall();
@@ -116,16 +117,18 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
- assertTrue("Bundle installed", bundleB.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
OSGiBundle bundleA = runtime.installBundle("jbosgi38-bundleA.jar");
- assertTrue("Bundle installed", bundleA.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleA.getState());
bundleA.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.RESOLVED, bundleB.getState());
+ assertBundleState(Bundle.ACTIVE, bundleA.getState());
bundleA.uninstall();
bundleB.uninstall();
@@ -149,7 +152,7 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
try
{
@@ -162,10 +165,11 @@
}
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
bundleB.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
bundleB.uninstall();
bundleX.uninstall();
@@ -188,10 +192,10 @@
runtime.addCapability(new CompendiumCapability());
OSGiBundle bundleA = runtime.installBundle("jbosgi38-bundleA.jar");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleA.getState());
+ assertBundleState(Bundle.INSTALLED, bundleA.getState());
OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
try
{
@@ -204,13 +208,14 @@
}
OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
- assertTrue("Bundle installed", bundleX.getState() <= Bundle.RESOLVED);
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
bundleB.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
bundleA.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+ assertBundleState(Bundle.ACTIVE, bundleA.getState());
bundleA.uninstall();
bundleB.uninstall();
@@ -221,4 +226,56 @@
runtime.shutdown();
}
}
+
+ /*
+ * Uninstall X, B stays active
+ */
+ @Test
+ public void testUninstallX() throws Exception
+ {
+ if ("jbossmc".equals(getFramework()))
+ {
+ System.out.println("FIXME [JBOSGI-213] Unexpected dependee state changes");
+ return;
+ }
+
+ OSGiRuntime runtime = getEmbeddedRuntime();
+ try
+ {
+ runtime.addCapability(new CompendiumCapability());
+
+ OSGiBundle bundleX = runtime.installBundle("jbosgi38-bundleX.jar");
+ assertBundleState(Bundle.INSTALLED, bundleX.getState());
+
+ OSGiBundle bundleB = runtime.installBundle("jbosgi38-bundleB.jar");
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
+
+ bundleB.start();
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
+
+ bundleX.stop();
+ assertBundleState(Bundle.RESOLVED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
+
+ bundleX.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundleX.getState());
+ assertBundleState(Bundle.ACTIVE, bundleB.getState());
+
+ bundleB.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundleB.getState());
+ }
+ finally
+ {
+ runtime.shutdown();
+ }
+ }
+
+ private void assertBundleState(int expState, int wasState)
+ {
+ String expstr = ConstantsHelper.bundleState(expState);
+ String wasstr = ConstantsHelper.bundleState(wasState);
+ assertEquals("Bundle " + expstr, expstr, wasstr);
+ }
+
}
\ No newline at end of file
16 years, 7 months
JBoss-OSGI SVN: r97220 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle.
by jboss-osgi-commits@lists.jboss.org
Author: alesj
Date: 2009-12-01 06:52:28 -0500 (Tue, 01 Dec 2009)
New Revision: 97220
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
Log:
Use fixed ContextTracker api.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-01 11:38:59 UTC (rev 97219)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-01 11:52:28 UTC (rev 97220)
@@ -322,12 +322,12 @@
{
checkInstalled();
- Set<org.jboss.dependency.spi.ControllerContext> contexts = getUsedContexts(null);
+ Set<ControllerContext> contexts = getUsedContexts(this);
if (contexts.isEmpty())
return null;
Set<ServiceReference> result = new HashSet<ServiceReference>();
- for (org.jboss.dependency.spi.ControllerContext context : contexts)
+ for (ControllerContext context : contexts)
{
ServiceReference ref = getBundleManager().getServiceReferenceForContext(context);
if (ref != null)
@@ -372,7 +372,7 @@
public ServiceReference[] getServicesInUse()
{
- Set<ControllerContext> contexts = getUsedContexts(null);
+ Set<ControllerContext> contexts = getUsedContexts(this);
if (contexts == null || contexts.isEmpty())
return null;
Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-01 11:38:59 UTC (rev 97219)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-01 11:52:28 UTC (rev 97220)
@@ -344,7 +344,7 @@
}
}
- for (ControllerContext context : getUsedContexts(null))
+ for (ControllerContext context : getUsedContexts(this))
{
int count = getUsedByCount(context, this);
while (count > 0)
16 years, 7 months
JBoss-OSGI SVN: r97218 - in projects/jboss-osgi/projects: runtime/framework/branches/1.0.0.Alpha2/src/main/java/org/jboss/osgi/framework/deployers and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-01 06:34:45 -0500 (Tue, 01 Dec 2009)
New Revision: 97218
Modified:
projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/pom.xml
projects/jboss-osgi/projects/runtime/framework/branches/1.0.0.Alpha2/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
Log:
Fix NPE in DeployersWrapper
Modified: projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/pom.xml 2009-12-01 11:14:07 UTC (rev 97217)
+++ projects/jboss-osgi/projects/bundles/jboss-xml-binding/trunk/pom.xml 2009-12-01 11:34:45 UTC (rev 97218)
@@ -14,7 +14,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <name>JBossOSGi Bundles - JBossXB</name>
+ <name>JBossOSGi Bundles - XML Binding</name>
<description>A JBossOSGi provided JBossXB bundle</description>
<groupId>org.jboss.osgi.bundles</groupId>
Modified: projects/jboss-osgi/projects/runtime/framework/branches/1.0.0.Alpha2/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/1.0.0.Alpha2/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2009-12-01 11:14:07 UTC (rev 97217)
+++ projects/jboss-osgi/projects/runtime/framework/branches/1.0.0.Alpha2/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2009-12-01 11:34:45 UTC (rev 97218)
@@ -130,7 +130,9 @@
continue;
Deployment dep = unit.getAttachment(Deployment.class);
- if (dep.isAutoStart() == true && bundle.getState() == Bundle.INSTALLED)
+ boolean autoStart = (dep != null ? dep.isAutoStart() : true);
+
+ if (autoStart == true && bundle.getState() == Bundle.INSTALLED)
{
unresolvedBundles.add(0, bundle);
}
16 years, 7 months