[jboss-osgi-commits] JBoss-OSGI SVN: r97432 - in projects/jboss-osgi/trunk/reactor/framework/src/test: java/org/jboss/test/osgi/service/support and 3 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Thu Dec 3 16:05:25 EST 2009
Author: alesj
Date: 2009-12-03 16:05:24 -0500 (Thu, 03 Dec 2009)
New Revision: 97432
Added:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/a/A.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF
Log:
Add new SF test -- TODO make it work.
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-03 21:03:31 UTC (rev 97431)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2009-12-03 21:05:24 UTC (rev 97432)
@@ -36,6 +36,7 @@
import org.jboss.test.osgi.service.support.LazyBundle;
import org.jboss.test.osgi.service.support.a.A;
import org.jboss.test.osgi.service.support.c.C;
+import org.jboss.test.osgi.service.support.d.D;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -227,6 +228,69 @@
}
}
+ public void disabled_testServiceFactoryInjection() throws Throwable
+ {
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C1", C.class.getName());
+ builder.addPropertyMetaData("a", builder.createInject("A"));
+ BeanMetaData bmd = builder.getBeanMetaData();
+ Deployment bean1 = addBean("beanA1", C.class, bmd, A.class, D.class);
+ try
+ {
+ builder = BeanMetaDataBuilder.createBuilder("C2", C.class.getName());
+ builder.addPropertyMetaData("a", builder.createInject("A"));
+ bmd = builder.getBeanMetaData();
+ Deployment bean2 = addBean("beanA2", C.class, bmd, A.class, D.class);
+ try
+ {
+ Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle4");
+ try
+ {
+ bundle1.start();
+ BundleContext bundleContext1 = bundle1.getBundleContext();
+ assertNotNull(bundleContext1);
+
+ Class<?> dClass = bundle1.loadClass(D.class.getName());
+ Object d = dClass.newInstance();
+ Hashtable<String, Object> table = new Hashtable<String, Object>();
+ table.put("service.alias.1", "A");
+ ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(), d, table);
+ assertNotNull(reg1);
+
+ try
+ {
+ checkComplete();
+
+ Object c1 = getBean("C1");
+ Object a1 = invoke(c1, "getA");
+ Object msg1 = invoke(a1, "getMsg");
+ assertEquals(msg1, getBundle(bean1).getSymbolicName());
+
+ Object c2 = getBean("C2");
+ Object a2 = invoke(c2, "getA");
+ Object msg2 = invoke(a2, "getMsg");
+ assertEquals(msg2, getBundle(bean2).getSymbolicName());
+ }
+ finally
+ {
+ reg1.unregister();
+ }
+ }
+ finally
+ {
+ uninstall(bundle1);
+ }
+ }
+ finally
+ {
+ undeploy(bean2);
+ }
+ }
+ finally
+ {
+ undeploy(bean1);
+ }
+ }
+
public void testFiltering() throws Throwable
{
Deployment bean = addBean("beanA", A.class);
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/a/A.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/a/A.java 2009-12-03 21:03:31 UTC (rev 97431)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/a/A.java 2009-12-03 21:05:24 UTC (rev 97432)
@@ -29,4 +29,10 @@
*/
public class A
{
+ public String msg;
+
+ public String getMsg()
+ {
+ return msg;
+ }
}
Added: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/support/d/D.java 2009-12-03 21:05:24 UTC (rev 97432)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.osgi.service.support.d;
+
+import org.jboss.test.osgi.service.support.a.A;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class D implements ServiceFactory
+{
+ public Object getService(Bundle bundle, ServiceRegistration registration)
+ {
+ A a = new A();
+ a.msg = bundle.getSymbolicName();
+ return a;
+ }
+
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
+ {
+ }
+}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF 2009-12-03 21:03:31 UTC (rev 97431)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF 2009-12-03 21:05:24 UTC (rev 97432)
@@ -4,4 +4,4 @@
Implementation-Vendor: jboss.org
Bundle-Name: Service4
Bundle-SymbolicName: org.jboss.test.osgi.service4
-Export-Package: org.jboss.test.osgi.service.support.a;org.jboss.test.osgi.service.support.c
+Import-Package: org.jboss.test.osgi.service.support.a;org.jboss.test.osgi.service.support.c;org.jboss.test.osgi.service.support.d
More information about the jboss-osgi-commits
mailing list