[jboss-cvs] JBossAS SVN: r92676 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src: test/java/org/jboss/test/osgi/simple and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 21 11:57:33 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-08-21 11:57:32 -0400 (Fri, 21 Aug 2009)
New Revision: 92676
Added:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkBootstrapProvider.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/resources/META-INF/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/resources/META-INF/services/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java
Log:
Add SPI provided test integration
Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkBootstrapProvider.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkBootstrapProvider.java 2009-08-21 15:57:32 UTC (rev 92676)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.plugins.facade.launch;
+
+// $Id$
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * An impementation of an OSGiBootstrapProvider
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 21-Aug-2009
+ */
+public class OSGiFrameworkBootstrapProvider implements OSGiBootstrapProvider
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(OSGiFrameworkBootstrapProvider.class);
+
+ private Framework framework;
+
+ public void configure()
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ framework = factory.newFramework(null);
+ }
+
+ public void configure(URL urlConfig)
+ {
+ configure();
+ }
+
+ public void configure(String resourceConfig)
+ {
+ configure();
+ }
+
+ public void configure(InputStream streamConfig)
+ {
+ configure();
+ }
+
+ public Framework getFramework()
+ {
+ return framework;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/main/java/org/jboss/osgi/plugins/facade/launch/OSGiFrameworkBootstrapProvider.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java 2009-08-21 15:27:11 UTC (rev 92675)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java 2009-08-21 15:57:32 UTC (rev 92676)
@@ -27,15 +27,13 @@
import java.net.URL;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
import org.jboss.osgi.spi.util.ServiceLoader;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
@@ -47,26 +45,14 @@
*/
public class SimpleBundleTestCase
{
- private static Framework framework;
-
- @BeforeClass
- public static void beforeClass() throws BundleException
+ @Test
+ public void testBundleInstallLauchAPI() throws Exception
{
+ // Uses the OSGi Framework launch API
FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- framework = factory.newFramework(null);
+ Framework framework = factory.newFramework(null);
framework.start();
- }
-
- @AfterClass
- public static void afterClass() throws BundleException
- {
- if (framework != null)
- framework.stop();
- }
-
- @Test
- public void testBundleInstall() throws Exception
- {
+
BundleContext sysContext = framework.getBundleContext();
URL bundleURL = new OSGiTestHelper().getTestArchiveURL("simple-bundle.jar");
Bundle bundle = sysContext.installBundle(bundleURL.toExternalForm());
@@ -79,5 +65,26 @@
bundle.uninstall();
assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ framework.stop();
}
+
+ @Test
+ public void testBundleInstallRuntimeAPI() throws Exception
+ {
+ // Uses the JBossOSGi SPI provided runtime abstraction
+ OSGiRuntime runtime = new OSGiTestHelper().getEmbeddedRuntime();
+ OSGiBundle bundle = runtime.installBundle("simple-bundle.jar");
+
+ assertEquals("simple-bundle", bundle.getSymbolicName());
+
+ System.out.println("FIXME: bundle.start() does not initalize BundleContext");
+ //bundle.start();
+ //assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ runtime.shutdown();
+ }
}
\ No newline at end of file
Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/osgi-int/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-08-21 15:57:32 UTC (rev 92676)
@@ -0,0 +1 @@
+org.jboss.osgi.plugins.facade.launch.OSGiFrameworkBootstrapProvider
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list