[jboss-cvs] JBossAS SVN: r94544 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi: bundle/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 9 03:59:20 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-09 03:59:20 -0400 (Fri, 09 Oct 2009)
New Revision: 94544
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java
Log:
Improve event delivery assertion
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java 2009-10-09 07:37:48 UTC (rev 94543)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java 2009-10-09 07:59:20 UTC (rev 94544)
@@ -447,7 +447,7 @@
protected void assertFrameworkEvent(int type, Bundle bundle, Class<? extends Throwable> expectedThrowable) throws Exception
{
- waitForEvents(frameworkEvents);
+ waitForEvent(frameworkEvents, type);
getLog().debug("frameworkEvents=" + frameworkEvents);
int size = frameworkEvents.size();
assertTrue("" + size, size > 0);
@@ -489,7 +489,7 @@
protected void assertBundleEvent(int type, Bundle bundle) throws Exception
{
- waitForEvents(bundleEvents);
+ waitForEvent(bundleEvents, type);
getLog().debug("bundleEvents=" + bundleEvents);
int size = bundleEvents.size();
@@ -535,7 +535,7 @@
protected void assertServiceEvent(int type, ServiceReference reference) throws Exception
{
- waitForEvents(serviceEvents);
+ waitForEvent(serviceEvents, type);
getLog().debug("serviceEvents=" + serviceEvents);
int size = serviceEvents.size();
assertTrue("" + size, size > 0);
@@ -546,18 +546,47 @@
}
@SuppressWarnings("unchecked")
- private void waitForEvents(List events) throws InterruptedException
+ private void waitForEvent(List events, int type) throws InterruptedException
{
// Timeout for event delivery: 3 sec
int timeout = 30;
- while (events.size() == 0 && 0 < timeout)
+ boolean eventFound = false;
+ while (eventFound == false && 0 < timeout)
{
synchronized (events)
{
events.wait(100);
- if (events.size() > 0)
- break;
+ for (Object aux : events)
+ {
+ if (aux instanceof BundleEvent)
+ {
+ BundleEvent event = (BundleEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ else if (aux instanceof ServiceEvent)
+ {
+ ServiceEvent event = (ServiceEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ else if (aux instanceof FrameworkEvent)
+ {
+ FrameworkEvent event = (FrameworkEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ }
}
timeout--;
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java 2009-10-09 07:37:48 UTC (rev 94543)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java 2009-10-09 07:59:20 UTC (rev 94544)
@@ -408,6 +408,7 @@
{
uninstall(bundle);
}
+ assertBundleEvent(BundleEvent.STOPPING, bundle);
assertBundleEvent(BundleEvent.STOPPED, bundle);
// todo assertBundleEvent(BundleEvent.UNRESOLVED, bundle);
assertBundleEvent(BundleEvent.UNINSTALLED, bundle);
More information about the jboss-cvs-commits
mailing list