kazurayam / materialstore

A domain-specific file system to store "materials" (screenshots, HTML, JSON, XML) collected during End-to-End testings using Selenium WebDriver etc. Features to make "diff" and compiling HTML reports are also included. This is written in pure Java8
Apache License 2.0
0 stars 0 forks source link

add Material.Builder(URL fileURL) #312

Closed kazurayam closed 2 years ago

kazurayam commented 2 years ago

not only URL in http:// + https://, but also file:

kazurayam commented 2 years ago

I made a test as follows:

    @Test
    public void testFileURLSupport() throws MalformedURLException {
        String fileUrlString = "file:/Users/who/bar/baz.txt";
        URL url = new URL(fileUrlString);
        Metadata md = new Metadata.Builder(url).build();
        System.out.println(md.toJson(true));
        assertTrue(md.containsKey("URL.protocol"), "URL.protocol is not contained");
        assertEquals("file", md.get("URL.protocol"));
        assertTrue(md.containsKey("URL.path"), "URL.path is not contained");
        assertEquals("/Users/who/bar/baz.txt", md.get("URL.path"));
    }

It emitted :

{
  "URL.host": {
    "key": "URL.host",
    "value": ""
  },
  "URL.path": {
    "key": "URL.path",
    "value": "/Users/who/bar/baz.txt"
  },
  "URL.protocol": {
    "key": "URL.protocol",
    "value": "file"
  }
}

So the file URL is already supported by Metadata.Builder(URL) method