public static boolean checkStatusForTimeout(QueryExceptionHTTP e) { int httpCode = e.getResponseCode(); // 408,504,524 timeout codes from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes return httpCode == 408 || httpCode == 504 || httpCode == 524; } }
public static boolean checkStatusForTimeout(QueryExceptionHTTP e) { int httpCode = e.getResponseCode(); // 408,504,524 timeout codes from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes return httpCode == 408 || httpCode == 504 || httpCode == 524; } }
@Override public String toString() { StringBuilder sb = new StringBuilder() ; sb.append("HttpException: ") ; int code = getResponseCode() ; if ( code != QueryExceptionHTTP.noResponseCode ) { sb.append(code) ; if ( getResponseMessage() != null ) { sb.append(" ") ; sb.append(getResponseMessage()) ; } } else { sb.append(getCause().toString()+": "+getMessage()) ; } return sb.toString() ; } }
private static void expectQuery(Runnable action, int expected) { try { action.run(); throw new HttpException("action completed"); } catch (QueryExceptionHTTP ex) { if ( ex.getResponseCode() != expected ) throw ex; } }
private static void expectQuery(Runnable action, int expected) { try { action.run(); throw new HttpException("action completed"); } catch (QueryExceptionHTTP ex) { if ( ex.getResponseCode() != expected ) throw ex; } }
private void queryHttp(int statusCode, String user, String password, String queryString) { try { query(user, password, queryString); if ( statusCode < 200 && statusCode > 299 ) fail("Should have responded with "+statusCode); } catch (QueryExceptionHTTP ex) { assertEquals(statusCode, ex.getResponseCode()); } }
private void queryHttp(int statusCode, String user, String password, String queryString) { try { query(user, password, queryString); if ( statusCode < 200 && statusCode > 299 ) fail("Should have responded with "+statusCode); } catch (QueryExceptionHTTP ex) { assertEquals(statusCode, ex.getResponseCode()); } }
throw new RuntimeException("Didn't fail"); } catch (QueryExceptionHTTP ex) { if ( ex.getResponseCode() != HttpSC.NOT_FOUND_404 ) { throw new RuntimeException("Not a 404", ex);
throw new RuntimeException("Didn't fail"); } catch (QueryExceptionHTTP ex) { if ( ex.getResponseCode() != HttpSC.NOT_FOUND_404 ) { throw new RuntimeException("Not a 404", ex);
throw new RuntimeException("Didn't fail"); } catch (QueryExceptionHTTP ex) { if ( ex.getResponseCode() != HttpSC.NOT_FOUND_404 ) { throw new RuntimeException("Not a 404", ex);