[jboss-cvs] JBossAS SVN: r69980 - projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 20 12:53:53 EST 2008
Author: adrian at jboss.org
Date: 2008-02-20 12:53:53 -0500 (Wed, 20 Feb 2008)
New Revision: 69980
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java
Log:
Add some methods for getting/asserting beans using type safe api
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java 2008-02-20 17:53:38 UTC (rev 69979)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java 2008-02-20 17:53:53 UTC (rev 69980)
@@ -103,6 +103,35 @@
{
return getMCDelegate().getBean(name, state);
}
+
+ /**
+ * Get a bean
+ *
+ * @param <T> the expected type
+ * @param name the name of the bean
+ * @param state the state of the bean
+ * @param expected the expected type
+ * @return the bean
+ * @throws IllegalStateException when the bean does not exist at that state
+ */
+ protected <T> T assertBean(Object name, ControllerState state, Class<T> expected)
+ {
+ return getMCDelegate().getBean(name, state, expected);
+ }
+
+ /**
+ * Get a bean
+ *
+ * @param <T> the expected type
+ * @param name the name of the bean
+ * @param expected the expected type
+ * @return the bean
+ * @throws IllegalStateException when the bean does not exist at that state
+ */
+ protected <T> T assertBean(Object name, Class<T> expected)
+ {
+ return assertBean(name, ControllerState.INSTALLED, expected);
+ }
/**
* Get a context
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java 2008-02-20 17:53:38 UTC (rev 69979)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java 2008-02-20 17:53:53 UTC (rev 69980)
@@ -157,6 +157,24 @@
}
/**
+ * Get a bean
+ *
+ * @param <T> the expected type
+ * @param name the name of the bean
+ * @param state the state of the bean
+ * @param expected the expected type
+ * @return the bean
+ * @throws IllegalStateException when the bean does not exist at that state
+ */
+ protected <T> T getBean(final Object name, final ControllerState state, final Class<T> expected)
+ {
+ if (expected == null)
+ throw new IllegalArgumentException("Null expected");
+ Object bean = getBean(name, state);
+ return expected.cast(bean);
+ }
+
+ /**
* Get the metadata repository
* @return the metadata repository
* @throws IllegalStateException when the bean does not exist at that state
More information about the jboss-cvs-commits
mailing list