List of usage examples for java.lang RuntimeException getCause
public synchronized Throwable getCause()
From source file:org.sonar.process.AesCipherTest.java
@Test public void decrypt_other_key() { AesCipher cipher = new AesCipher(getPath("other_secret_key.txt")); try {/*from ww w. java 2 s .c o m*/ // text encrypted with another key cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY="); fail(); } catch (RuntimeException e) { assertThat(e.getCause()).isInstanceOf(BadPaddingException.class); } }
From source file:org.sonar.application.AesCipherTest.java
@Test public void decrypt_bad_key() throws Exception { AesCipher cipher = new AesCipher(getPath("bad_secret_key.txt")); try {//ww w . j av a2s .c o m cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY="); fail(); } catch (RuntimeException e) { assertThat(e.getCause()).isInstanceOf(InvalidKeyException.class); } }
From source file:org.sonar.application.AesCipherTest.java
@Test public void decrypt_other_key() throws Exception { AesCipher cipher = new AesCipher(getPath("other_secret_key.txt")); try {//from ww w . j a v a 2 s . c o m // text encrypted with another key cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY="); fail(); } catch (RuntimeException e) { assertThat(e.getCause()).isInstanceOf(BadPaddingException.class); } }
From source file:org.jsonschema2pojo.integration.config.CustomAnnotatorIT.java
@Test public void invalidCustomAnnotatorClassCausesMojoException() { try {//from www. j a v a 2 s.com schemaRule.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.midonet.midolman.host.services.HostServiceTest.java
private void startAndStop() throws Throwable { HostService hostService = makeHostService(); try {//from www. ja va2 s . c om hostService.startAsync().awaitRunning(); } catch (RuntimeException e) { throw e.getCause(); } hostService.stopAsync().awaitTerminated(); }
From source file:io.airlift.http.server.TestHttpServerProvider.java
@Test public void testHttpIsDisabled() throws Exception { config.setHttpEnabled(false);/*from ww w . jav a 2s .c o m*/ createServer(); server.start(); try (HttpClient client = new JettyHttpClient( new HttpClientConfig().setConnectTimeout(new Duration(2.0, TimeUnit.SECONDS)))) { StatusResponse response = client.execute( prepareGet().setUri(httpServerInfo.getHttpUri().resolve("/")).build(), createStatusResponseHandler()); if (response != null) { // TODO: this is a workaround for a bug in AHC (some race condition) fail("Expected connection refused, got response code: " + response.getStatusCode()); } } catch (RuntimeException e) { assertTrue(e.getCause() instanceof ConnectException, e.getCause().getClass() + " instanceof ConnectException"); } }
From source file:org.neo4j.server.database.TestLifecycleManagedDatabase.java
@Test public void shouldComplainIfDatabaseLocationIsAlreadyInUse() throws Throwable { deletionFailureOk = true;//w ww.j a v a 2s.c om theDatabase.start(); LifecycleManagingDatabase db = newDatabase(); try { db.start(); } catch (RuntimeException e) { // Wrapped in a lifecycle exception, needs to be dug out assertThat(e.getCause().getCause(), instanceOf(StoreLockException.class)); } }
From source file:com.opengamma.util.test.HSQLDbManagement.java
@Override public void dropSchema(String catalog, String schema) { try {/* www . j a va 2s. c o m*/ super.dropSchema(catalog, schema); } catch (RuntimeException ex) { // try deleting database if (ex.getCause() instanceof SQLInvalidAuthorizationSpecException) { FileUtils.deleteQuietly(getFile()); super.dropSchema(catalog, schema); } } }
From source file:org.rhq.enterprise.server.resource.ResourceAvailabilityManagerBean.java
public ResourceAvailability getLatestAvailability(int resourceId) { Query query = entityManager.createNamedQuery(ResourceAvailability.QUERY_FIND_BY_RESOURCE_ID); query.setParameter("resourceId", resourceId); try {//from w w w. ja va 2s . c o m ResourceAvailability result = (ResourceAvailability) query.getSingleResult(); return result; } catch (NoResultException nre) { return null; } catch (RuntimeException re) { Throwable cause = re.getCause(); if (cause instanceof SQLException) { log.error("Failed to get latest avail for Resource [" + resourceId + "]: " + JDBCUtil.convertSQLExceptionToString((SQLException) cause)); } throw re; } }
From source file:org.sonar.api.config.AesCipherTest.java
@Test public void decrypt_bad_key() throws Exception { URL resource = getClass().getResource("/org/sonar/api/config/AesCipherTest/bad_secret_key.txt"); Settings settings = new Settings(); settings.setProperty(CoreProperties.ENCRYPTION_SECRET_KEY_PATH, new File(resource.toURI()).getCanonicalPath()); AesCipher cipher = new AesCipher(settings); try {//from w ww .jav a 2 s .c o m cipher.decrypt("9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY="); fail(); } catch (RuntimeException e) { assertThat(e.getCause(), is(InvalidKeyException.class)); } }