List of usage examples for java.lang RuntimeException getCause
public synchronized Throwable getCause()
From source file:org.wildfly.security.tool.CredentialStoreCommandInputTest.java
@Test @Ignore("https://issues.jboss.org/browse/ELY-1054") public void testEmptyValue() throws Exception { String storageLocation = getStoragePathForNewFile(); String storagePassword = "cspassword"; String[] aliasNames = { "", "testalias1", "" }; String[] aliasValues = { "secretValue", "", "" }; for (int i = 0; i < aliasNames.length; i++) { try {//w w w .ja v a 2 s .c om createStoreAndAddAliasAndCheck(storageLocation, storagePassword, aliasNames[i], aliasValues[i]); } catch (RuntimeException e) { if (!(e.getCause() instanceof NullPointerException)) { Assert.fail("It must fail because of there is forbidden to use empty alias name or value."); } } } }
From source file:com.rackspacecloud.blueflood.io.serializers.HistogramSerializationTest.java
@Test public void testBadSerializationVersion() { byte[] buf = new byte[] { 99, 99 }; // hopefully we won't have 99 different serialization versions. try {//from w w w .j ava 2 s .c o m HistogramSerializer.get().fromByteBuffer(ByteBuffer.wrap(buf)); Assert.fail(String.format("Should have errored out. Such a version doesn't exist for histogram.")); } catch (RuntimeException ex) { Assert.assertTrue(ex.getCause().getMessage().startsWith("Unexpected serialization version")); } }
From source file:org.lendingclub.mercator.docker.DockerRestClient.java
public JsonNode get(String... paths) { try {/*from ww w . j a v a 2s. co m*/ WebTarget t = webTarget; for (String p : paths) { t = t.path(p); } JsonNode n = t.request().accept("application/json").get(JsonNode.class); return n; } catch (RuntimeException e) { Throwable t = e.getCause(); if (t != null && t instanceof NotFoundException) { throw new org.lendingclub.mercator.core.NotFoundException(t); } throw new MercatorException(e); } }
From source file:org.echocat.marquardt.common.ValidatorUnitTest.java
private void thenAnWrappedIoExceptionIsThrown() { try {//w w w .j a v a2 s . c o m whenValidatedPayloadIsDeserialized(); fail(RuntimeException.class + " expected to be thrown!"); } catch (final RuntimeException e) { assertThat(e.getCause() instanceof EOFException, is(true)); } }
From source file:com.googlecode.jsonschema2pojo.integration.config.AnnotationStyleIT.java
@Test public void invalidAnnotationStyleCausesMojoException() { try {//ww w. j a va 2 s . c o m generate("/schema/properties/primitiveProperties.json", "com.example", config("annotationStyle", "invalidstyle")); fail(); } catch (RuntimeException e) { assertThat(e.getCause(), is(instanceOf(MojoExecutionException.class))); assertThat(e.getCause().getMessage(), is(containsString("invalidstyle"))); } }
From source file:org.jsonschema2pojo.integration.config.AnnotationStyleIT.java
@Test public void invalidAnnotationStyleCausesMojoException() { try {/*from w ww .j a v a 2 s.co m*/ schemaRule.generate("/schema/properties/primitiveProperties.json", "com.example", config("annotationStyle", "invalidstyle")); fail(); } catch (RuntimeException e) { assertThat(e.getCause(), is(instanceOf(MojoExecutionException.class))); assertThat(e.getCause().getMessage(), is(containsString("invalidstyle"))); } }
From source file:io.rhiot.gateway.camel.webcam.WebcamComponentTest.java
@Test public void shouldValidateInvalidDriverClass() throws Exception { try {/*from w w w . j a v a2 s .c om*/ WebcamComponent component = new WebcamComponent(context); component.setDriver("invalid.driver"); component.start(); } catch (RuntimeException ex) { Truth.assertThat(ex.getCause()).isInstanceOf(ClassNotFoundException.class); return; } fail("Expected ClassNotFoundException to be thrown."); }
From source file:com.googlecode.jsonschema2pojo.integration.config.CustomAnnotatorIT.java
@Test public void invalidCustomAnnotatorClassCausesMojoException() { try {/*from w ww .j a v a 2 s. c o m*/ generate("/schema/properties/primitiveProperties.json", "com.example", config("customAnnotator", "java.lang.String")); fail(); } catch (RuntimeException e) { assertThat(e.getCause(), is(instanceOf(MojoExecutionException.class))); assertThat(e.getCause().getMessage(), is(containsString("annotator"))); } }
From source file:org.fornax.cartridges.sculptor.framework.web.errorhandling.ExceptionAdvice.java
protected String handleWrappingException(RequestContext requestContext, RuntimeException e) { Throwable cause = (e.getCause() == null ? e : e.getCause()); if (cause instanceof RemoteException) { cause = cause.getCause();//from w w w. jav a 2 s . c om } OptimisticLockingException ole = unwrapOptimisticLockingException(cause); ValidationException idoe = unwrapValidationException(cause); if (ole != null) { return handleOptimisticLockingException(requestContext, ole); } else if (idoe != null) { return handleValidationException(requestContext, idoe); } else if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else { // not a wrapped exception throw e; } }
From source file:org.sonar.process.AesCipherTest.java
@Test public void decrypt_bad_key() { AesCipher cipher = new AesCipher(getPath("bad_secret_key.txt")); try {//from w ww . java 2 s . c o m cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY="); fail(); } catch (RuntimeException e) { assertThat(e.getCause()).isInstanceOf(InvalidKeyException.class); } }