[jboss-cvs] JBossAS SVN: r97226 - projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 1 08:36:31 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-12-01 08:36:31 -0500 (Tue, 01 Dec 2009)
New Revision: 97226
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
Log:
Pull up test assertions
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2009-12-01 13:12:44 UTC (rev 97225)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2009-12-01 13:36:31 UTC (rev 97226)
@@ -31,6 +31,7 @@
import org.jboss.virtual.VirtualFile;
import org.junit.After;
import org.junit.Before;
+import org.osgi.framework.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -211,4 +212,14 @@
{
return getTestHelper().assembleBundle(name, resources, packages);
}
+
+ public void assertBundleState(int expState, int wasState)
+ {
+ getTestHelper().assertBundleState(expState, wasState);
+ }
+
+ public void assertBundleLoadClass(Bundle bundle, String expClazz, boolean success)
+ {
+ getTestHelper().assertBundleLoadClass(bundle, expClazz, success);
+ }
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-12-01 13:12:44 UTC (rev 97225)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2009-12-01 13:36:31 UTC (rev 97226)
@@ -21,6 +21,9 @@
*/
package org.jboss.osgi.testing;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
@@ -33,11 +36,13 @@
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.osgi.testing.internal.EmbeddedRuntime;
import org.jboss.osgi.testing.internal.RemoteRuntime;
import org.jboss.virtual.AssembledDirectory;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
/**
* An OSGi Test Helper
@@ -223,6 +228,37 @@
return assembledDirectory;
}
+ public void assertBundleState(int expState, int wasState)
+ {
+ String expstr = ConstantsHelper.bundleState(expState);
+ String wasstr = ConstantsHelper.bundleState(wasState);
+ assertEquals("Bundle " + expstr, expstr, wasstr);
+ }
+
+ public void assertBundleLoadClass(Bundle bundle, String expClazz, boolean success)
+ {
+ String message = bundle.getSymbolicName() + " loads " + expClazz;
+
+ Class<?> wasClass;
+ try
+ {
+ wasClass = bundle.loadClass(expClazz);
+ if (success)
+ {
+ assertEquals(message, expClazz, wasClass.getName());
+ }
+ else
+ {
+ fail("ClassNotFoundException expected for: " + message + "\nLoaded from " + wasClass.getClassLoader());
+ }
+ }
+ catch (ClassNotFoundException ex)
+ {
+ if (success)
+ fail("Unexpected ClassNotFoundException for: " + message);
+ }
+ }
+
private void addPath(AssembledDirectory dir, String path, String name) throws Exception
{
URL url = getClass().getResource(path);
More information about the jboss-cvs-commits
mailing list