001package org.hl7.fhir.utilities;
002
003/**
004 * A few places in the code, we call System.exit(int) to pass on the exit code to 
005 * other tools (for integration in scripts)
006 * 
007 * But you don't want to do that while running the failing things under JUnit 
008 * This class does two things 
009 * 
010 * * Remember the exit code while shutdown / cleanup happens 
011 * * Allow for a test case to turn exiting off altogther 
012 *  
013 * @author grahamegrieve
014 *
015 */
016public class SystemExitManager {
017
018  private static int error;
019  private static boolean noExit;
020
021  public static int getError() {
022    return error;
023  }
024
025  public static void setError(int error) {
026    SystemExitManager.error = error;
027  }
028
029  public static boolean isNoExit() {
030    return noExit;
031  }
032
033  public static void setNoExit(boolean noExit) {
034    SystemExitManager.noExit = noExit;
035  }
036
037  public static void finish() {
038    if (!noExit && error > 0) {
039      System.exit(error);
040    }
041  }
042
043}