Example usage for java.lang RuntimeException getMessage

List of usage examples for java.lang RuntimeException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:net.shirayu.android.WlanLogin.MyHttpClient.java

public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> handler)
        throws IOException, ClientProtocolException {
    stop_auth = false;/*from w w w . ja  v  a2s . c  o  m*/
    try {
        return client.execute(request, handler);
    } catch (RuntimeException ex) {
        throw new ClientProtocolException(ex.getMessage());
    }
}

From source file:net.shirayu.android.WlanLogin.MyHttpClient.java

public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
        throws IOException, ClientProtocolException {
    stop_auth = false;//w  w w  . ja  va  2s.  com
    try {
        return client.execute(target, request, context);
    } catch (RuntimeException ex) {
        throw new ClientProtocolException(ex.getMessage());
    }
}

From source file:net.shirayu.android.WlanLogin.MyHttpClient.java

public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T> handler, HttpContext context)
        throws IOException, ClientProtocolException {
    stop_auth = false;/*from  www . j  a  v a  2  s . c om*/
    try {
        return client.execute(request, handler, context);
    } catch (RuntimeException ex) {
        throw new ClientProtocolException(ex.getMessage());
    }
}

From source file:net.shirayu.android.WlanLogin.MyHttpClient.java

public <T> T execute(HttpHost host, HttpRequest request, ResponseHandler<? extends T> handler)
        throws IOException, ClientProtocolException {
    stop_auth = false;/*from   w  w  w  . j a v a2s  .  c  o m*/
    try {
        return client.execute(host, request, handler);
    } catch (RuntimeException ex) {
        throw new ClientProtocolException(ex.getMessage());
    }
}

From source file:net.shirayu.android.WlanLogin.MyHttpClient.java

public <T> T execute(HttpHost host, HttpRequest request, ResponseHandler<? extends T> handler,
        HttpContext context) throws IOException, ClientProtocolException {
    stop_auth = false;/* w  w  w . ja  va 2  s.  c o  m*/
    try {
        return client.execute(host, request, handler, context);
    } catch (RuntimeException ex) {
        throw new ClientProtocolException(ex.getMessage());
    }
}

From source file:com.legstar.codegen.CodeGenMakeTest.java

/**
 * Check controls on input make file tag &lt;cixstemplate name=""&gt;.
 * @throws IOException if file cannot be read
 *//*from w  ww .  ja  va 2  s .com*/
public void testCodeGenMakeTemplateNoTemplateName() throws IOException {
    File tempMakeFile = File.createTempFile("test-temp", "xml");
    /* Create a temporary make file */
    BufferedWriter out;
    out = new BufferedWriter(new FileWriter(tempMakeFile));
    out.write("<target name=\"aTarget\"><step/></target>");
    out.close();

    CodeGenMake codeGenMake = new CodeGenMake();
    codeGenMake.setModelName("modelName");
    codeGenMake.setModel("model");
    codeGenMake.setCodeGenMakeFileName(tempMakeFile.getPath());
    try {
        codeGenMake.execute();
    } catch (RuntimeException e) {
        assertEquals("Missing template name attribute for step element", e.getMessage());
    }
}

From source file:org.resthub.rpc.AMQPHessianProxyTest.java

@Test
public void testException() throws Exception {
    EchoServiceEndpoint endpoint = new EchoServiceEndpoint();
    endpoint.setConnectionFactory(connectionFactory);
    endpoint.run();/* w  ww.j  a v  a2s  .  c  o  m*/

    AMQPHessianProxyFactory factory = new AMQPHessianProxyFactory();
    factory.setReadTimeout(5000);
    factory.setCompressed(true);
    factory.setConnectionFactory(connectionFactory);
    EchoService service = factory.create(EchoService.class);
    String message = "Hello Hessian!";

    try {
        service.exception(message);
        fail("No exception thrown");
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        assertEquals("Exception message", message, e.getMessage());
    } finally {
        endpoint.destroy();
    }
}

From source file:net.big_oh.algorithms.graph.clique.BronKerboschMaximalCliqueFinder.java

public Set<Set<V>> findMaximalCliques(Graph<V> g, int minCliqueSize) throws IllegalArgumentException {

    Duration d = new Duration(this.getClass());

    if (g == null) {
        throw new IllegalArgumentException("The Graph argument must not be null.");
    }/*from   w ww  .jav a2s .  c o m*/
    if (minCliqueSize < 2) {
        throw new IllegalArgumentException("The minCliqueSize argument must not be less than two.");
    }

    // for the first step of the BronKerbosch algorithm, use a Vertex
    // iterator instead of fetching the entire collection. For sparse
    // graphs, use of the iterator avoids creating unnecessarily large
    // P collections.
    Set<Set<V>> maximalCliques = new HashSet<Set<V>>();

    long numVertices = g.getVertexCount();
    int completedVertexCounter = 0;
    for (Iterator<V> vertexIter = g.getAllVerticesIterator(); vertexIter.hasNext();) {
        V v = vertexIter.next();

        Set<V> r = new HashSet<V>();
        r.add(v);

        Set<V> p = g.getAllNeighbors(v);

        Set<V> x = g.getAllNeighbors(v);

        // process maximal cliques discovered for Vertex v
        processMaximalCliqueDiscoveries(maximalCliques, bronKerbosch1(r, p, x, g, minCliqueSize, 1));

        // count the completion of a step in the algorithm
        completedVertexCounter++;

        // signal step completion to listeners
        for (MaximalCliqueFinderEventListener<V> listener : eventListeners) {
            try {
                listener.stepCompleted(completedVertexCounter, numVertices);
            } catch (RuntimeException re) {
                logger.error(re.getMessage(), re);
            }
        }

        // log current progress of the operation?
        if (completedVertexCounter % Math.max(1, (numVertices / 100)) == 0) {
            logger.info("Executing " + this.getClass().getSimpleName() + ".findMaximalCliques(..) ... "
                    + (int) ((double) completedVertexCounter / (double) numVertices * 100.0) + "% complete.");
        }
    }

    d.stop("findMaximalCliques");

    logger.info("Discovered " + maximalCliques.size() + " maximal cliques with size of at least "
            + minCliqueSize + ".");

    return maximalCliques;

}

From source file:com.seleniumtests.browserfactory.RemoteDriverFactory.java

@Override
public WebDriver createWebDriver()
        throws MalformedURLException, IllegalArgumentException, SecurityException, InstantiationException,
        IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
    DriverConfig webDriverConfig = this.getWebDriverConfig();
    DesiredCapabilities capability = null;
    URL url;//from ww  w.  ja va 2 s  .c o m

    url = new URL(webDriverConfig.getHubUrl());

    switch (webDriverConfig.getBrowser()) {

    case FireFox:
        capability = new FirefoxCapabilitiesFactory().createCapabilities(webDriverConfig);
        break;

    case InternetExplore:
        capability = new IECapabilitiesFactory().createCapabilities(webDriverConfig);
        break;

    case Chrome:
        capability = new ChromeCapabilitiesFactory().createCapabilities(webDriverConfig);
        break;

    case HtmlUnit:
        capability = new HtmlUnitCapabilitiesFactory().createCapabilities(webDriverConfig);
        break;

    case Safari:
        capability = new SafariCapabilitiesFactory().createCapabilities(webDriverConfig);
        break;

    case Android:
        capability = new AndroidCapabilitiesFactory().createCapabilities(webDriverConfig);
        break;

    case IPhone:
        capability = ((ICapabilitiesFactory) Class
                .forName("com.seleniumtests.browserfactory.IPhoneCapabilitiesFactory").getConstructor()
                .newInstance()).createCapabilities(webDriverConfig);
        break;

    case PhantomJS:
        capability = new PhantomJSCapabilitiesFactory().createCapabilities(webDriverConfig);
        break;

    default:
        break;
    }

    switch (webDriverConfig.getBrowser()) {

    case IPhone:
    case FireFox:
        try {
            driver = new ScreenShotRemoteWebDriver(url, capability);
        } catch (RuntimeException e) {
            if (e.getMessage().contains(
                    "Unable to connect to host 127.0.0.1 on port 7062 after 45000 ms. Firefox console output")) {
                TestLogging.log("Firefox Driver creation got port customexception, retry after 5 seconds");
                WaitHelper.waitForSeconds(5);
                driver = new ScreenShotRemoteWebDriver(url, capability);
            } else {
                throw e;
            }
        }

        break;

    default:
        driver = new ScreenShotRemoteWebDriver(url, capability);
    }

    setImplicitWaitTimeout(webDriverConfig.getImplicitWaitTimeout());
    if (webDriverConfig.getPageLoadTimeout() >= 0) {
        setPageLoadTimeout(webDriverConfig.getPageLoadTimeout(), webDriverConfig.getBrowser());
    }

    this.setWebDriver(driver);

    String hub = url.getHost();
    int port = url.getPort();

    // logging node ip address:
    try {
        HttpHost host = new HttpHost(hub, port);
        DefaultHttpClient client = new DefaultHttpClient();
        String sessionUrl = "http://" + hub + ":" + port + "/grid/api/testsession?session=";
        URL session = new URL(sessionUrl + ((RemoteWebDriver) driver).getSessionId());
        BasicHttpEntityEnclosingRequest req;
        req = new BasicHttpEntityEnclosingRequest("POST", session.toExternalForm());

        org.apache.http.HttpResponse response = client.execute(host, req);
        String responseContent = EntityUtils.toString(response.getEntity());
        try {
            JSONObject object = new JSONObject(responseContent);
            String proxyId = (String) object.get("proxyId");
            String node = (proxyId.split("//")[1].split(":")[0]);
            String browserName = ((RemoteWebDriver) driver).getCapabilities().getBrowserName();
            String version = ((RemoteWebDriver) driver).getCapabilities().getVersion();
            System.out.println("WebDriver is running on node " + node + ", " + browserName + version
                    + ", session " + ((RemoteWebDriver) driver).getSessionId());
            TestLogging.log("WebDriver is running on node " + node + ", " + browserName + version + ", session "
                    + ((RemoteWebDriver) driver).getSessionId());
        } catch (org.json.JSONException e) {
        }
    } catch (Exception ex) {
    }

    return driver;
}

From source file:com.android.tests.lib.LibUnitTest.java

@Test
public void exceptions() {
    try {/*from w  w w  .j  a  v a  2 s  .c o  m*/
        ArrayMap map = new ArrayMap();
        map.isEmpty();
        fail();
    } catch (RuntimeException e) {
        assertEquals(RuntimeException.class, e.getClass());
        assertTrue(e.getMessage().contains("isEmpty"));
        assertTrue(e.getMessage().contains("not mocked"));
    }

    try {
        Debug.getThreadAllocCount();
        fail();
    } catch (RuntimeException e) {
        assertEquals(RuntimeException.class, e.getClass());
        assertTrue(e.getMessage().contains("getThreadAllocCount"));
        assertTrue(e.getMessage().contains("not mocked"));
    }

}