org.springframework.core.NestedRuntimeException Java Examples
The following examples show how to use
org.springframework.core.NestedRuntimeException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityPersistHandler.java From secure-data-service with Apache License 2.0 | 6 votes |
boolean update(String collectionName, Entity entity, List<Entity> failed, AbstractMessageReport report, ReportStats reportStats, Source nrSource) { boolean res = false; try { res = entityRepository.updateWithRetries(collectionName, entity, totalRetries); if (!res) { failed.add(entity); } } catch (MongoException e) { NestedRuntimeException wrapper = new NestedRuntimeException("Mongo Exception", e) { private static final long serialVersionUID = 1L; }; reportWarnings(wrapper.getMostSpecificCause().getMessage(), collectionName, ((SimpleEntity) entity).getSourceFile(), report, reportStats, nrSource); } return res; }
Example #2
Source File: ComposablePointcutTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testFilterByClass() throws NoSuchMethodException { ComposablePointcut pc = new ComposablePointcut(); assertTrue(pc.getClassFilter().matches(Object.class)); ClassFilter cf = new RootClassFilter(Exception.class); pc.intersection(cf); assertFalse(pc.getClassFilter().matches(Object.class)); assertTrue(pc.getClassFilter().matches(Exception.class)); pc.intersection(new RootClassFilter(NestedRuntimeException.class)); assertFalse(pc.getClassFilter().matches(Exception.class)); assertTrue(pc.getClassFilter().matches(NestedRuntimeException.class)); assertFalse(pc.getClassFilter().matches(String.class)); pc.union(new RootClassFilter(String.class)); assertFalse(pc.getClassFilter().matches(Exception.class)); assertTrue(pc.getClassFilter().matches(String.class)); assertTrue(pc.getClassFilter().matches(NestedRuntimeException.class)); }
Example #3
Source File: ComposablePointcutTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testFilterByClass() throws NoSuchMethodException { ComposablePointcut pc = new ComposablePointcut(); assertTrue(pc.getClassFilter().matches(Object.class)); ClassFilter cf = new RootClassFilter(Exception.class); pc.intersection(cf); assertFalse(pc.getClassFilter().matches(Object.class)); assertTrue(pc.getClassFilter().matches(Exception.class)); pc.intersection(new RootClassFilter(NestedRuntimeException.class)); assertFalse(pc.getClassFilter().matches(Exception.class)); assertTrue(pc.getClassFilter().matches(NestedRuntimeException.class)); assertFalse(pc.getClassFilter().matches(String.class)); pc.union(new RootClassFilter(String.class)); assertFalse(pc.getClassFilter().matches(Exception.class)); assertTrue(pc.getClassFilter().matches(String.class)); assertTrue(pc.getClassFilter().matches(NestedRuntimeException.class)); }
Example #4
Source File: ComposablePointcutTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testFilterByClass() throws NoSuchMethodException { ComposablePointcut pc = new ComposablePointcut(); assertTrue(pc.getClassFilter().matches(Object.class)); ClassFilter cf = new RootClassFilter(Exception.class); pc.intersection(cf); assertFalse(pc.getClassFilter().matches(Object.class)); assertTrue(pc.getClassFilter().matches(Exception.class)); pc.intersection(new RootClassFilter(NestedRuntimeException.class)); assertFalse(pc.getClassFilter().matches(Exception.class)); assertTrue(pc.getClassFilter().matches(NestedRuntimeException.class)); assertFalse(pc.getClassFilter().matches(String.class)); pc.union(new RootClassFilter(String.class)); assertFalse(pc.getClassFilter().matches(Exception.class)); assertTrue(pc.getClassFilter().matches(String.class)); assertTrue(pc.getClassFilter().matches(NestedRuntimeException.class)); }
Example #5
Source File: DefaultMailService.java From iotplatform with Apache License 2.0 | 5 votes |
protected IoTPException handleException(Exception exception) { String message; if (exception instanceof NestedRuntimeException) { message = ((NestedRuntimeException) exception).getMostSpecificCause().getMessage(); } else { message = exception.getMessage(); } return new IoTPException(String.format("Unable to send mail: %s", message), IoTPErrorCode.GENERAL); }
Example #6
Source File: EnableDiscoveryClientMissingImplTests.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@Test public void testContextFails() { try (ConfigurableApplicationContext context = new SpringApplicationBuilder() .sources(App.class).web(WebApplicationType.NONE).run()) { // do sth } catch (NestedRuntimeException e) { Throwable rootCause = e.getRootCause(); then(rootCause instanceof IllegalStateException).isTrue(); then(rootCause.getMessage().contains("no implementations")).isTrue(); } }
Example #7
Source File: SimpleInterceptorChain.java From onetwo with Apache License 2.0 | 5 votes |
private RuntimeException convertRuntimeException(Throwable e){ if (e instanceof InvocationTargetException) { InvocationTargetException ite = (InvocationTargetException)e; Throwable target = ite.getTargetException(); if(target instanceof NestedRuntimeException){ throw (NestedRuntimeException)ite.getTargetException(); } } else if ( e instanceof RuntimeException) { throw (RuntimeException) e; } return new BaseException("invoke method error, targetMethod: " + targetMethod, e); }
Example #8
Source File: ClientCertificateAuthenticationStepsIntegrationTests.java From spring-vault with Apache License 2.0 | 5 votes |
@Test void authenticationStepsLoginShouldFail() { ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create(new ClientOptions(), Settings.createSslConfiguration()); RestTemplate restTemplate = VaultClients.createRestTemplate(TestRestTemplateFactory.TEST_VAULT_ENDPOINT, clientHttpRequestFactory); assertThatExceptionOfType(NestedRuntimeException.class).isThrownBy( () -> new AuthenticationStepsExecutor(ClientCertificateAuthentication.createAuthenticationSteps(), restTemplate).login()); }
Example #9
Source File: ClientCertificateAuthenticationIntegrationTests.java From spring-vault with Apache License 2.0 | 5 votes |
@Test void loginShouldFail() { ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create(new ClientOptions(), Settings.createSslConfiguration()); RestTemplate restTemplate = VaultClients.createRestTemplate(TestRestTemplateFactory.TEST_VAULT_ENDPOINT, clientHttpRequestFactory); assertThatExceptionOfType(NestedRuntimeException.class) .isThrownBy(() -> new ClientCertificateAuthentication(restTemplate).login()); }
Example #10
Source File: ClientCertificateAuthenticationIntegrationTests.java From spring-vault with Apache License 2.0 | 5 votes |
@Test void shouldSelectInvalidKey() { ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory.create(new ClientOptions(), prepareCertAuthenticationMethod(SslConfiguration.KeyConfiguration.of("changeit".toCharArray(), "2"))); RestTemplate restTemplate = VaultClients.createRestTemplate(TestRestTemplateFactory.TEST_VAULT_ENDPOINT, clientHttpRequestFactory); ClientCertificateAuthentication authentication = new ClientCertificateAuthentication(restTemplate); assertThatExceptionOfType(NestedRuntimeException.class).isThrownBy(authentication::login); }
Example #11
Source File: BeanCreationException.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public boolean contains(Class<?> exClass) { if (super.contains(exClass)) { return true; } if (this.relatedCauses != null) { for (Throwable relatedCause : this.relatedCauses) { if (relatedCause instanceof NestedRuntimeException && ((NestedRuntimeException) relatedCause).contains(exClass)) { return true; } } } return false; }
Example #12
Source File: BshScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void scriptCompilationException() throws Exception { try { new ClassPathXmlApplicationContext("org/springframework/scripting/bsh/bshBrokenContext.xml"); fail("Must throw exception for broken script file"); } catch (NestedRuntimeException ex) { assertTrue(ex.contains(ScriptCompilationException.class)); } }
Example #13
Source File: GroovyScriptFactoryTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testScriptCompilationException() throws Exception { try { new ClassPathXmlApplicationContext("org/springframework/scripting/groovy/groovyBrokenContext.xml"); fail("Should throw exception for broken script file"); } catch (NestedRuntimeException ex) { assertTrue("Wrong root cause: " + ex, ex.contains(ScriptCompilationException.class)); } }
Example #14
Source File: ClassFiltersTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testIntersection() { assertTrue(exceptionFilter.matches(RuntimeException.class)); assertTrue(hasRootCauseFilter.matches(NestedRuntimeException.class)); ClassFilter intersection = ClassFilters.intersection(exceptionFilter, hasRootCauseFilter); assertFalse(intersection.matches(RuntimeException.class)); assertFalse(intersection.matches(TestBean.class)); assertTrue(intersection.matches(NestedRuntimeException.class)); }
Example #15
Source File: BeanCreationException.java From blog_demos with Apache License 2.0 | 5 votes |
@Override public boolean contains(Class<?> exClass) { if (super.contains(exClass)) { return true; } if (this.relatedCauses != null) { for (Throwable relatedCause : this.relatedCauses) { if (relatedCause instanceof NestedRuntimeException && ((NestedRuntimeException) relatedCause).contains(exClass)) { return true; } } } return false; }
Example #16
Source File: BeanCreationException.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public boolean contains(Class<?> exClass) { if (super.contains(exClass)) { return true; } if (this.relatedCauses != null) { for (Throwable relatedCause : this.relatedCauses) { if (relatedCause instanceof NestedRuntimeException && ((NestedRuntimeException) relatedCause).contains(exClass)) { return true; } } } return false; }
Example #17
Source File: BeanCreationException.java From java-technology-stack with MIT License | 5 votes |
@Override public boolean contains(@Nullable Class<?> exClass) { if (super.contains(exClass)) { return true; } if (this.relatedCauses != null) { for (Throwable relatedCause : this.relatedCauses) { if (relatedCause instanceof NestedRuntimeException && ((NestedRuntimeException) relatedCause).contains(exClass)) { return true; } } } return false; }
Example #18
Source File: BshScriptFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void scriptCompilationException() { try { new ClassPathXmlApplicationContext("org/springframework/scripting/bsh/bshBrokenContext.xml"); fail("Must throw exception for broken script file"); } catch (NestedRuntimeException ex) { assertTrue(ex.contains(ScriptCompilationException.class)); } }
Example #19
Source File: GroovyScriptFactoryTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testScriptCompilationException() throws Exception { try { new ClassPathXmlApplicationContext("org/springframework/scripting/groovy/groovyBrokenContext.xml"); fail("Should throw exception for broken script file"); } catch (NestedRuntimeException ex) { assertTrue("Wrong root cause: " + ex, ex.contains(ScriptCompilationException.class)); } }
Example #20
Source File: ClassFiltersTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testIntersection() { assertTrue(exceptionFilter.matches(RuntimeException.class)); assertTrue(hasRootCauseFilter.matches(NestedRuntimeException.class)); ClassFilter intersection = ClassFilters.intersection(exceptionFilter, hasRootCauseFilter); assertFalse(intersection.matches(RuntimeException.class)); assertFalse(intersection.matches(TestBean.class)); assertTrue(intersection.matches(NestedRuntimeException.class)); }
Example #21
Source File: BeanCreationException.java From spring-analysis-note with MIT License | 5 votes |
@Override public boolean contains(@Nullable Class<?> exClass) { if (super.contains(exClass)) { return true; } if (this.relatedCauses != null) { for (Throwable relatedCause : this.relatedCauses) { if (relatedCause instanceof NestedRuntimeException && ((NestedRuntimeException) relatedCause).contains(exClass)) { return true; } } } return false; }
Example #22
Source File: BshScriptFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void scriptCompilationException() { try { new ClassPathXmlApplicationContext("org/springframework/scripting/bsh/bshBrokenContext.xml"); fail("Must throw exception for broken script file"); } catch (NestedRuntimeException ex) { assertTrue(ex.contains(ScriptCompilationException.class)); } }
Example #23
Source File: GroovyScriptFactoryTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testScriptCompilationException() throws Exception { try { new ClassPathXmlApplicationContext("org/springframework/scripting/groovy/groovyBrokenContext.xml"); fail("Should throw exception for broken script file"); } catch (NestedRuntimeException ex) { assertTrue("Wrong root cause: " + ex, ex.contains(ScriptCompilationException.class)); } }
Example #24
Source File: ClassFiltersTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testIntersection() { assertTrue(exceptionFilter.matches(RuntimeException.class)); assertTrue(hasRootCauseFilter.matches(NestedRuntimeException.class)); ClassFilter intersection = ClassFilters.intersection(exceptionFilter, hasRootCauseFilter); assertFalse(intersection.matches(RuntimeException.class)); assertFalse(intersection.matches(TestBean.class)); assertTrue(intersection.matches(NestedRuntimeException.class)); }
Example #25
Source File: RestErrorHandlerImpl.java From moserp with Apache License 2.0 | 4 votes |
@Override @UiThread public void onRestClientExceptionThrown(NestedRuntimeException e) { Log.d("RestErrorHandler", "Error! " + e); Toast.makeText(context, R.string.toast_backend_error, Toast.LENGTH_SHORT).show(); }