[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: serializable KernelDeployment

alesj do-not-reply at jboss.com
Tue Jan 23 07:37:56 EST 2007


"adrian at jboss.org" wrote : "alesj" wrote : 
  |   | So if our returned MetaData is non-Serializable, we should throw exception (since we want all our MD to be serializable, right?)?
  |   | 
  | 
  | Correct.
  | 

Ok, for MetaData there is no problem.
What do we do with JavaBeans (which now fail - since with wildcard test's we use plain java.lang.Object)?

anonymous wrote : 
  | This is a candidate for AbstractTestCase in the jboss-test project.
  | 
  | 
  |   |    /**
  |   |     * Check we have the expected type
  |   |     * 
  |   |     * @param <T> the expected type
  |   |     * @param o the object
  |   |     * @param expectedType the excepted class of the exception
  |   |     * @return the expected type
  |   |     */
  |   |    protected <T> T assertInstanceOf(Object o, Class<T> expectedType)
  |   |    {
  |   |       return assertInstanceOf(o, expectedType, true);
  |   |    }
  |   | 
  |   |    /**
  |   |     * Check we have the expected type
  |   |     * 
  |   |     * @param <T> the expected type
  |   |     * @param o the object
  |   |     * @param expectedType the excepted class of the exception
  |   |     * @param allowNull whether the object can be null
  |   |     * @return the expected type
  |   |     */
  |   |    protected <T> T assertInstanceOf(Object o, Class<T> expectedType, boolean allowNull)
  |   |    {
  |   |       if (expectedType == null)
  |   |          fail("Null expectedType");
  |   | 
  |   |       if (o == null && allowNull)
  |   |          return null;
  |   | 
  |   |       try
  |   |       {
  |   |          return expectedType.cast(o);
  |   |       }
  |   |       catch (ClassCastException e)
  |   |       {
  |   |          fail("Object " + o + " of class " + o.getClass().getName() + " is not an instanceof " + expectedType.getName());
  |   |       }
  |   |    }
  |   | 

Cool.
I added this code to test project.
Will use it in MC once I update test snapshot.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4005296#4005296

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4005296



More information about the jboss-dev-forums mailing list