| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -168,6 +168,44 @@ public void exec(HttpURLConnection res, Exception ex) { | |||
| 168 | 168 | assertNotNull(status.getStackTrace()); | |
| 169 | 169 | } | |
| 170 | 170 | ||
| 171 | + public void test_Does_handle_401_Error_with_empty_ResponseBody() { | ||
| 172 | + JsonServiceClient testClient = new JsonServiceClient("http://test.servicestack.net"); | ||
| 173 | + | ||
| 174 | + final Exception[] globalError = new Exception[1]; //Wow Java, you suck. | ||
| 175 | + final Exception[] localError = new Exception[1]; | ||
| 176 | + WebServiceException thrownError = null; | ||
| 177 | + | ||
| 178 | + JsonServiceClient.GlobalExceptionFilter = new ExceptionFilter() { | ||
| 179 | + @Override | ||
| 180 | + public void exec(HttpURLConnection res, Exception ex) { | ||
| 181 | + globalError[0] = ex; | ||
| 182 | + } | ||
| 183 | + }; | ||
| 184 | + | ||
| 185 | + testClient.ExceptionFilter = new ExceptionFilter() { | ||
| 186 | + @Override | ||
| 187 | + public void exec(HttpURLConnection res, Exception ex) { | ||
| 188 | + localError[0] = ex; | ||
| 189 | + } | ||
| 190 | + }; | ||
| 191 | + | ||
| 192 | + TestAuth request = new TestAuth(); | ||
| 193 | + | ||
| 194 | + try { | ||
| 195 | + TestAuthResponse response = testClient.send(request); | ||
| 196 | + } | ||
| 197 | + catch (WebServiceException webEx){ | ||
| 198 | + thrownError = webEx; | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + assertNotNull(globalError[0]); | ||
| 202 | + assertNotNull(localError[0]); | ||
| 203 | + assertNotNull(thrownError); | ||
| 204 | + | ||
| 205 | + ResponseStatus status = thrownError.getResponseStatus(); | ||
| 206 | + assertNull(status); | ||
| 207 | + } | ||
| 208 | + | ||
| 171 | 209 | public void test_Does_handle_ValidationException(){ | |
| 172 | 210 | ThrowValidation request = new ThrowValidation() | |
| 173 | 211 | .setEmail("invalidemail"); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments