コード例 #1
0
  @Test
  public void testOpenWithExistingLocation() throws IOException {
    String data = "test data";

    File file = File.createTempFile(FileSystemResourceLoaderTest.class.getSimpleName(), ".data");
    InputStream inputStream = null;
    try {
      FileUtils.write(file, data);

      inputStream = loader.openStream("file:" + file.getAbsolutePath());

      String actualData = IOUtils.toString(inputStream);
      assertThat(actualData).isEqualTo(data);
    } finally {
      MiscUtils.closeQuietly(inputStream);
      file.delete();
    }
  }
コード例 #2
0
 @Test(expected = IllegalArgumentException.class)
 public void testOpenWithEmptyLocation() throws IOException {
   loader.openStream("");
 }
コード例 #3
0
  @Test
  public void testOpenWithNonExistentLocation() throws IOException {
    InputStream inputStream = loader.openStream("file:/test43243958438");

    assertThat(inputStream).isNull();
  }
コード例 #4
0
 @Test(expected = NullPointerException.class)
 public void testOpenWithNullLocation() throws IOException {
   loader.openStream(null);
 }
コード例 #5
0
 @Test(expected = IllegalArgumentException.class)
 public void testOpenWithInvalidSchema() throws IOException {
   loader.openStream("http:/tmp/test");
 }
コード例 #6
0
 @Test(expected = IllegalArgumentException.class)
 public void testOpenWithInvalidLocation() throws IOException {
   loader.openStream("file/tmp/test");
 }