//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testBaseDir() throws Exception public virtual void testBaseDir() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.io.File super = createTempDir("fsResourceLoaderBase").getAbsoluteFile(); File @base = createTempDir("fsResourceLoaderBase").AbsoluteFile; try { @base.mkdirs(); Writer os = new System.IO.StreamWriter(new System.IO.FileStream(@base, "template.txt", System.IO.FileMode.Create, System.IO.FileAccess.Write), Encoding.UTF8); try { os.write("foobar\n"); } finally { IOUtils.closeWhileHandlingException(os); } ResourceLoader rl = new FilesystemResourceLoader(@base); assertEquals("foobar", WordlistLoader.getLines(rl.openResource("template.txt"), StandardCharsets.UTF_8).get(0)); // Same with full path name: string fullPath = (new File(@base, "template.txt")).ToString(); assertEquals("foobar", WordlistLoader.getLines(rl.openResource(fullPath), StandardCharsets.UTF_8).get(0)); assertClasspathDelegation(rl); assertNotFound(rl); // now use RL without base dir: rl = new FilesystemResourceLoader(); assertEquals("foobar", WordlistLoader.getLines(rl.openResource((new File(@base, "template.txt")).ToString()), StandardCharsets.UTF_8).get(0)); assertClasspathDelegation(rl); assertNotFound(rl); } finally { TestUtil.rm(@base); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testDelegation() throws Exception public virtual void testDelegation() { ResourceLoader rl = new FilesystemResourceLoader(null, new StringMockResourceLoader("foobar\n")); assertEquals("foobar", WordlistLoader.getLines(rl.openResource("template.txt"), StandardCharsets.UTF_8).get(0)); }