Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

In this page you can find the example usage for java.lang RuntimeException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.expedia.client.WunderGroundClient.java

@Override
public ResponseEntity<ResponseWrapper> getJSONResponse(Object request) {
    ResponseEntity<ResponseWrapper> responseEntity = null;
    Weather weather = null;/*ww w .j a  v a2s  .  co  m*/

    if (request instanceof Weather) {
        weather = (Weather) request;
        List<MediaType> mediaTypes = new ArrayList<MediaType>();
        mediaTypes.add(MediaType.APPLICATION_JSON);
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept(mediaTypes);
        HttpEntity<Weather> httpEntity = new HttpEntity<Weather>(null, headers);
        try {
            System.out.println("Hitting weather service for JSON response!");
            responseEntity = restTemplate.exchange(weatherServiceJsonUrl, HttpMethod.GET, httpEntity,
                    ResponseWrapper.class, weatherApiKey, weather.getZipCode());
        } catch (RuntimeException e) {
            e.printStackTrace();
            weather.setErrorDesc("Get failed" + e.getMessage());
        }
    }
    return responseEntity;
}

From source file:lumbermill.internal.StringTemplateTest.java

@Test
public void testExtractSentence() {
    try {//  ww  w. j av a2  s  .c o  m

        StringTemplate t = StringTemplate.compile("Hej hopp {field}");
        Event event = Codecs.BYTES.from("Hello").put("field", "value");
        Optional<String> formattedString = t.format(event);
        assertThat(formattedString.isPresent()).isTrue();
        assertThat(formattedString.get()).isEqualTo("Hej hopp value");

        ObjectNode objectNode = new ObjectNode(JsonNodeFactory.instance);
        JsonEvent jsonEvent = new JsonEvent(objectNode);
        jsonEvent.put("id", "This is a test ID");
        jsonEvent.put("version", "This is a test version");

        StringTemplate key = StringTemplate.compile("{id}/{version}");
        assertThat(key.format(jsonEvent).get()).isEqualTo("This is a test ID/This is a test version");

    } catch (RuntimeException e) {
        e.printStackTrace();
        throw e;
    }
}

From source file:com.gs.obevo.db.scenariotests.OnboardingDeployTest.java

@Test
public void onboardingTest() throws Exception {
    final File srcDir = new File("./src/test/resources/scenariotests/onboardingDeploy");
    final File destDir = new File("./target/scenariotests/onboardingDeploy");
    FileUtils.deleteQuietly(destDir);//from   ww  w  .  j  a v  a  2s  .c  om

    FileUtils.copyDirectory(srcDir, destDir);

    LOG.info("Part 1 - do the deployment w/ onboarding mode");
    DbDeployerAppContext deployContext = DbEnvironmentFactory.getInstance()
            .readOneFromSourcePath(destDir.getAbsolutePath(), "test").buildAppContext();

    try {
        deployContext.setupEnvInfra().cleanEnvironment().deploy(new MainDeployerArgs().onboardingMode(true));
    } catch (RuntimeException exc) {
        exc.printStackTrace();
        // ignoring
    }

    // Verify that the exception files have been created properly
    assertTrue(new File(destDir, "SCHEMA1/staticdata/exceptions/TABLE_A.csv").exists());
    assertTrue(new File(destDir, "SCHEMA1/staticdata/exceptions/TABLE_B.csv").exists());
    assertTrue(new File(destDir, "SCHEMA1/table/exceptions/TABLE_C.ddl").exists());
    assertTrue(new File(destDir, "SCHEMA1/table/exceptions/TABLE_WITH_ERROR.ddl").exists());
    assertTrue(new File(destDir, "SCHEMA1/view/exceptions/VIEW_WITH_ERROR.sql").exists());
    assertTrue(new File(destDir, "SCHEMA1/view/dependentOnExceptions/VIEW_DEPENDING_ON_BAD_VIEW.sql").exists());

    LOG.info("Part 2 - rerun the deploy and ensure the data remains as is");
    deployContext = DbEnvironmentFactory.getInstance().readOneFromSourcePath(destDir.getAbsolutePath(), "test")
            .buildAppContext();

    try {
        deployContext.deploy(new MainDeployerArgs().onboardingMode(true));
    } catch (RuntimeException exc) {
        exc.printStackTrace();
        // ignoring
    }

    // Same assertions as before should hold
    assertTrue(new File(destDir, "SCHEMA1/staticdata/exceptions/TABLE_A.csv").exists());
    assertTrue(new File(destDir, "SCHEMA1/staticdata/exceptions/TABLE_B.csv").exists());
    assertTrue(new File(destDir, "SCHEMA1/table/exceptions/TABLE_C.ddl").exists());
    assertTrue(new File(destDir, "SCHEMA1/table/exceptions/TABLE_WITH_ERROR.ddl").exists());
    assertTrue(new File(destDir, "SCHEMA1/view/exceptions/VIEW_WITH_ERROR.sql").exists());
    assertTrue(new File(destDir, "SCHEMA1/view/dependentOnExceptions/VIEW_DEPENDING_ON_BAD_VIEW.sql").exists());

    LOG.info("Part 3 - fix the view and verify that it is moved back to the regular folder");
    FileUtils.copyFile(new File(srcDir, "VIEW_WITH_ERROR.corrected.sql"),
            new File(destDir, "SCHEMA1/view/exceptions/VIEW_WITH_ERROR.sql"));

    deployContext = DbEnvironmentFactory.getInstance().readOneFromSourcePath(destDir.getAbsolutePath(), "test")
            .buildAppContext();

    try {
        deployContext.deploy(new MainDeployerArgs().onboardingMode(true));
    } catch (RuntimeException exc) {
        exc.printStackTrace();
        // ignoring
    }

    assertTrue(new File(destDir, "SCHEMA1/staticdata/exceptions/TABLE_A.csv").exists());
    assertTrue(new File(destDir, "SCHEMA1/staticdata/exceptions/TABLE_B.csv").exists());
    assertTrue(new File(destDir, "SCHEMA1/table/exceptions/TABLE_C.ddl").exists());
    assertTrue(new File(destDir, "SCHEMA1/table/exceptions/TABLE_WITH_ERROR.ddl").exists());
    // These two have changed from above
    assertTrue(new File(destDir, "SCHEMA1/view/VIEW_WITH_ERROR.sql").exists());
    assertTrue(new File(destDir, "SCHEMA1/view/VIEW_DEPENDING_ON_BAD_VIEW.sql").exists());
}

From source file:it.drwolf.ridire.session.async.callable.CorpusDeleter.java

public IndexingResult call() {
    IndexingResult indexingResult = new IndexingResult();
    Lifecycle.beginCall();//from   ww  w. j  a  v a 2s  .  c om
    try {
        this.contextsIndexManager = (ContextsIndexManager) Component.getInstance("contextsIndexManager");
        TopDocs termDocs = null;
        int updated = 0;
        int totToBeModified = 0;
        this.contextsIndexManager.reOpenIndexReaderW();
        termDocs = this.contextsIndexManager.getIndexSearcherW()
                .search(new TermQuery(new Term("corpus", this.corpusName)), Integer.MAX_VALUE);
        totToBeModified = termDocs.totalHits;
        for (int i = 0; i < termDocs.totalHits; i += 30) {
            ScoreDoc[] tmp = (ScoreDoc[]) ArrayUtils.subarray(termDocs.scoreDocs, i, i + 30);
            for (ScoreDoc scoreDoc : tmp) {
                this.contextsIndexManager.reOpenIndexReaderW();
                Document d = this.contextsIndexManager.getIndexSearcherW().doc(scoreDoc.doc);
                List<String> corporaNames = new ArrayList<String>();
                for (String cn : d.getValues("corpus")) {
                    if (!cn.equals(this.corpusName)) {
                        corporaNames.add(cn);
                    }
                }
                d.removeFields("corpus");
                if (corporaNames.size() > 0) {
                    for (String cn : corporaNames) {
                        d.add(new Field("corpus", cn, Field.Store.YES, Field.Index.NOT_ANALYZED));
                    }
                }
                try {
                    this.contextsIndexManager.closeIndexWriter();
                    this.contextsIndexManager.getIndexSearcherW().getIndexReader().deleteDocument(scoreDoc.doc);
                    this.contextsIndexManager.getIndexSearcherW().getIndexReader().close();
                    this.contextsIndexManager.openIndexWriterWithoutCreating();
                    this.contextsIndexManager.getIndexWriter().updateDocument(new Term("corpus"), d);
                    this.contextsIndexManager.closeIndexWriter();
                } catch (RuntimeException e) {
                    e.printStackTrace();
                    throw e;
                }
                ++updated;
                this.percentage = updated / (totToBeModified * 1.0f);
            }
        }
        this.contextsIndexManager.openIndexWriterWithoutCreating();
        this.contextsIndexManager.getIndexWriter().expungeDeletes();
        this.contextsIndexManager.closeIndexWriter();
    } catch (Exception e) {
        e.printStackTrace();
    }
    Lifecycle.endCall();
    this.setTerminated(true);
    return indexingResult;
}

From source file:com.samples.platform.serviceprovider.library.internal.dao.PlatformDao.java

/**
 * @param value/*from w w  w.j  av  a  2  s .c  o m*/
 *            the id of the book to delete.
 */
@Transactional(value = PersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED)
public void deleteBook(final BookType value) {
    if (value != null) {
        try {
            this.logger.debug("deleteBook id=" + value.getUUID());
            this.em.remove(value);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    } else {
        this.logger.debug("deleteBook: value not found to delete it.");
    }
}

From source file:org.apache.xmlgraphics.image.codec.png.CodecResourcesTest.java

public void testResources() throws Exception {

    InputStream in = new java.io.FileInputStream("test/images/barcode.eps");
    SeekableStream seekStream = new MemoryCacheSeekableStream(in);
    try {/*w w w.  java  2  s  .co  m*/
        new PNGImage(seekStream, null);
        fail("Exception expected");
    } catch (RuntimeException re) {
        String msg = re.getMessage();
        if ("PNGImageDecoder0".equals(msg)) {
            re.printStackTrace();
            fail("Message resource don't seem to be present! Message is: " + msg);
        } else if (msg.toLowerCase().indexOf("magic") < 0) {
            fail("Message not as expected! Message is: " + msg);
        }
    } finally {
        IOUtils.closeQuietly(seekStream);
        IOUtils.closeQuietly(in);
    }

}

From source file:com.samples.platform.serviceprovider.library.internal.dao.PlatformDao.java

/**
 * @param value//from ww w.j  a v  a 2s  .  com
 *            the {@link BookType} to create.
 * @return the created {@link BookType}.
 */
@Transactional(value = PersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED)
public BookType createBook(final BookType value) {
    if (value != null) {
        try {
            this.em.persist(value);
            this.logger.debug("createBook id=" + value.getUUID());
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
        return value;
    } else {
        this.logger.debug("createBook: value is null.");
        return null;
    }
}

From source file:com.samples.platform.serviceprovider.library.internal.dao.PlatformDao.java

/**
 * @param value/*from  ww  w. ja v  a2 s  .co  m*/
 *            the {@link BookType} to save.
 * @return the created {@link BookType}.
 */
@Transactional(value = PersistenceConfig.TRANSACTION_MANAGER_NAME, propagation = Propagation.REQUIRED)
public BookType saveBook(final BookType value) {
    if (value != null) {
        try {
            this.em.merge(value);
            this.logger.debug("saveBook id=" + value.getUUID());
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
        return value;
    } else {
        this.logger.debug("saveBook: value is null.");
        return null;
    }
}

From source file:pl.nask.hsn2.TaskProcessorTest.java

TaskRequest testRequest() {
    try {/*w  ww .  j a  va  2  s .co m*/
        return TaskRequest.newBuilder().setJob(1l).setTaskId(1).setObject(0).build();
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw e;
    }
}

From source file:it.gcaliendo.elytheme.fragments.FragmentExtras.java

private void actRequest() {
    String pkg = getResources().getString(R.string.pkg);
    Intent iconrequest = new Intent(Intent.ACTION_MAIN);
    iconrequest.setComponent(new ComponentName(pkg, pkg + ".RequestActivity"));

    try {//from  w ww  .ja  va  2 s.c o m
        startActivity(iconrequest);
    } catch (RuntimeException icons) {
        icons.printStackTrace();
    }
}