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

Last change on this file since 1421 was 1210, checked in by wouter, 3 months ago

changed GetResourcesTest in junit-t to check that casting to char now works.

File size: 933 bytes
Line 
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 {
26 final InputStream stream = getClass()
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 // you can also use Character.toChars(c)[0];
39 s = s + (char) c;
40 }
41 assertEquals("ok1", s);
42 }
43
44}
Note: See TracBrowser for help on using the repository browser.