### Question:
TransactionServiceCheck extends Check { @Override public void run() throws Exception { LOG.info("Validating transaction service configuration."); int defaultTxTimeout = getConfiguredInteger(TxConstants.Manager.CFG_TX_TIMEOUT, "Default transaction timeout"); int maxTxTimeout = getConfiguredInteger(TxConstants.Manager.CFG_TX_MAX_TIMEOUT, "Transaction timeout limit"); if (defaultTxTimeout > maxTxTimeout) { throw new IllegalArgumentException(String.format( "Default transaction timeout (%s) of %d seconds must not exceed the transaction timeout limit (%s) of %d", TxConstants.Manager.CFG_TX_TIMEOUT, defaultTxTimeout, TxConstants.Manager.CFG_TX_MAX_TIMEOUT, maxTxTimeout)); } LOG.info("Transaction service configuration successfully validated."); } @Inject  TransactionServiceCheck(CConfiguration cConf);  TransactionServiceCheck(Configuration hConf); @Override void run();  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testDefaultNotConfigured() throws Exception { CConfiguration cConfiguration = CConfiguration.create(); cConfiguration.unset(TxConstants.Manager.CFG_TX_TIMEOUT); run(cConfiguration); }
@Test(expected = IllegalArgumentException.class) public void testDefaultNotInteger() throws Exception { CConfiguration cConfiguration = CConfiguration.create(); cConfiguration.set(TxConstants.Manager.CFG_TX_TIMEOUT, "NaN"); run(cConfiguration); }
@Test(expected = IllegalArgumentException.class) public void testMaxNotConfigured() throws Exception { CConfiguration cConfiguration = CConfiguration.create(); cConfiguration.unset(TxConstants.Manager.CFG_TX_MAX_TIMEOUT); run(cConfiguration); }
@Test(expected = IllegalArgumentException.class) public void testMaxNotInteger() throws Exception { CConfiguration cConfiguration = CConfiguration.create(); cConfiguration.set(TxConstants.Manager.CFG_TX_MAX_TIMEOUT, "NaN"); run(cConfiguration); }
@Test(expected = IllegalArgumentException.class) public void testDefaultExceedsMax() throws Exception { CConfiguration cConfiguration = CConfiguration.create(); cConfiguration.setInt(TxConstants.Manager.CFG_TX_TIMEOUT, cConfiguration.getInt(TxConstants.Manager.CFG_TX_MAX_TIMEOUT) + 5); run(cConfiguration); }