Example usage for java.lang Throwable Throwable

List of usage examples for java.lang Throwable Throwable

Introduction

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

Prototype

public Throwable(String message, Throwable cause) 

Source Link

Document

Constructs a new throwable with the specified detail message and cause.

Usage

From source file:org.eclipse.epp.internal.logging.aeri.ui.LogListenerTest.java

@Test
public void testLinkageErrorCommentAdded() {
    Throwable e3 = new RuntimeException();
    e3.fillInStackTrace();// w w w . j  av a2  s .  c  om
    ClassNotFoundException e2 = new ClassNotFoundException(StringUtils.class.getName(), e3);
    Throwable e1 = new Throwable("test", e2);
    Status status = new Status(IStatus.ERROR, TEST_PLUGIN_ID, "test message", e1);

    sut.logging(status, "");

    ErrorReport report = pollEvent().report;
    assertThat(report.getComment(), not(isEmptyOrNullString()));
}

From source file:org.dita.dost.AbstractIntegrationTest.java

private void compare(final File expDir, final File actDir) throws Throwable {
    final Collection<String> files = getFiles(expDir, actDir);
    for (final String name : files) {
        final File exp = new File(expDir, name);
        final File act = new File(actDir, name);
        if (exp.isDirectory()) {
            compare(exp, act);// w  ww  .  j a v a2 s .  co  m
        } else {
            final String ext = FileUtils.getExtension(name);
            try {
                if (ext == null) {
                } else if (ext.equals("html") || ext.equals("htm") || ext.equals("xhtml")
                        || ext.equals("hhk")) {
                    assertXMLEqual(parseHtml(exp), parseHtml(act));
                } else if (ext.equals("xml") || ext.equals("dita") || ext.equals("ditamap")) {
                    assertXMLEqual(parseXml(exp), parseXml(act));
                } else if (ext.equals("txt")) {
                    assertArrayEquals(readTextFile(exp), readTextFile(act));
                }
            } catch (final RuntimeException ex) {
                throw ex;
            } catch (final Throwable ex) {
                throw new Throwable("Failed comparing " + exp.getAbsolutePath() + " and "
                        + act.getAbsolutePath() + ": " + ex.getMessage(), ex);
            }
        }
    }
}

From source file:com.xwiki.authentication.sts.XWikiSTSAuthenticator.java

/**
 * checkAuth - Checks authentification session in cookies. If there is data about current user
 * returns it. If there is not an authentification data - then method is trying to login
 * using methadata creating new XWiki Object.
 * /*  w w  w .  jav a2  s .c o m*/
 * @param context XWikiContext - context of XWiki Engine
 * @throws XWikiUser java.lang.Object extended by java.lang.Throwable </br> extended by java.lang.Exception extended by com.xpn.xwiki.XWikiException
 *
* @see com.xpn.xwiki.user.impl.xwiki.AppServerTrustedAuthServiceImpl#checkAuth(com.xpn.xwiki.XWikiContext)
*/
@Override
public XWikiUser checkAuth(XWikiContext context) throws XWikiException {
    log.trace("checkAuth(context)");
    try {
        XWikiRequest request = context.getRequest();
        log.trace("context================\n" + context);
        log.trace("request headers============");
        Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            log.trace(headerName + "=" + request.getHeader(headerName));
        }
        Enumeration<String> en = request.getParameterNames();
        log.trace("request parameters=============");
        while (en.hasMoreElements()) {
            String paramName = en.nextElement();
            String paramValue = request.getParameter(paramName);
            log.trace(paramName + "=" + URLEncoder.encode(paramValue));
        }
    } catch (Exception e) {
        log.error("Got error during printing request parameters: " + e);
        errorCollector.addError(new Throwable("Got error during printing request parameters: ", e));
    }

    // check in the session if the user is already authenticated
    String stsUserName = (String) context.getRequest().getSession().getAttribute(props.getAuthField(context));
    if (stsUserName == null) {
        // check standard authentication
        if (context.getRequest().getCookie("username") != null || "logout".equals(context.getAction())
                || context.getAction().startsWith("login")
                || "1".equals(context.getRequest().getParameter("basicauth"))) {
            log.debug("Fallback to standard authentication");
            return super.checkAuth(context);
        }
        // check if we have a STS Response to verify
        // (this sets getAuthField value for the next pass)
        if (checkSTSResponse(context))
            return null;
    } else {
        log.debug("Found authentication of user " + stsUserName);
        log.info(errorCollector.listErrors());
        if (context.isMainWiki()) {
            return new XWikiUser(stsUserName);
        } else {
            return new XWikiUser(context.getMainXWiki() + ":" + stsUserName);
        }
    }
    return null;
}

From source file:org.betaconceptframework.astroboa.test.engine.service.TopicServiceTest.java

private void assertTopicOutcome(TopicCriteria topicCriteria, Topic topic, String expression,
        SearchOutcome searchOutcome) throws Throwable {

    try {/* w w w  .  j ava2 s  . c o m*/

        topicCriteria.reset();

        CriterionFactory.parse(expression, topicCriteria);

        CmsOutcome<Topic> outcome = topicService.searchTopics(topicCriteria,
                ResourceRepresentationType.TOPIC_LIST);

        if (SearchOutcome.ONLY_EXPECTED_TOPIC == searchOutcome) {
            Assert.assertEquals(outcome.getCount(), 1, "Invalid topic outcome count." + printOutcome(outcome));

            Assert.assertEquals(outcome.getResults().get(0).getId(), topic.getId(), "Invalid topic outcome ");
        } else {

            //At least the provided topic must exist
            boolean providedTopicFound = false;

            if (outcome.getCount() > 0) {
                for (Topic topicResult : outcome.getResults()) {
                    if (StringUtils.equals(topicResult.getId(), topic.getId())) {
                        providedTopicFound = true;
                    }
                }
            }

            if (SearchOutcome.AT_LEAST_EXPECTED_TOPIC == searchOutcome) {
                Assert.assertTrue(providedTopicFound,
                        "Invalid topic outcome. Did not find topic " + topic + " in the results");
            } else {
                Assert.assertFalse(providedTopicFound,
                        "Invalid topic outcome. Found topic " + topic + " in the results");
            }
        }
    } catch (Throwable t) {
        throw new Throwable("Expression " + expression + ", XPath " + topicCriteria.getXPathQuery(), t);
    }
}