ExceptionUtil { public static boolean isInvalidSessionId(final String message) { return isExceptionMsg(INVALID_SESSION_ID, message); } 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_isInvalidSessionId_String() { Assert.assertFalse("Should not be an invalid session id", ExceptionUtil.isInvalidSessionId((String) null)); Assert.assertFalse("Should not be an invalid session id", ExceptionUtil.isInvalidSessionId("test a")); Assert.assertTrue("Should be an invalid session id", ExceptionUtil.isInvalidSessionId(" foo " + ExceptionUtil.INVALID_SESSION_ID + " bar ")); Assert.assertTrue("Should be an invalid session id", ExceptionUtil.isInvalidSessionId(" foo " + ExceptionUtil.INVALID_SESSION_ID)); Assert.assertTrue("Should be an invalid session id", ExceptionUtil.isInvalidSessionId(ExceptionUtil.INVALID_SESSION_ID + "bar")); Assert.assertTrue("Should be an invalid session id", ExceptionUtil.isInvalidSessionId(ExceptionUtil.INVALID_SESSION_ID)); }
@Test public void test_isInvalidSessionId_Throwable() { Assert.assertFalse("Should not be an exception msg", ExceptionUtil.isInvalidSessionId(new RuntimeException("hello world"))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isInvalidSessionId(new RuntimeException(" foo " + ExceptionUtil.INVALID_SESSION_ID + " bar "))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isInvalidSessionId(new RuntimeException(" foo " + ExceptionUtil.INVALID_SESSION_ID))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isInvalidSessionId(new RuntimeException(ExceptionUtil.INVALID_SESSION_ID + "bar"))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isInvalidSessionId(new RuntimeException(ExceptionUtil.INVALID_SESSION_ID))); Assert.assertFalse("Should not be an exception msg", ExceptionUtil.isInvalidSessionId(new InvocationTargetException(new RuntimeException("hello world")))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isInvalidSessionId(new InvocationTargetException(new RuntimeException(" foo " + ExceptionUtil.INVALID_SESSION_ID + " bar ")))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isInvalidSessionId(new InvocationTargetException(new RuntimeException(" foo " + ExceptionUtil.INVALID_SESSION_ID)))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isInvalidSessionId(new InvocationTargetException(new RuntimeException(ExceptionUtil.INVALID_SESSION_ID + "bar")))); Assert.assertTrue("Should be an exception msg", ExceptionUtil.isInvalidSessionId(new InvocationTargetException(new RuntimeException(ExceptionUtil.INVALID_SESSION_ID)))); }