1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat.document.impl;
20
21 import java.io.BufferedReader;
22 import java.io.File;
23 import java.io.Reader;
24
25 import junit.framework.TestCase;
26
27 import org.apache.rat.api.Document;
28 import org.apache.rat.test.utils.Resources;
29
30 public class SingularFileDocumentTest extends TestCase {
31 private Document document;
32 private File file;
33
34 protected void setUp() throws Exception {
35 super.setUp();
36 file = Resources.getResourceFile("elements/Source.java");
37 document = new MonolithicFileDocument(file);
38 }
39
40 protected void tearDown() throws Exception {
41 super.tearDown();
42 }
43
44 public void testReader() throws Exception {
45 Reader reader = document.reader();
46 assertNotNull("Reader should be returned", reader);
47 assertEquals("First file line expected", "package elements;",
48 new BufferedReader(reader).readLine());
49 }
50
51 public void testGetName() {
52 final String name = document.getName();
53 assertNotNull("Name is set", name);
54 assertEquals("Name is filename", DocumentImplUtils.toName(file), name);
55 }
56 }