ExceptionUtil { public static boolean isExceptionMsg(final String toCompare, final String message) { return (null == message ? false : message.contains(toCompare)); } private  ExceptionUtil(); static boolean isExceptionMsg(final String toCompare, final String message); static boolean isExceptionMsg(final String toCompare, final Throwable failure); static boolean isInvalidSessionId(final String message); static boolean isInvalidSessionId(final Throwable failure); static boolean isServerUnavailable(final String message, final int[] retryIssues); static boolean isServerUnavailable(final Throwable failure, final int[] retryIssues); static boolean isServiceUnavailable(final Throwable failure, final int[] retryIssues); static boolean isUnableToLockRow(final Throwable failure, final int[] retryIssues); static boolean isReloginException(final Throwable failure, final int[] retryIssues); static boolean isRetryException(final Throwable failure, final int[] retryIssues); static final String INVALID_SESSION_ID; static final int INVALID_SESSION_INDEX; static final String SERVER_UNAVAILABLE; static final int SERVER_UNAVAILABLE_INDEX; static final String SERVICE_UNAVAILABLE; static final int SERVICE_UNAVAILABLE_INDEX; static final String UNABLE_TO_LOCK_ROW; static final int UNABLE_TO_LOCK_ROW_INDEX; }
@Test public void test_isExceptionMsg_String_String() { Assert.assertFalse("Should not be an exception msg", ExceptionUtil.isExceptionMsg("test a", (String) null)); Assert.assertFalse("Should not be an exception msg", ExceptionUtil.isExceptionMsg("test b", "try 1")); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isExceptionMsg("test c", "try 2 test c lmn")); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isExceptionMsg("test d", "test d lmn")); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isExceptionMsg("test e", "try 2 test e")); }
@Test public void test_isExceptionMsg_String_Throwable() { Assert.assertFalse("Should not be an exception msg", ExceptionUtil.isExceptionMsg("test a", new RuntimeException("hello world"))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isExceptionMsg("test c", new RuntimeException("try 2 test c lmn"))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isExceptionMsg("test d", new RuntimeException("test d lmn"))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isExceptionMsg("test e", new RuntimeException("try 2 test e"))); Assert.assertFalse("Should not be an exception msg", ExceptionUtil.isExceptionMsg("test a", new InvocationTargetException(new RuntimeException("hello world")))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isExceptionMsg("test c", new InvocationTargetException(new RuntimeException("try 2 test c lmn")))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isExceptionMsg("test d", new InvocationTargetException(new RuntimeException("test d lmn")))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isExceptionMsg("test e", new InvocationTargetException(new RuntimeException("try 2 test e")))); }