本文整理匯總了Java中org.springframework.core.NestedRuntimeException類的典型用法代碼示例。如果您正苦於以下問題:Java NestedRuntimeException類的具體用法?Java NestedRuntimeException怎麽用?Java NestedRuntimeException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NestedRuntimeException類屬於org.springframework.core包,在下文中一共展示了NestedRuntimeException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invoke
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@Override
protected Object invoke(final RemoteInvocation invocation, final Object targetObject)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
Throwable unwrapped = null;
try
{
Object rval = super.invoke(invocation, targetObject);
rval = initialiser.unwrapHibernate(rval);
rval = initialiser.initialise(rval, new RemoteSimplifier());
return rval;
}
catch( InvocationTargetException e )
{
unwrapped = e.getTargetException();
Throwable t2 = unwrapped;
// We want to determine if hibernate exception is thrown at any
// point
while( t2 != null )
{
if( t2 instanceof NestedRuntimeException )
{
logger.error(unwrapped.getMessage(), unwrapped);
throw new RuntimeApplicationException(unwrapped.getMessage());
}
t2 = t2.getCause();
}
logger.error("Error invoking " + invocation.getMethodName(), unwrapped);
throw e;
}
}
示例2: testFilterByClass
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@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));
}
示例3: getSystemException
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
/**
* Selecting {@link SystemException} from {@link BeanCreationException} causes if exists to be able to return with user-readable exception message.
* @param e is the catched exception
* @return with {@link SystemException} if causes contains {@link SystemException} else null
*/
public SystemException getSystemException(final Exception e) {
SystemException result = null;
if (e instanceof BeanCreationException) {
if (((NestedRuntimeException) e).getMostSpecificCause() != null) {
Throwable ex = e;
boolean found = false;
while (ex.getCause() != null && !found) {
if (ex.getCause() instanceof SystemException) {
found = true;
result = (SystemException) ex.getCause();
}
ex = ex.getCause();
}
}
}
return result;
}
示例4: update
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
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;
}
示例5: contains
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@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;
}
示例6: handleException
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
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);
}
示例7: testIntersection
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@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));
}
示例8: testScriptCompilationException
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@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));
}
}
示例9: scriptCompilationException
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@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));
}
}
示例10: findSpringBean
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
/**
* Looks up a Spring managed bean from an Application Context. First looks for a bean
* with name specified. If no such bean exists, looks for a bean by type. If there is
* only one bean of the appropriate type, it is returned. If zero or more than one bean
* of the correct type exists, an exception is thrown.
*
* @param ctx the Spring Application Context
* @param name the name of the spring bean to look for
* @param type the type of bean to look for
* @param allowFindByType true to indicate that finding a bean by type is acceptable
* if find by name fails.
* @exception RuntimeException various subclasses of RuntimeException are thrown if it
* is not possible to find a unique matching bean in the spring context given
* the constraints supplied.
*/
public static Object findSpringBean(ApplicationContext ctx,
String name,
Class<?> type,
boolean allowFindByType) {
// First try to lookup using the name provided
try {
Object bean = ctx.getBean(name, type);
if (bean != null) {
log.debug("Found spring bean with name [", name, "] and type [", bean.getClass()
.getName(), "]");
}
return bean;
}
catch (NestedRuntimeException nre) {
if (!allowFindByType) throw nre;
}
// If we got here then we didn't find a bean yet, try by type
String[] beanNames = ctx.getBeanNamesForType(type);
if (beanNames.length == 0) {
throw new StripesRuntimeException(
"Unable to find SpringBean with name [" + name + "] or type [" +
type.getName() + "] in the Spring application context.");
}
else if (beanNames.length > 1) {
throw new StripesRuntimeException(
"Unable to find SpringBean with name [" + name + "] or unique bean with type [" +
type.getName() + "] in the Spring application context. Found " + beanNames.length +
"beans of matching type.");
}
else {
log.debug("Found unique SpringBean with type [" + type.getName() + "]. Matching on ",
"type is a little risky so watch out!");
return ctx.getBean(beanNames[0], type);
}
}
示例11: loginShouldFail
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@Test(expected = NestedRuntimeException.class)
public void loginShouldFail() {
ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory
.create(new ClientOptions(), Settings.createSslConfiguration());
RestTemplate restTemplate = VaultClients.createRestTemplate(
TestRestTemplateFactory.TEST_VAULT_ENDPOINT, clientHttpRequestFactory);
new ClientCertificateAuthentication(restTemplate).login();
}
開發者ID:spring-projects,項目名稱:spring-vault,代碼行數:11,代碼來源:ClientCertificateAuthenticationIntegrationTests.java
示例12: authenticationStepsLoginShouldFail
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@Test(expected = NestedRuntimeException.class)
public void authenticationStepsLoginShouldFail() {
ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory
.create(new ClientOptions(), Settings.createSslConfiguration());
RestTemplate restTemplate = VaultClients.createRestTemplate(
TestRestTemplateFactory.TEST_VAULT_ENDPOINT, clientHttpRequestFactory);
new AuthenticationStepsExecutor(
ClientCertificateAuthentication.createAuthenticationSteps(), restTemplate)
.login();
}
開發者ID:spring-projects,項目名稱:spring-vault,代碼行數:13,代碼來源:ClientCertificateAuthenticationStepsIntegrationTests.java
示例13: handleException
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
protected ThingsboardException handleException(Exception exception) {
String message;
if (exception instanceof NestedRuntimeException) {
message = ((NestedRuntimeException)exception).getMostSpecificCause().getMessage();
} else {
message = exception.getMessage();
}
return new ThingsboardException(String.format("Unable to send mail: %s", message),
ThingsboardErrorCode.GENERAL);
}
示例14: invalidPollEndpoint
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@Test
public void invalidPollEndpoint() throws Exception {
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
ctx.register(SettingsConfiguration.class);
ctx.getEnvironment().getPropertySources().addFirst(exclude(validProperties(), "taxiiService.pollEndpoint"));
ctx.refresh();
fail("The context creation must fail because of invalid configuration.");
} catch (NestedRuntimeException e) {
BindException be = (BindException) e.getRootCause();
handler.handle(be);
verify(err).println(contains("pollEndpoint has illegal value"));
}
}
示例15: refuseMissingConfiguration
import org.springframework.core.NestedRuntimeException; //導入依賴的package包/類
@Test
public void refuseMissingConfiguration() throws Exception {
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SettingsConfiguration.class)) {
fail("The context creation must fail because of missing configuration.");
} catch (NestedRuntimeException e) {
BindException be = (BindException) e.getRootCause();
assertThat(be.getFieldErrors(), is(not(emptyCollectionOf(FieldError.class))));
}
}