0 Replies Latest reply on Mar 19, 2008 10:46 AM by Ales Justin

    AbstractTestCase::assterInstanceOf is broken

    Ales Justin Master

      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. :-)