Author: thomas.diesler(a)jboss.com
Date: 2010-02-05 11:29:37 -0500 (Fri, 05 Feb 2010)
New Revision: 100550
Modified:
projects/jboss-osgi/branches/1.0.0.Beta6/pom.xml
projects/jboss-osgi/branches/1.0.0.Beta6/testsuite/example/src/test/java/org/jboss/test/osgi/example/serviceloader/ServiceLoaderTestCase.java
Log:
Fix ServiceLoaderInterceptor
Modified: projects/jboss-osgi/branches/1.0.0.Beta6/pom.xml
===================================================================
--- projects/jboss-osgi/branches/1.0.0.Beta6/pom.xml 2010-02-05 16:28:30 UTC (rev 100549)
+++ projects/jboss-osgi/branches/1.0.0.Beta6/pom.xml 2010-02-05 16:29:37 UTC (rev 100550)
@@ -70,7 +70,7 @@
<version.jboss.osgi.runtime.equinox>3.5.1</version.jboss.osgi.runtime.equinox>
<version.jboss.osgi.runtime.felix>2.0.2</version.jboss.osgi.runtime.felix>
<version.jboss.osgi.runtime.jbossas>1.0.2</version.jboss.osgi.runtime.jbossas>
-
<version.jboss.osgi.serviceloader>1.0.0-SNAPSHOT</version.jboss.osgi.serviceloader>
+
<version.jboss.osgi.serviceloader>1.0.0</version.jboss.osgi.serviceloader>
<version.jboss.osgi.spi>1.0.4</version.jboss.osgi.spi>
<version.jboss.osgi.webapp>0.7.2.SP1</version.jboss.osgi.webapp>
<version.jboss.osgi.webconsole>1.0.2</version.jboss.osgi.webconsole>
Modified:
projects/jboss-osgi/branches/1.0.0.Beta6/testsuite/example/src/test/java/org/jboss/test/osgi/example/serviceloader/ServiceLoaderTestCase.java
===================================================================
---
projects/jboss-osgi/branches/1.0.0.Beta6/testsuite/example/src/test/java/org/jboss/test/osgi/example/serviceloader/ServiceLoaderTestCase.java 2010-02-05
16:28:30 UTC (rev 100549)
+++
projects/jboss-osgi/branches/1.0.0.Beta6/testsuite/example/src/test/java/org/jboss/test/osgi/example/serviceloader/ServiceLoaderTestCase.java 2010-02-05
16:29:37 UTC (rev 100550)
@@ -25,6 +25,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import org.jboss.osgi.serviceloader.ServiceLoaderCapability;
@@ -34,6 +35,7 @@
import org.jboss.osgi.testing.OSGiServiceReference;
import org.jboss.osgi.testing.OSGiTest;
import org.jboss.test.osgi.example.serviceloader.service.AccountService;
+import org.jboss.test.osgi.example.serviceloader.service.internal.AccountServiceImpl;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -77,7 +79,7 @@
try
{
// Install the API bundle
- runtime.installBundle("example-serviceloader-api.jar");
+ OSGiBundle apiBundle =
runtime.installBundle("example-serviceloader-api.jar");
// Install/Start the client bundle
OSGiBundle implBundle =
runtime.installBundle("example-serviceloader-impl.jar");
@@ -93,6 +95,26 @@
assertBundleState(Bundle.ACTIVE, implBundle.getState());
assertBundleState(Bundle.ACTIVE, clientBundle.getState());
+
+ OSGiBundle apiProvider =
clientBundle.loadClass(AccountService.class.getName());
+ assertEquals(apiBundle, apiProvider);
+
+ try
+ {
+ // The client cannot access the implementation class directly
+ clientBundle.loadClass(AccountServiceImpl.class.getName());
+ fail("ClassNotFoundException expected");
+ }
+ catch (ClassNotFoundException ex)
+ {
+ // expected
+ }
+
+ // Stopping the implementation bundle should unregister the service
+ implBundle.stop();
+
+ OSGiServiceReference sref =
runtime.getServiceReference(AccountService.class.getName());
+ assertNull("AccountService not available", sref);
}
finally
{