source: java2python/junit-t/resourcestest/testcode/GetResourcesTest.java@ 898

Last change on this file since 898 was 897, checked in by wouter, 5 months ago

remove unused code

File size: 900 bytes
RevLine 
[896]1package testcode;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.io.InputStream;
7
8import org.eclipse.jdt.annotation.NonNull;
9import org.junit.Test;
10import org.junit.internal.runners.JUnit4ClassRunner;
11import org.junit.runner.RunWith;
12
13/**
14 * Test to see if getResource can reach the resource file.
15 */
16@RunWith(JUnit4ClassRunner.class)
17public class GetResourcesTest {
18
19 /**
20 *
21 * @return string read from resource file
22 * @throws IOException
23 */
24 @Test
25 public void test1() throws IOException {
[897]26 final InputStream stream = getClass()
[896]27 .getResourceAsStream("theresource.txt");
28 /* use inputstream directly, this is the bottom level mechanism
29 * that should be supported
30 */
31 int c;
32 @NonNull
33 String s = "";
34 while (true) {
35 c = stream.read();
36 if (c == -1)
37 break;
38 s = s + Character.toChars(c)[0];
39 }
40 assertEquals("ok1", s);
41 }
42
43}
Note: See TracBrowser for help on using the repository browser.