Пример #1
0
  @Test
  public void testAddJasperReportsViewResolver() {
    String webMvcConfig = WEB_MVC_CONFIG;
    PathResolver pathResolver = projectOperations.getPathResolver();
    when(pathResolver.getIdentifier(
            LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), "WEB-INF/spring/webmvc-config.xml"))
        .thenReturn(webMvcConfig);
    StubMutableFile webMvcConfigFile =
        new StubMutableFile(new File(getClass().getResource(webMvcConfig).getFile()));
    when(fileManager.exists(webMvcConfig)).thenReturn(true);
    when(fileManager.updateFile(webMvcConfig)).thenReturn(webMvcConfigFile);

    // operations.addJasperReportsViewResolver();
    String output = webMvcConfigFile.getOutputAsString();
    assertThat(
        output,
        containsString(
            "<bean id=\"jasperReportsXmlViewResolver\" class=\"org.springframework.web.servlet.view.XmlViewResolver\" p:location=\"/WEB-INF/spring/jasper-views.xml\" p:order=\"0\" />"));
    assertThat(output, containsString("<import resource=\"jasper-views.xml\" />"));
  }