Improve error reporting
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 4 Jun 2009 17:48:20 +0000 (17:48 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 4 Jun 2009 17:48:20 +0000 (17:48 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@2470 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.support.equinox/src/test/java/org/argeo/slc/osgi/test/AbstractOsgiRuntimeTestCase.java

index 0874aae568cb49ce2b28de9638adc4e1132534d3..88c9f1af54dd14be9e2d454a2109c4bbe7536519 100644 (file)
@@ -5,6 +5,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.management.BadBinaryOpValueExpException;
+
 import junit.framework.TestCase;
 
 import org.apache.commons.logging.Log;
@@ -101,7 +103,9 @@ public abstract class AbstractOsgiRuntimeTestCase extends TestCase {
                long begin = System.currentTimeMillis();
                long duration = 0;
                boolean allBundlesOk = true;
+               StringBuffer badBundles = null;
                while (duration < getResolvedTimeout()) {
+                       badBundles = new StringBuffer();
                        for (Bundle bundle : bundleContext.getBundles()) {
                                if (bundle.getSymbolicName() != null
                                                && bundle.getSymbolicName().startsWith(
@@ -112,13 +116,23 @@ public abstract class AbstractOsgiRuntimeTestCase extends TestCase {
 
                                if (bundle.getState() == Bundle.INSTALLED) {
                                        allBundlesOk = false;
-                                       break;// for
+                                       badBundles
+                                                       .append(OsgiStringUtils
+                                                                       .nullSafeSymbolicName(bundle)
+                                                                       + " ["
+                                                                       + OsgiStringUtils
+                                                                                       .bundleStateAsString(bundle) + "]");
                                }
 
                                if (bundlesToStart.contains(bundle.getSymbolicName())
                                                && bundle.getState() != Bundle.ACTIVE) {
                                        allBundlesOk = false;
-                                       break;// for
+                                       badBundles
+                                                       .append(OsgiStringUtils
+                                                                       .nullSafeSymbolicName(bundle)
+                                                                       + " ["
+                                                                       + OsgiStringUtils
+                                                                                       .bundleStateAsString(bundle) + "]\n");
                                }
                        }
 
@@ -132,7 +146,8 @@ public abstract class AbstractOsgiRuntimeTestCase extends TestCase {
 
                if (!allBundlesOk) {
                        listInstalledBundles();
-                       throw new SlcException("Some bundles are in INSTALLED status");
+                       throw new SlcException(
+                                       "Some bundles are not at the proper status:\n" + badBundles);
                }
        }