コード例 #1
0
  protected void assertResource(String name, String expectedContent) throws Exception {
    ResourceLoader resourceLoader = (ResourceLoader) lookup(ResourceLoader.ROLE);

    InputStream is = resourceLoader.getResourceAsInputStream(name);

    assertNotNull("The returned input stream is null, name: '" + name + "'.", is);

    String actialContent = IOUtil.toString(is);

    assertEquals(expectedContent, actialContent);
  }
コード例 #2
0
  protected void assertMissingResource(String name) throws Exception {
    ResourceLoader resourceLoader = (ResourceLoader) lookup(ResourceLoader.ROLE);

    try {
      InputStream is = resourceLoader.getResourceAsInputStream(name);

      String content = IOUtil.toString(is);

      fail(
          "Expected ResourceNotFoundException while looking for a resource named '"
              + name
              + "'. Content:\n"
              + content);
    } catch (ResourceNotFoundException e) {
      // expected
    }
  }