[jboss-cvs] JBossAS SVN: r91513 - in projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi: jbosgi108 and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 21 15:48:29 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-07-21 15:48:28 -0400 (Tue, 21 Jul 2009)
New Revision: 91513
Added:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/
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/bundleA/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java
Removed:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java
Modified:
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java
Log:
[JBOSGI-92] Class.forName issue with XMLParserActivator
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108
___________________________________________________________________
Name: svn:mergeinfo
-
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI108TestCase.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,176 @@
+/*
+ * 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.test.osgi.jbosgi108;
+
+//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler at jboss.com $
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.jboss.osgi.jmx.JMXCapability;
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.test.osgi.jbosgi108.bundleA.SomeBeanMBean;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.BundleException;
+
+/**
+ * [JBOSGI-108] Investigate statics on PackageAdmin.refresh
+ *
+ * https://jira.jboss.org/jira/browse/JBOSGI-108
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 19-Jun-2009
+ */
+public class OSGI108TestCase
+{
+ private static OSGiRuntime runtime;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ runtime = new OSGiTestHelper().getDefaultRuntime();
+ runtime.addCapability(new JMXCapability());
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ if (runtime != null)
+ runtime.shutdown();
+ }
+
+ @Before
+ public void setUp()
+ {
+ OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
+ packageAdmin.refreshPackages(null);
+ }
+
+ @Test
+ public void testRedeploySingle() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+
+ bundleA.start();
+
+ SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
+ List<String> messages = report(someBean.getMessages());
+ assertEquals("Start messages", 1, messages.size());
+
+ bundleA.uninstall();
+
+ // Reinstall bundleA
+ bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ bundleA.start();
+
+ // The static in bundleA.SomeBean is expected to be recreated
+
+ messages = report(someBean.getMessages());
+ assertEquals("Start messages", 1, messages.size());
+
+ bundleA.uninstall();
+ }
+
+ @Test
+ public void testRedeployWithReference() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ OSGiBundle bundleB = runtime.installBundle("jbosgi108-bundleB.jar");
+
+ bundleA.start();
+ bundleB.start();
+
+ SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
+ List<String> messages = report(someBean.getMessages());
+ assertEquals("Start messages", 2, messages.size());
+
+ bundleA.uninstall();
+
+ // After uninstall bundleA, bundleB still holds a reference on
+ // bundleA.SomeBean
+
+ // Reinstall bundleA
+ bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ bundleA.start();
+
+ // The static in bundleA.SomeBean is expected to be reused
+
+ messages = report(someBean.getMessages());
+ assertEquals("Start messages", 4, messages.size());
+
+ bundleB.uninstall();
+ bundleA.uninstall();
+ }
+
+ @Test
+ public void testRedeployWithReferenceAndRefresh() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ OSGiBundle bundleB = runtime.installBundle("jbosgi108-bundleB.jar");
+
+ bundleA.start();
+ bundleB.start();
+
+ SomeBeanMBean someBean = MBeanProxy.get(SomeBeanMBean.class, SomeBeanMBean.MBEAN_NAME, runtime.getMBeanServer());
+ List<String> messages = report(someBean.getMessages());
+ assertEquals("Start messages", 2, messages.size());
+
+ bundleA.uninstall();
+
+ // After uninstall bundleA, bundleB still holds a reference on
+ // bundleA.SomeBean
+
+ // Refresh all packages
+ OSGiPackageAdmin packageAdmin = runtime.getPackageAdmin();
+ packageAdmin.refreshPackages(null);
+
+ // Reinstall bundleA
+ bundleA = runtime.installBundle("jbosgi108-bundleA.jar");
+ bundleA.start();
+
+ // The static in bundleA.SomeBean is expected to be recreated
+
+ messages = report(someBean.getMessages());
+ assertEquals("Start messages", 1, messages.size());
+
+ bundleB.uninstall();
+ bundleA.uninstall();
+ }
+
+ private List<String> report(List<String> messages)
+ {
+ // System.out.println(">>>>>>>>>>>>");
+ // for (String aux : messages)
+ // System.out.println(aux);
+ // System.out.println("<<<<<<<<<<<");
+
+ return messages;
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java 2009-07-21 19:47:26 UTC (rev 91512)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/OSGI92TestCase.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -1,81 +0,0 @@
-/*
- * 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.test.osgi.jbosgi92;
-
-//$Id: OSGI39TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler at jboss.com $
-
-import static org.junit.Assert.assertEquals;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.jboss.osgi.spi.testing.OSGiBundle;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiServiceReference;
-import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/**
- * [JBOSGI-92] Class.forName issue with XMLParserActivator
- *
- * https://jira.jboss.org/jira/browse/JBOSGI-92
- *
- * @author thomas.diesler at jboss.com
- * @since 21-Jul-2009
- */
-public class OSGI92TestCase
-{
- private static OSGiRuntime runtime;
-
- @BeforeClass
- public static void beforeClass() throws BundleException
- {
- runtime = new OSGiTestHelper().getDefaultRuntime();
- }
-
- @AfterClass
- public static void afterClass() throws BundleException
- {
- if (runtime != null)
- runtime.shutdown();
- }
-
- @Test
- public void testDeployParsers() throws Exception
- {
- OSGiBundle bundleA = runtime.installBundle("jbosgi92-bundleA.jar");
- bundleA.start();
-
- assertEquals(Bundle.ACTIVE, bundleA.getState());
-
- String filter = "(parser.factoryname=org.jboss.test.osgi.jbosgi92.bundleA.*)";
- OSGiServiceReference[] domRefs = runtime.getServiceReferences(DocumentBuilderFactory.class.getName(), filter);
- assertEquals("DocumentBuilderFactory servce available", 1, domRefs.length);
-
- OSGiServiceReference[] saxRefs = runtime.getServiceReferences(SAXParserFactory.class.getName(), filter);
- assertEquals("SAXParserFactory servce available", 1, saxRefs.length);
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java 2009-07-21 19:47:26 UTC (rev 91512)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/ActivatorBundleA.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -19,70 +19,57 @@
* 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.jbosgi92.bundleA;
+package org.jboss.test.osgi.jbosgi108.bundleA;
//$Id: ServiceActivator.java 87064 2009-04-09 11:08:56Z thomas.diesler at jboss.com $
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.SAXParserFactory;
+import javax.management.MBeanServer;
-import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.xml.XMLParserActivator;
-public class ActivatorBundleA extends XMLParserActivator
+public class ActivatorBundleA implements BundleActivator
{
- private LogService log;
+ private SomeBean bean;
- public void start(BundleContext context) throws Exception
+ public void start(BundleContext context)
{
- log = new LogServiceTracker(context);
+ bean = new SomeBean();
- super.start(context);
-
- logSAXParserFactory(context);
- logDOMParserFactory(context);
- }
-
- private void logSAXParserFactory(BundleContext context)
- {
- ServiceReference saxRef = context.getServiceReference(SAXParserFactory.class.getName());
- if (saxRef != null)
+ // Register the MBean
+ try
{
- Object factory = context.getService(saxRef);
- log.log(LogService.LOG_INFO, "SAXParserFactory: " + factory.getClass().getName());
-
- for (String key : saxRef.getPropertyKeys())
- {
- Object value = saxRef.getProperty(key);
- log.log(LogService.LOG_INFO, " " + key + "=" + value);
- }
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ MBeanServer service = (MBeanServer)context.getService(sref);
+ service.registerMBean(bean, SomeBean.MBEAN_NAME);
}
- else
+ catch (Exception ex)
{
- log.log(LogService.LOG_WARNING, "No SAXParserFactory registered");
+ throw new IllegalStateException(ex);
}
+
+ ClassLoader cl = getClass().getClassLoader();
+ String msg = "start with " + cl + " - hashCode: " + cl.hashCode();
+ bean.addMessage(msg);
}
- private void logDOMParserFactory(BundleContext context)
+ public void stop(BundleContext context)
{
- ServiceReference domRef = context.getServiceReference(DocumentBuilderFactory.class.getName());
- if (domRef != null)
+ ClassLoader cl = getClass().getClassLoader();
+ String msg = "stop with " + cl + " - hashCode: " + cl.hashCode();
+ bean.addMessage(msg);
+
+ // Register the MBean
+ try
{
- Object factory = context.getService(domRef);
- log.log(LogService.LOG_INFO, "DocumentBuilderFactory: " + factory.getClass().getName());
-
- for (String key : domRef.getPropertyKeys())
- {
- Object value = domRef.getProperty(key);
- log.log(LogService.LOG_INFO, " " + key + "=" + value);
- }
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ MBeanServer service = (MBeanServer)context.getService(sref);
+ service.unregisterMBean(SomeBean.MBEAN_NAME);
}
- else
+ catch (Exception ex)
{
- log.log(LogService.LOG_WARNING, "No DocumentBuilderFactory registered");
+ throw new IllegalStateException(ex);
}
}
}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java 2009-07-21 19:47:26 UTC (rev 91512)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/DocumentBuilderFactoryImpl.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -1,59 +0,0 @@
-/*
- * 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.test.osgi.jbosgi92.bundleA;
-
-//$Id$
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory
-{
- @Override
- public Object getAttribute(String name) throws IllegalArgumentException
- {
- return null;
- }
-
- @Override
- public boolean getFeature(String name) throws ParserConfigurationException
- {
- return false;
- }
-
- @Override
- public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException
- {
- return null;
- }
-
- @Override
- public void setAttribute(String name, Object value) throws IllegalArgumentException
- {
- }
-
- @Override
- public void setFeature(String name, boolean value) throws ParserConfigurationException
- {
- }
-}
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java 2009-07-21 19:47:26 UTC (rev 91512)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SAXParserFactoryImpl.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -1,52 +0,0 @@
-/*
- * 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.test.osgi.jbosgi92.bundleA;
-
-//$Id$
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-
-public class SAXParserFactoryImpl extends SAXParserFactory
-{
- @Override
- public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
- {
- return false;
- }
-
- @Override
- public SAXParser newSAXParser() throws ParserConfigurationException, SAXException
- {
- return null;
- }
-
- @Override
- public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
- {
- }
-}
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBean.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,43 @@
+/*
+ * 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.test.osgi.jbosgi108.bundleA;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class SomeBean implements SomeBeanMBean
+{
+ private static List<String> messages = new ArrayList<String>();
+
+ public void addMessage(String msg)
+ {
+ messages.add(msg);
+ }
+
+ public List<String> getMessages()
+ {
+ return Collections.unmodifiableList(messages);
+ }
+}
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleA/SomeBeanMBean.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,37 @@
+/*
+ * 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.test.osgi.jbosgi108.bundleA;
+
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+
+//$Id$
+
+public interface SomeBeanMBean
+{
+ ObjectName MBEAN_NAME = ObjectNameFactory.create("jboss.osgi:bean=SomeBean");
+
+ List<String> getMessages();
+}
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB)
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java 2009-07-14 09:41:15 UTC (rev 91196)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -1,47 +0,0 @@
-/*
- * 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.test.osgi.jbosgi108.bundleB;
-
-//$Id$
-
-import org.jboss.test.osgi.jbosgi108.bundleA.SomeBean;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class ActivatorBundleB implements BundleActivator
-{
- private SomeBean bean = new SomeBean();
-
- public void start(BundleContext context)
- {
- ClassLoader cl = getClass().getClassLoader();
- String msg = "start with " + cl + " - hashCode: " + cl.hashCode();
- bean.addMessage(msg);
- }
-
- public void stop(BundleContext context)
- {
- ClassLoader cl = getClass().getClassLoader();
- String msg = "stop with " + cl + " - hashCode: " + cl.hashCode();
- bean.addMessage(msg);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java (from rev 91196, projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi108/bundleB/ActivatorBundleB.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,47 @@
+/*
+ * 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.test.osgi.jbosgi108.bundleB;
+
+//$Id$
+
+import org.jboss.test.osgi.jbosgi108.bundleA.SomeBean;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class ActivatorBundleB implements BundleActivator
+{
+ private SomeBean bean = new SomeBean();
+
+ public void start(BundleContext context)
+ {
+ ClassLoader cl = getClass().getClassLoader();
+ String msg = "start with " + cl + " - hashCode: " + cl.hashCode();
+ bean.addMessage(msg);
+ }
+
+ public void stop(BundleContext context)
+ {
+ ClassLoader cl = getClass().getClassLoader();
+ String msg = "stop with " + cl + " - hashCode: " + cl.hashCode();
+ bean.addMessage(msg);
+ }
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,81 @@
+/*
+ * 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.test.osgi.jbosgi92;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * [JBOSGI-92] Class.forName issue with XMLParserActivator
+ *
+ * https://jira.jboss.org/jira/browse/JBOSGI-92
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 21-Jul-2009
+ */
+public class OSGI92TestCase
+{
+ private static OSGiRuntime runtime;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ runtime = new OSGiTestHelper().getDefaultRuntime();
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ if (runtime != null)
+ runtime.shutdown();
+ }
+
+ @Test
+ public void testDeployParsers() throws Exception
+ {
+ OSGiBundle bundleA = runtime.installBundle("jbosgi92-bundleA.jar");
+ bundleA.start();
+
+ assertEquals(Bundle.ACTIVE, bundleA.getState());
+
+ String filter = "(parser.factoryname=org.jboss.test.osgi.jbosgi92.bundleA.*)";
+ OSGiServiceReference[] domRefs = runtime.getServiceReferences(DocumentBuilderFactory.class.getName(), filter);
+ assertEquals("DocumentBuilderFactory servce available", 1, domRefs.length);
+
+ OSGiServiceReference[] saxRefs = runtime.getServiceReferences(SAXParserFactory.class.getName(), filter);
+ assertEquals("SAXParserFactory servce available", 1, saxRefs.length);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/OSGI92TestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,88 @@
+/*
+ * 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.test.osgi.jbosgi92.bundleA;
+
+//$Id$
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.xml.XMLParserActivator;
+
+public class ActivatorBundleA extends XMLParserActivator
+{
+ private LogService log;
+
+ public void start(BundleContext context) throws Exception
+ {
+ log = new LogServiceTracker(context);
+
+ super.start(context);
+
+ logSAXParserFactory(context);
+ logDOMParserFactory(context);
+ }
+
+ private void logSAXParserFactory(BundleContext context)
+ {
+ ServiceReference saxRef = context.getServiceReference(SAXParserFactory.class.getName());
+ if (saxRef != null)
+ {
+ Object factory = context.getService(saxRef);
+ log.log(LogService.LOG_INFO, "SAXParserFactory: " + factory.getClass().getName());
+
+ for (String key : saxRef.getPropertyKeys())
+ {
+ Object value = saxRef.getProperty(key);
+ log.log(LogService.LOG_INFO, " " + key + "=" + value);
+ }
+ }
+ else
+ {
+ log.log(LogService.LOG_WARNING, "No SAXParserFactory registered");
+ }
+ }
+
+ private void logDOMParserFactory(BundleContext context)
+ {
+ ServiceReference domRef = context.getServiceReference(DocumentBuilderFactory.class.getName());
+ if (domRef != null)
+ {
+ Object factory = context.getService(domRef);
+ log.log(LogService.LOG_INFO, "DocumentBuilderFactory: " + factory.getClass().getName());
+
+ for (String key : domRef.getPropertyKeys())
+ {
+ Object value = domRef.getProperty(key);
+ log.log(LogService.LOG_INFO, " " + key + "=" + value);
+ }
+ }
+ else
+ {
+ log.log(LogService.LOG_WARNING, "No DocumentBuilderFactory registered");
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/ActivatorBundleA.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,59 @@
+/*
+ * 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.test.osgi.jbosgi92.bundleA;
+
+//$Id$
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory
+{
+ @Override
+ public Object getAttribute(String name) throws IllegalArgumentException
+ {
+ return null;
+ }
+
+ @Override
+ public boolean getFeature(String name) throws ParserConfigurationException
+ {
+ return false;
+ }
+
+ @Override
+ public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException
+ {
+ return null;
+ }
+
+ @Override
+ public void setAttribute(String name, Object value) throws IllegalArgumentException
+ {
+ }
+
+ @Override
+ public void setFeature(String name, boolean value) throws ParserConfigurationException
+ {
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/DocumentBuilderFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java 2009-07-21 19:48:28 UTC (rev 91513)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.osgi.jbosgi92.bundleA;
+
+//$Id$
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+public class SAXParserFactoryImpl extends SAXParserFactory
+{
+ @Override
+ public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
+ {
+ return false;
+ }
+
+ @Override
+ public SAXParser newSAXParser() throws ParserConfigurationException, SAXException
+ {
+ return null;
+ }
+
+ @Override
+ public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
+ {
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi92/bundleA/SAXParserFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jboss-cvs-commits
mailing list