Package org.djunits

Class Try

java.lang.Object
org.djunits.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 Summary

    Constructors 
    Constructor Description
    Try()  
  • Method Summary

    Modifier and Type Method Description
    abstract void execute()
    implement the execute method to test failure.
    void test()
    call the test method to test failure of the try.
    void test​(String message)
    call the test method to test failure of the try.
    void test​(String message, Class<? extends Exception> expectedExceptionClass)
    call the test method to test failure of the try with an expected exception type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Try

      public Try()
  • Method Details

    • 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