Example usage for java.lang InterruptedException toString

List of usage examples for java.lang InterruptedException toString

Introduction

In this page you can find the example usage for java.lang InterruptedException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.thoughtworks.go.agent.AgentProcessParentImpl.java

public int run(String launcherVersion, String launcherMd5, ServerUrlGenerator urlGenerator,
        Map<String, String> env, Map context) {
    int exitValue = 0;
    LOG.info("Agent is version: {}", CurrentGoCDVersion.getInstance().fullVersion());
    String command[] = new String[] {};

    try {/*www .j  a  v  a 2s . co m*/
        AgentBootstrapperArgs bootstrapperArgs = AgentBootstrapperArgs.fromProperties(context);
        File rootCertFile = bootstrapperArgs.getRootCertFile();
        SslVerificationMode sslVerificationMode = SslVerificationMode
                .valueOf(bootstrapperArgs.getSslMode().name());

        ServerBinaryDownloader agentDownloader = new ServerBinaryDownloader(urlGenerator, rootCertFile,
                sslVerificationMode);
        agentDownloader.downloadIfNecessary(DownloadableFile.AGENT);

        ServerBinaryDownloader pluginZipDownloader = new ServerBinaryDownloader(urlGenerator, rootCertFile,
                sslVerificationMode);
        pluginZipDownloader.downloadIfNecessary(DownloadableFile.AGENT_PLUGINS);

        ServerBinaryDownloader tfsImplDownloader = new ServerBinaryDownloader(urlGenerator, rootCertFile,
                sslVerificationMode);
        tfsImplDownloader.downloadIfNecessary(DownloadableFile.TFS_IMPL);

        command = agentInvocationCommand(agentDownloader.getMd5(), launcherMd5, pluginZipDownloader.getMd5(),
                tfsImplDownloader.getMd5(), env, context, agentDownloader.getExtraProperties());
        LOG.info("Launching Agent with command: {}", join(command, " "));

        Process agent = invoke(command);

        // The next lines prevent the child process from blocking on Windows

        AgentOutputAppender agentOutputAppenderForStdErr = new AgentOutputAppender(GO_AGENT_STDERR_LOG);
        AgentOutputAppender agentOutputAppenderForStdOut = new AgentOutputAppender(GO_AGENT_STDOUT_LOG);

        if (new SystemEnvironment().consoleOutToStdout()) {
            agentOutputAppenderForStdErr.writeTo(AgentOutputAppender.Outstream.STDERR);
            agentOutputAppenderForStdOut.writeTo(AgentOutputAppender.Outstream.STDOUT);
        }

        agent.getOutputStream().close();
        AgentConsoleLogThread stdErrThd = new AgentConsoleLogThread(agent.getErrorStream(),
                agentOutputAppenderForStdErr);
        stdErrThd.start();
        AgentConsoleLogThread stdOutThd = new AgentConsoleLogThread(agent.getInputStream(),
                agentOutputAppenderForStdOut);
        stdOutThd.start();

        Shutdown shutdownHook = new Shutdown(agent);
        Runtime.getRuntime().addShutdownHook(shutdownHook);
        try {
            exitValue = agent.waitFor();
        } catch (InterruptedException ie) {
            LOG.error("Agent was interrupted. Terminating agent and respawning. {}", ie.toString());
            agent.destroy();
        } finally {
            removeShutdownHook(shutdownHook);
            stdErrThd.stopAndJoin();
            stdOutThd.stopAndJoin();
        }
    } catch (Exception e) {
        LOG.error("Exception while executing command: {} - {}", join(command, " "), e.toString());
        exitValue = EXCEPTION_OCCURRED;
    }
    return exitValue;
}

From source file:org.apache.sqoop.mapreduce.mainframe.TestMainframeDatasetFTPRecordReader.java

@Test
public void testReadAllData() {
    try {//from   w w w . j  a va 2s.com
        mfDFTPRR.initialize(mfDIS, context);
        Assert.assertTrue("Retrieve of dataset", mfDFTPRR.nextKeyValue());
        Assert.assertEquals("Key should increase by records", 1, mfDFTPRR.getCurrentKey().get());
        Assert.assertEquals("Read value by line and by dataset", "123", mfDFTPRR.getCurrentValue().toString());
        Assert.assertEquals("Get progress according to left dataset", mfDFTPRR.getProgress(), (float) 0.5,
                0.02);
        Assert.assertTrue("Retrieve of dataset", mfDFTPRR.nextKeyValue());
        Assert.assertEquals("Key should increase by records", 2, mfDFTPRR.getCurrentKey().get());
        Assert.assertEquals("Read value by line and by dataset", "456", mfDFTPRR.getCurrentValue().toString());
        Assert.assertEquals("Get progress according to left dataset", mfDFTPRR.getProgress(), (float) 0.5,
                0.02);
        Assert.assertTrue("Retrieve of dataset", mfDFTPRR.nextKeyValue());
        Assert.assertEquals("Key should increase by records", 3, mfDFTPRR.getCurrentKey().get());
        Assert.assertEquals("Read value by line and by dataset", "789", mfDFTPRR.getCurrentValue().toString());
        Assert.assertEquals("Get progress according to left dataset", mfDFTPRR.getProgress(), (float) 1, 0.02);
        Assert.assertFalse("End of dataset", mfDFTPRR.nextKeyValue());
    } catch (IOException ioe) {
        fail("Got IOException: " + ioe.toString());
    } catch (InterruptedException ie) {
        fail("Got InterruptedException: " + ie.toString());
    }
}

From source file:hochschuledarmstadt.photostream_tools.ApiRequestsFailTest.java

@Test
public void loadPhotos() throws IOException, BaseAsyncTask.HttpPhotoStreamException {
    HttpGetExecutor executor = createMockHttpGetExecutor();
    LoadPhotosAsyncTask.GetPhotosCallback callback = mock(LoadPhotosAsyncTask.GetPhotosCallback.class);
    LoadPhotosAsyncTask streamAsyncTask = new LoadPhotosAsyncTask(executor, imageLoaderStub, imageCacherStub,
            callback);// www  .  j  a  v a 2 s.c o  m
    streamAsyncTask.execute();
    Robolectric.flushBackgroundThreadScheduler();
    try {
        streamAsyncTask.get();
        verify(callback, times(1)).onPhotosError(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 loadMorePhotos() throws IOException, BaseAsyncTask.HttpPhotoStreamException {
    HttpGetExecutor executor = createMockHttpGetExecutor();
    LoadMorePhotosAsyncTask.GetPhotosCallback callback = mock(LoadMorePhotosAsyncTask.GetPhotosCallback.class);
    LoadMorePhotosAsyncTask streamAsyncTask = new LoadMorePhotosAsyncTask(executor, imageLoaderStub,
            imageCacherStub, callback);/*from  w w w  . j a v a2  s .c o m*/
    streamAsyncTask.execute();
    Robolectric.flushBackgroundThreadScheduler();
    try {
        streamAsyncTask.get();
        verify(callback, times(1)).onPhotosError(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 uploadPhoto() throws IOException, BaseAsyncTask.HttpPhotoStreamException {
    HttpPostExecutor executor = createMockHttpPostExecutor();
    StorePhotoAsyncTask.OnPhotoStoredCallback listener = mock(StorePhotoAsyncTask.OnPhotoStoredCallback.class);
    StorePhotoAsyncTask storePhotoAsyncTask = new StorePhotoAsyncTask(executor, imageLoaderStub,
            imageCacherStub, listener);//from w w  w .j a va 2  s. c  om
    storePhotoAsyncTask.execute(new JSONObject());
    Robolectric.flushBackgroundThreadScheduler();
    try {
        storePhotoAsyncTask.get();
        verify(listener, times(1)).onPhotoStoreError(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 searchMorePhotos() throws IOException, BaseAsyncTask.HttpPhotoStreamException {
    HttpGetExecutor executor = createMockHttpGetExecutor();
    SearchMorePhotosAsyncTask.OnSearchPhotosResultCallback callback = mock(
            SearchMorePhotosAsyncTask.OnSearchPhotosResultCallback.class);
    SearchMorePhotosAsyncTask searchPhotosAsyncTask = new SearchMorePhotosAsyncTask(executor, imageLoaderStub,
            imageCacherStub, callback);//from  www. j ava 2s .  c o m
    searchPhotosAsyncTask.execute();
    Robolectric.flushBackgroundThreadScheduler();
    try {
        searchPhotosAsyncTask.get();
        verify(callback, times(1)).onSearchPhotosError(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 loadComments() throws IOException, BaseAsyncTask.HttpPhotoStreamException {
    HttpGetExecutor executor = createMockHttpGetExecutor();
    final int photoId = INVALID_PHOTO_ID;
    LoadCommentsAsyncTask.OnCommentsResultListener listener = mock(
            LoadCommentsAsyncTask.OnCommentsResultListener.class);
    LoadCommentsAsyncTask loadCommentsAsyncTask = new LoadCommentsAsyncTask(executor, photoId, listener);
    loadCommentsAsyncTask.execute();//  www .  j a v  a2  s .com
    Robolectric.flushBackgroundThreadScheduler();
    try {
        loadCommentsAsyncTask.get();
        verify(listener, times(1)).onGetCommentsFailed(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 likePhoto() throws IOException, BaseAsyncTask.HttpPhotoStreamException {
    HttpPutExecutor executor = createMockHttpPutExecutor();
    final int photoId = INVALID_PHOTO_ID;
    LikePhotoAsyncTask.OnVotePhotoResultListener callback = mock(
            LikePhotoAsyncTask.OnVotePhotoResultListener.class);
    LikePhotoAsyncTask votePhotoAsyncTask = new LikePhotoAsyncTask(executor, photoId, callback);
    votePhotoAsyncTask.execute();/*  w ww .j a  va  2 s  .  c o  m*/
    Robolectric.flushBackgroundThreadScheduler();
    try {
        votePhotoAsyncTask.get();
        verify(callback, times(1)).onPhotoLikeFailed(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 resetLikeForPhoto() throws IOException, BaseAsyncTask.HttpPhotoStreamException {
    HttpPutExecutor executor = createMockHttpPutExecutor();
    final int photoId = INVALID_PHOTO_ID;
    DislikePhotoAsyncTask.OnVotePhotoResultListener callback = mock(
            DislikePhotoAsyncTask.OnVotePhotoResultListener.class);
    DislikePhotoAsyncTask votePhotoAsyncTask = new DislikePhotoAsyncTask(executor, photoId, callback);
    votePhotoAsyncTask.execute();/*from www.  j  av a2 s.c  o m*/
    Robolectric.flushBackgroundThreadScheduler();
    try {
        votePhotoAsyncTask.get();
        verify(callback, times(1)).onPhotoLikeFailed(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 deleteComment() throws IOException, BaseAsyncTask.HttpPhotoStreamException {
    HttpDeleteExecutor executor = createMockHttpDeleteExecutor();
    final int commentId = INVALID_COMMENT_ID;
    DeleteCommentAsyncTask.OnDeleteCommentResultListener callback = mock(
            DeleteCommentAsyncTask.OnDeleteCommentResultListener.class);
    DeleteCommentAsyncTask deleteCommentAsyncTask = new DeleteCommentAsyncTask(executor, commentId, callback);
    deleteCommentAsyncTask.execute();/*  ww w .j a v  a 2 s  .c  om*/
    Robolectric.flushBackgroundThreadScheduler();
    try {
        deleteCommentAsyncTask.get();
        verify(callback, times(1)).onCommentDeleteFailed(eq(commentId), any(HttpError.class));
    } catch (InterruptedException e) {
        fail(e.toString());
    } catch (ExecutionException e) {
        fail(e.toString());
    }
}