org.springframework.context.ApplicationContextException.getMessage()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(29)

本文整理了Java中org.springframework.context.ApplicationContextException.getMessage()方法的一些代码示例,展示了ApplicationContextException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContextException.getMessage()方法的具体详情如下:
包路径:org.springframework.context.ApplicationContextException
类名称:ApplicationContextException
方法名:getMessage

ApplicationContextException.getMessage介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Test
public void missingGroovyMarkupConfig() throws Exception {
  GroovyMarkupView view = new GroovyMarkupView();
  given(this.webAppContext.getBeansOfType(GroovyMarkupConfig.class, true, false))
      .willReturn(new HashMap<>());
  view.setUrl("sampleView");
  try {
    view.setApplicationContext(this.webAppContext);
    fail();
  }
  catch (ApplicationContextException ex) {
    assertTrue(ex.getMessage().contains("GroovyMarkupConfig"));
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testContextLoaderListenerWithUnknownContextInitializer() {
  MockServletContext sc = new MockServletContext("");
  // config file doesn't matter.  just a placeholder
  sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
      "/org/springframework/web/context/WEB-INF/empty-context.xml");
  sc.addInitParameter(ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM,
      StringUtils.arrayToCommaDelimitedString(new Object[] {UnknownContextInitializer.class.getName()}));
  ContextLoaderListener listener = new ContextLoaderListener();
  try {
    listener.contextInitialized(new ServletContextEvent(sc));
    fail("expected exception");
  }
  catch (ApplicationContextException ex) {
    assertTrue(ex.getMessage().contains("not assignable"));
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void testXmlViewResolverWithoutCache() throws Exception {
  StaticWebApplicationContext wac = new StaticWebApplicationContext() {
    @Override
    protected Resource getResourceByPath(String path) {
      assertTrue("Correct default location", XmlViewResolver.DEFAULT_LOCATION.equals(path));
      return super.getResourceByPath(path);
    }
  };
  wac.setServletContext(new MockServletContext());
  wac.refresh();
  XmlViewResolver vr = new XmlViewResolver();
  vr.setCache(false);
  try {
    vr.setApplicationContext(wac);
  }
  catch (ApplicationContextException ex) {
    fail("Should not have thrown ApplicationContextException: " + ex.getMessage());
  }
  try {
    vr.resolveViewName("example1", Locale.getDefault());
    fail("Should have thrown BeanDefinitionStoreException");
  }
  catch (BeanDefinitionStoreException ex) {
    // expected
  }
}

代码示例来源:origin: spring-projects/spring-amqp

@Test
public void testNoAdmin() throws Exception {
  try {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config0.class);
    context.close();
    fail("expected initialization failure");
  }
  catch (ApplicationContextException e) {
    assertThat(e.getCause().getCause(), instanceOf(IllegalStateException.class));
    assertThat(e.getMessage(), containsString("When 'mismatchedQueuesFatal' is 'true', there must be "
        + "exactly one AmqpAdmin in the context or you must inject one into this container; found: 0"));
  }
}

相关文章