List of usage examples for java.lang RuntimeException getMessage
public String getMessage()
From source file:com.legstar.codegen.CodeGenMakeTest.java
/** * Check controls on input make file./*from w w w. j ava 2 s . c o m*/ */ public void testCixsMakeInputValidation() { CodeGenMake codeGenMake = new CodeGenMake(); codeGenMake.setModelName("modelName"); codeGenMake.setModel("model"); try { codeGenMake.execute(); } catch (RuntimeException e) { assertEquals("Missing make file parameter", e.getMessage()); } codeGenMake.setCodeGenMakeFileName("tarass.boulba"); try { codeGenMake.execute(); } catch (RuntimeException e) { assertEquals("Code generation make file tarass.boulba does not exist", e.getMessage()); } }
From source file:com.googlecode.ehcache.annotations.integration.SelfPopulatingTest.java
@Test(timeout = 1000) public void testExceptionCaching() { final CountDownLatch threadRunningLatch = new CountDownLatch(0); final CountDownLatch proccedLatch = new CountDownLatch(0); this.selfPopulatingTestInterface.setThreadRunningLatch(threadRunningLatch); this.selfPopulatingTestInterface.setProccedLatch(proccedLatch); Assert.assertEquals(0, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedCount()); Assert.assertEquals(0, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedThrowsCount()); Assert.assertEquals("interfaceAnnotatedExceptionCached(false)", selfPopulatingTestInterface.interfaceAnnotatedExceptionCached(false)); Assert.assertEquals(1, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedCount()); Assert.assertEquals(0, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedThrowsCount()); Assert.assertEquals("interfaceAnnotatedExceptionCached(false)", selfPopulatingTestInterface.interfaceAnnotatedExceptionCached(false)); Assert.assertEquals(1, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedCount()); Assert.assertEquals(0, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedThrowsCount()); try {/*from ww w . j av a 2s . c o m*/ selfPopulatingTestInterface.interfaceAnnotatedExceptionCached(true); Assert.fail("interfaceAnnotatedExceptionCached(true) should have thrown an exception"); } catch (RuntimeException re) { Assert.assertEquals("throwsException was true", re.getMessage()); } Assert.assertEquals(1, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedCount()); Assert.assertEquals(1, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedThrowsCount()); try { selfPopulatingTestInterface.interfaceAnnotatedExceptionCached(true); Assert.fail("interfaceAnnotatedExceptionCached(true) should have thrown an exception"); } catch (RuntimeException re) { Assert.assertEquals("throwsException was true", re.getMessage()); } Assert.assertEquals(1, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedCount()); Assert.assertEquals(1, selfPopulatingTestInterface.interfaceAnnotatedExceptionCachedThrowsCount()); }
From source file:io.kamax.mxisd.controller.DefaultExceptionHandler.java
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(RuntimeException.class) public String handle(HttpServletRequest req, RuntimeException e) { log.error("Unknown error when handling {}", req.getRequestURL(), e); return handle(req, "M_UNKNOWN", StringUtils.defaultIfBlank(e.getMessage(), "An internal server error occurred. If this error persists, please contact support with reference #" + Instant.now().toEpochMilli())); }
From source file:org.eclipse.jgit.lfs.server.fs.DownloadTest.java
@Test public void testDownloadInvalidId() throws ClientProtocolException, IOException { String TEXT = "test"; String id = putContent(TEXT).name().replace('f', 'z'); Path f = Paths.get(getTempDirectory().toString(), "download"); try {//from www . jav a 2 s . c om getContent(id, f); fail("expected RuntimeException"); } catch (RuntimeException e) { String error = String.format("Invalid id: : %s", id); assertEquals(formatErrorMessage(SC_UNPROCESSABLE_ENTITY, error), e.getMessage()); } }
From source file:com.espertech.esper.epl.virtualdw.JoinExecTableLookupStrategyVirtualDW.java
public Set<EventBean> lookup(EventBean theEvent, Cursor cursor, ExprEvaluatorContext context) { eventsPerStream[lookupStream] = theEvent; Object[] keys = new Object[evaluators.length]; for (int i = 0; i < evaluators.length; i++) { keys[i] = evaluators[i].evaluate(eventsPerStream, context); }//from www. ja va 2 s. c o m Set<EventBean> events = null; try { events = externalIndex.lookup(keys, eventsPerStream); } catch (RuntimeException ex) { log.warn("Exception encountered invoking virtual data window external index for window '" + namedWindowName + "': " + ex.getMessage(), ex); } return events; }
From source file:com.logiclander.jaasmine.authentication.http.SPNegoFilter.java
private String getSPNegoToken(HttpServletRequest req) { String headerValue = req.getHeader("Authorization"); if (headerValue == null || headerValue.isEmpty()) { return ""; }//from w w w .j av a 2 s. c o m // Split "Negotiate [SPNego_TOKEN]" by the space and return the token. String token = ""; try { token = headerValue.split(" ", 2)[1]; } catch (RuntimeException t) { logger.fatal(t.getMessage(), t); throw t; } if (logger.isDebugEnabled()) { logger.debug(String.format("%nSPNego token%n%s%n", token)); } return token; }
From source file:net.nelz.simplesm.aop.CacheBaseTest.java
@Test public void testGenerateCacheKey() throws Exception { final Method method = KeyObject.class.getMethod("toString", null); try {/* w w w. ja v a2 s . c o m*/ cut.generateObjectId(method, new KeyObject(null)); fail("Expected Exception."); } catch (RuntimeException ex) { assertTrue(ex.getMessage().indexOf("empty key value") != -1); } try { cut.generateObjectId(method, new KeyObject("")); fail("Expected Exception."); } catch (RuntimeException ex) { assertTrue(ex.getMessage().indexOf("empty key value") != -1); } final String result = "momma"; assertEquals(result, cut.generateObjectId(method, new KeyObject(result))); }
From source file:org.eclipse.jgit.lfs.server.fs.DownloadTest.java
@Test public void testDownloadNotFound() throws ClientProtocolException, IOException { String TEXT = "test"; AnyLongObjectId id = LongObjectIdTestUtils.hash(TEXT); Path f = Paths.get(getTempDirectory().toString(), "download"); try {//from w w w . j a v a2 s . co m getContent(id, f); fail("expected RuntimeException"); } catch (RuntimeException e) { String error = String.format("Object '%s' not found", id.getName()); assertEquals(formatErrorMessage(SC_NOT_FOUND, error), e.getMessage()); } }
From source file:com.nextep.designer.dbgm.oracle.ui.navigators.OracleClusterContentProvider.java
@SuppressWarnings("unchecked") @Override// ww w .j av a 2 s .co m public Object[] getChildren(Object parentElement) { if (parentElement instanceof IOracleCluster) { final IOracleCluster cluster = (IOracleCluster) parentElement; final Collection<Object> elts = new ArrayList<Object>(); final Collection<IOracleClusteredTable> clusteredTabs = cluster.getClusteredTables(); if (clusteredTabs != null) { for (IOracleClusteredTable t : clusteredTabs) { try { IBasicTable table = (IBasicTable) VersionHelper.getReferencedItem(t.getTableReference()); elts.add(table); } catch (RuntimeException e) { LOGGER.warn(MessageFormat.format(DBOMUIMessages.getString("navigator.cluster.tabError"), //$NON-NLS-1$ e.getMessage()), e); } } return TypedNode.buildNodesFromCollection(cluster, (Collection<? extends ITypedObject>) elts, this) .toArray(); } } else if (parentElement instanceof ITypedNode) { return ((ITypedNode) parentElement).getChildren().toArray(); } return null; }
From source file:me.zhuoran.crawler4j.crawler.http.HttpClient.java
private HttpFetchResult doGet(final String threadName, final String defaultCharset, final URL url, final HttpGet req) { int retry = 0;//After the execute request failure of the number of retries StatusLine status = null;// w w w . jav a 2 s.co m HttpEntity entity = null; try { while (retry++ < 5) { try { HttpContext localContext = new BasicHttpContext(); HttpResponse rsp = HttpConnectionManager.getHttpClient().execute(req, localContext); entity = rsp.getEntity(); status = rsp.getStatusLine(); if (status.getStatusCode() != HttpStatus.SC_OK) { req.abort(); continue; } if (entity != null) { logger.debug(threadName + " request get " + url.toFullString() + " " + rsp.getStatusLine()); return new HttpFetchResult(rsp, defaultCharset); } else { req.abort(); } } catch (IOException ex) { // In case of an IOException the connection will be released // back to the connection manager automatically continue; } catch (RuntimeException e) { req.abort(); logger.error(threadName + " request " + url.toFullString() + " " + e.getMessage()); e.printStackTrace(); continue; } catch (Throwable e) { logger.error(threadName + " request " + url.toFullString() + " " + e.getMessage()); e.printStackTrace(); } } } finally { try { if (entity == null && req != null) { req.abort(); } } catch (Exception e) { e.printStackTrace(); } } logger.warn(threadName + " request get " + url.toFullString() + " " + status); return null; }