Last change
on this file since 896 was 896, checked in by wouter, 8 months ago |
#310 moved GetResourcesTest to junit-t because this test is so much easier if we have junit translator and package translation. junit tests now require @RunWith annotation for proper translation. Added more translators
|
File size:
1.1 KB
|
Rev | Line | |
---|
[896] | 1 | package testcode;
|
---|
| 2 |
|
---|
| 3 | import static org.junit.Assert.assertEquals;
|
---|
| 4 |
|
---|
| 5 | import java.io.IOException;
|
---|
| 6 | import java.io.InputStream;
|
---|
| 7 |
|
---|
| 8 | import org.eclipse.jdt.annotation.NonNull;
|
---|
| 9 | import org.junit.Test;
|
---|
| 10 | import org.junit.internal.runners.JUnit4ClassRunner;
|
---|
| 11 | import org.junit.runner.RunWith;
|
---|
| 12 |
|
---|
| 13 | /**
|
---|
| 14 | * Test to see if getResource can reach the resource file.
|
---|
| 15 | */
|
---|
| 16 | @RunWith(JUnit4ClassRunner.class)
|
---|
| 17 | public 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 @NonNull 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 | s = s + Character.toChars(c)[0];
|
---|
| 39 | }
|
---|
| 40 | assertEquals("ok1", s);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | // /**
|
---|
| 44 | // *
|
---|
| 45 | // * @param args the arguments of the call.
|
---|
| 46 | // * @throws IOException
|
---|
| 47 | // */
|
---|
| 48 | // static public void main(String[] args) throws IOException {
|
---|
| 49 | // new GetResourcesTest();
|
---|
| 50 | // }
|
---|
| 51 |
|
---|
| 52 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.