[jboss-dev-forums] [Design the new POJO MicroContainer] - AbstractTestCase::assterInstanceOf is broken

alesj do-not-reply at jboss.com
Wed Mar 19 10:46:43 EDT 2008


Dunno how this slipped by us for so long:

  |    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());
  |          // should not reach this
  |          return null;
  |       }
  |    }
  | 
What about if allowNull == false and o == null? :-(

A test for test required. :-)

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

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



More information about the jboss-dev-forums mailing list