//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test_of_classpath() throws Exception public virtual void test_of_classpath() { ResourceLocator test = ResourceLocator.of("classpath:com/opengamma/strata/collect/io/TestFile.txt"); assertTrue(test.Locator.StartsWith("classpath", StringComparison.Ordinal)); assertTrue(test.Locator.EndsWith("com/opengamma/strata/collect/io/TestFile.txt", StringComparison.Ordinal)); assertEquals(test.ByteSource.read()[0], 'H'); assertEquals(test.CharSource.readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.getCharSource(StandardCharsets.UTF_8).readLines(), ImmutableList.of("HelloWorld")); assertTrue(test.ToString().StartsWith("classpath", StringComparison.Ordinal)); assertTrue(test.ToString().EndsWith("com/opengamma/strata/collect/io/TestFile.txt", StringComparison.Ordinal)); }
//------------------------------------------------------------------------- //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test_orderedResources() throws Exception public virtual void test_orderedResources() { IList <ResourceLocator> list = ResourceConfig.orderedResources("TestFile.txt"); assertEquals(list.Count, 1); ResourceLocator test = list[0]; assertEquals(test.Locator.StartsWith("classpath", StringComparison.Ordinal), true); assertEquals(test.Locator.EndsWith("com/opengamma/strata/config/base/TestFile.txt", StringComparison.Ordinal), true); assertEquals(test.ByteSource.read()[0], 'H'); assertEquals(test.CharSource.readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.getCharSource(StandardCharsets.UTF_8).readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.ToString().StartsWith("classpath", StringComparison.Ordinal), true); assertEquals(test.ToString().EndsWith("com/opengamma/strata/config/base/TestFile.txt", StringComparison.Ordinal), true); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test_of_fileNoPrefix() throws Exception public virtual void test_of_fileNoPrefix() { ResourceLocator test = ResourceLocator.of("src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); assertEquals(test.Locator, "file:src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); assertEquals(test.ByteSource.read()[0], 'H'); assertEquals(test.CharSource.readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.getCharSource(StandardCharsets.UTF_8).readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.ToString(), "file:src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test_ofPath() throws Exception public virtual void test_ofPath() { Path path = Paths.get("src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); ResourceLocator test = ResourceLocator.ofPath(path); assertEquals(test.Locator.Replace('\\', '/'), "file:src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); assertEquals(test.ByteSource.read()[0], 'H'); assertEquals(test.CharSource.readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.getCharSource(StandardCharsets.UTF_8).readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.ToString().Replace('\\', '/'), "file:src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test_ofPath_zipFile() throws Exception public virtual void test_ofPath_zipFile() { Path path = Paths.get("src/test/resources/com/opengamma/strata/collect/io/TestFile.zip"); ResourceLocator test = ResourceLocator.ofPath(path); assertEquals(test.Locator.Replace('\\', '/'), "file:src/test/resources/com/opengamma/strata/collect/io/TestFile.zip"); sbyte[] read = test.ByteSource.read(); assertEquals(read[0], 80); // these are the standard header of a zip file assertEquals(read[1], 75); assertEquals(read[2], 3); assertEquals(read[3], 4); assertEquals(test.ToString().Replace('\\', '/'), "file:src/test/resources/com/opengamma/strata/collect/io/TestFile.zip"); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test_ofUrl() throws Exception public virtual void test_ofUrl() { File file = new File("src/test/resources/com/opengamma/strata/collect/io/TestFile.txt"); URL url = file.toURI().toURL(); ResourceLocator test = ResourceLocator.ofUrl(url); string locator = test.Locator; assertTrue(locator.StartsWith("url:file:", StringComparison.Ordinal)); assertTrue(locator.EndsWith("src/test/resources/com/opengamma/strata/collect/io/TestFile.txt", StringComparison.Ordinal)); assertEquals(test.ByteSource.read()[0], 'H'); assertEquals(test.CharSource.readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.getCharSource(StandardCharsets.UTF_8).readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.ToString(), locator); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void test_ofPath_fileInZipFile() throws Exception public virtual void test_ofPath_fileInZipFile() { Path zip = Paths.get("src/test/resources/com/opengamma/strata/collect/io/TestFile.zip"); using (FileSystem fs = FileSystems.newFileSystem(zip, null)) { Path path = fs.getPath("TestFile.txt").toAbsolutePath(); ResourceLocator test = ResourceLocator.ofPath(path); string locator = test.Locator; assertTrue(locator.StartsWith("url:jar:file:", StringComparison.Ordinal)); assertTrue(locator.EndsWith("src/test/resources/com/opengamma/strata/collect/io/TestFile.zip!/TestFile.txt", StringComparison.Ordinal)); assertEquals(test.ByteSource.read()[0], 'H'); assertEquals(test.CharSource.readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.getCharSource(StandardCharsets.UTF_8).readLines(), ImmutableList.of("HelloWorld")); assertEquals(test.ToString(), locator); } }