Package org.djunits

Class Try


  • public abstract class Try
    extends Object
    Use the Try class as follows:
     new Try(
       public @Override void execute()
       {
         // code to test that should fail
       }).test();
     

    Copyright (c) 2019-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See DJUNITS License.

    Author:
    Alexander Verbraeck
    • Constructor Detail

      • Try

        public Try()
    • Method Detail

      • execute

        public abstract void execute()
        implement the execute method to test failure.
      • test

        public void test()
        call the test method to test failure of the try.
      • test

        public void test​(String message)
        call the test method to test failure of the try.
        Parameters:
        message - the message to print
      • test

        public void test​(String message,
                         Class<? extends Exception> expectedExceptionClass)
        call the test method to test failure of the try with an expected exception type.
        Parameters:
        message - the message to print
        expectedExceptionClass - the expected exception