List of usage examples for java.lang InterruptedException toString
public String toString()
From source file:hochschuledarmstadt.photostream_tools.ApiRequestsFailTest.java
@Test public void deletePhoto() throws IOException, BaseAsyncTask.HttpPhotoStreamException { HttpDeleteExecutor executor = createMockHttpDeleteExecutor(); final int photoId = INVALID_PHOTO_ID; DeletePhotoAsyncTask.OnDeletePhotoResultListener callback = mock( DeletePhotoAsyncTask.OnDeletePhotoResultListener.class); DeletePhotoAsyncTask deletePhotoAsyncTask = new DeletePhotoAsyncTask(executor, photoId, callback); deletePhotoAsyncTask.execute();/* w w w. j a va 2s.c om*/ Robolectric.flushBackgroundThreadScheduler(); try { deletePhotoAsyncTask.get(); verify(callback, times(1)).onPhotoDeleteFailed(eq(photoId), any(HttpError.class)); } catch (InterruptedException e) { fail(e.toString()); } catch (ExecutionException e) { fail(e.toString()); } }
From source file:hochschuledarmstadt.photostream_tools.ApiRequestsFailTest.java
@Test public void uploadComment() throws IOException, BaseAsyncTask.HttpPhotoStreamException { HttpPostExecutor executor = createMockHttpPostExecutor(); final int photoId = INVALID_PHOTO_ID; StoreCommentAsyncTask.OnCommentSentListener listener = mock( StoreCommentAsyncTask.OnCommentSentListener.class); StoreCommentAsyncTask storeCommentAsyncTask = new StoreCommentAsyncTask(executor, photoId, "this will fail", listener);/*from w w w. ja v a2 s . c o m*/ storeCommentAsyncTask.execute(); Robolectric.flushBackgroundThreadScheduler(); try { storeCommentAsyncTask.get(); verify(listener, times(1)).onSendCommentFailed(any(HttpError.class)); } catch (InterruptedException e) { fail(e.toString()); } catch (ExecutionException e) { fail(e.toString()); } }
From source file:hochschuledarmstadt.photostream_tools.ApiRequestsFailTest.java
@Test public void searchPhotos() throws IOException, BaseAsyncTask.HttpPhotoStreamException { HttpGetExecutor executor = createMockHttpGetExecutor(); SearchPhotosAsyncTask.OnSearchPhotosResultCallback callback = mock( SearchPhotosAsyncTask.OnSearchPhotosResultCallback.class); SearchPhotosAsyncTask searchPhotosAsyncTask = new SearchPhotosAsyncTask(executor, imageLoaderStub, imageCacherStub, callback);//from w w w . j a v a 2 s . c o m searchPhotosAsyncTask.execute(); Robolectric.flushBackgroundThreadScheduler(); try { searchPhotosAsyncTask.get(); verify(callback, times(1)).onSearchPhotosError(any(HttpError.class)); } catch (InterruptedException e) { assertFalse(e.toString(), true); } catch (ExecutionException e) { assertFalse(e.toString(), true); } }
From source file:se.lu.nateko.edca.svc.GetMap.java
/** * Method run in a separate worker thread when GetMap.execute() is called. * Takes the server info from the ServerConnection supplied and stores it as a URI. * @param srvs An array of ServerConnection objects from which to form the URI. May only contain 1. *//*from w w w.ja v a 2 s . c o m*/ @Override protected GetMap doInBackground(ServerConnection... srvs) { // Log.d(TAG, "doInBackground(ServerConnection...) called."); mService.startAnimation(); // Start the animation, showing that a web communicating thread is active. mServerConnection = srvs[0]; // Stores the ServerConnection info. /* Make the GetMap request to the server and record the success state. */ try { // Get or wait for exclusive access to the HttpClient. mHttpClient = mService.getHttpClient(); } catch (InterruptedException e) { Log.e(TAG, "Thread " + Thread.currentThread().getId() + ": " + e.toString()); } mHasResponse = (getMapRequest() == RESULT_FAILURE) ? false : true; mService.unlockHttpClient(); // Release the lock on the HttpClient, allowing new connections to be made. Log.v(TAG, "GetMap request succeeded: " + String.valueOf(mHasResponse)); return this; }
From source file:org.hawkular.apm.tests.dockerized.TestScenarioRunner.java
/** * Run single test case/*from w ww .ja v a2 s . co m*/ * * @param testScenario Test scenario of the test case * @param testCase Test case to run * @param testEnvironmentExecutor Initialized environment * @throws TestFailException */ private void runTestCase(TestScenario testScenario, TestCase testCase, TestEnvironmentExecutor testEnvironmentExecutor) throws TestFailException { log.info(String.format("Executing test case: %s", testCase)); List<String> environmentId = null; ApmMockServer apmServer = new ApmMockServer(); apmServer.setHost("0.0.0.0"); apmServer.setPort(apmServerPort); // disable shut down timer apmServer.setShutdownTimer(60 * 60 * 1000); try { /** * Create network if necessary */ if (testScenario.getEnvironment().getApmAddress() != null) { testEnvironmentExecutor.createNetwork(); } /** * Start APM server */ apmServer.run(); /** * Run a container and wait */ environmentId = testEnvironmentExecutor.run(testScenario.getEnvironment()); Thread.sleep(testScenario.getEnvironment().getInitWaitSeconds() * 1000); /** * Execute test script and wait */ testEnvironmentExecutor.execScript(environmentId, testCase.getScriptServiceName(), testCase.getAction()); Thread.sleep(testCase.getAfterActionWaitSeconds() * 1000); /** * verify results */ Collection<JsonPathVerify> jsonPathVerifies = verifyResults(testScenario, testCase, apmServer); if (!jsonPathVerifies.isEmpty()) { throw new TestFailException(testCase, jsonPathVerifies); } } catch (InterruptedException ex) { log.severe("Interruption exception"); log.severe(ex.toString()); throw new TestFailException(testCase, ex); } finally { if (environmentId != null) { testEnvironmentExecutor.stopAndRemove(environmentId); } if (apmServer != null) { apmServer.shutdown(); } } }
From source file:org.fabrican.extension.variable.provider.servlet.ManagementServlet.java
@Override protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Pair<String, String> params = gePathParams(req); String cmd = params.left();//from ww w . j a v a 2 s .c o m String name = params.right(); RuleSetDAO dao = RuleSetDAO.getInstance(); try { switch (cmd) { case "providers": if (name == null || name.trim().length() == 0) { resp.setStatus(400); output(resp, "missing provider identity"); } else { if (dao.removeRuleSet(name)) { resp.setStatus(200); //output(resp, getListJSON(dao).toString()); } else { resp.setStatus(404); output(resp, "failed to delete"); } } return; } } catch (InterruptedException ex) { resp.setStatus(500); output(resp, ex.toString()); } catch (SQLException e) { resp.setStatus(500); output(resp, e.toString()); //} catch (JSONException e) { // resp.setStatus(500); // output(resp, e.toString()); } resp.setStatus(400); output(resp, "unrecognized request"); }
From source file:com.ardnezar.lookapp.WebSocketChannelClient.java
public void disconnect(boolean waitForComplete) { checkIfCalledOnValidThread();/* w w w.j a va2s .c o m*/ Log.d(TAG, "Disonnect WebSocket. State: " + state); if (state == WebSocketConnectionState.REGISTERED) { // Send "bye" to WebSocket server. send("{\"type\": \"bye\"}"); state = WebSocketConnectionState.CONNECTED; // Send http DELETE to http WebSocket server. sendWSSMessage("DELETE", ""); } // Close WebSocket in CONNECTED or ERROR states only. if (state == WebSocketConnectionState.CONNECTED || state == WebSocketConnectionState.ERROR) { ws.disconnect(); state = WebSocketConnectionState.CLOSED; // Wait for websocket close event to prevent websocket library from // sending any pending messages to deleted looper thread. if (waitForComplete) { synchronized (closeEventLock) { while (!closeEvent) { try { closeEventLock.wait(CLOSE_TIMEOUT); break; } catch (InterruptedException e) { Log.e(TAG, "Wait error: " + e.toString()); } } } } } Log.d(TAG, "Disonnecting WebSocket done."); }
From source file:org.openhab.binding.ebus.internal.EBusBinding.java
public void activate() { super.activate(); logger.debug("eBus binding has been started."); // check to ensure that it is available checkConfigurationProvider();/* w w w .ja v a 2 s .co m*/ // observe connection, if not started 15 sec. later than start it manually // replacing a bundle doesn't recall update function, more // a bug/enhancement in openhab new Thread() { @Override public void run() { try { sleep(15000); if (connector == null) { logger.warn("eBus connector still not started, started it yet!"); Configuration configuration = configurationAdminService.getConfiguration("org.openhab.ebus", null); if (configuration != null) { updated(configuration.getProperties()); for (EBusBindingProvider provider : EBusBinding.this.providers) { commandProcessor.allBindingsChanged(provider); } } } } catch (InterruptedException e) { logger.error(e.toString(), e); } catch (ConfigurationException e) { logger.error(e.toString(), e); } catch (IOException e) { logger.error(e.toString(), e); } } }.start(); ; }
From source file:org.jenkinsci.plugins.testrail.TestRailClient.java
private TestRailResponse httpGet(String path) throws IOException { TestRailResponse response;/* w ww . j ava 2 s . c o m*/ do { response = httpGetInt(path); if (response.getStatus() == 429) { try { Thread.sleep(60000); } catch (InterruptedException e) { log(e.toString()); } } } while (response.getStatus() == 429); return response; }
From source file:org.jenkinsci.plugins.testrail.TestRailClient.java
private TestRailResponse httpPost(String path, String payload) throws UnsupportedEncodingException, IOException, HTTPException, TestRailException { TestRailResponse response;/*from w ww . j a va 2 s. c om*/ do { response = httpPostInt(path, payload); if (response.getStatus() == 429) { try { Thread.sleep(60000); } catch (InterruptedException e) { log(e.toString()); } } } while (response.getStatus() == 429); if (response.getStatus() != 200) { // any status code other than 200 is an error throw new TestRailException("Posting to " + path + " returned an error! Response from TestRail is: \n" + response.getBody()); } return response; }