|
3 | 3 | import org.junit.Test; |
4 | 4 |
|
5 | 5 | import com.ukubuka.core.exception.ReaderException; |
| 6 | +import com.ukubuka.core.model.SupportedSource; |
6 | 7 |
|
7 | 8 | /** |
8 | 9 | * Ukubuka Reader Test |
|
12 | 13 | */ |
13 | 14 | public class UkubukaReaderTest { |
14 | 15 |
|
15 | | - private UkubukaReader ukubukaReader; |
| 16 | + private UkubukaReader ukubukaReader = new UkubukaReader(); |
16 | 17 |
|
17 | 18 | /******************************** Test(s) ********************************/ |
18 | | - @Test(expected = NullPointerException.class) |
19 | | - public void test_readFile_success() throws ReaderException { |
20 | | - ukubukaReader.readFile(null, null, null, null); |
| 19 | + @Test |
| 20 | + public void test_readFile_withDelim_success() throws ReaderException { |
| 21 | + ukubukaReader.readFile( |
| 22 | + SupportedSource.FILE, this.getClass().getClassLoader() |
| 23 | + .getResource("test-dataset.csv").getFile(), |
| 24 | + "UTF-8", "\n"); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void test_readFile_withoutDelim_success() throws ReaderException { |
| 29 | + ukubukaReader.readFile( |
| 30 | + SupportedSource.FILE, this.getClass().getClassLoader() |
| 31 | + .getResource("test-dataset.csv").getFile(), |
| 32 | + "UTF-8", null); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + public void test_readFileAsString_file_withEncoding_success() |
| 37 | + throws ReaderException { |
| 38 | + ukubukaReader |
| 39 | + .readFileAsString(SupportedSource.FILE, |
| 40 | + this.getClass().getClassLoader() |
| 41 | + .getResource("test-dataset.csv").getFile(), |
| 42 | + "UTF-8"); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void test_readFileAsString_file_withoutEncoding_success() |
| 47 | + throws ReaderException { |
| 48 | + System.out.println(this.getClass().getClassLoader() |
| 49 | + .getResource("test-dataset.csv")); |
| 50 | + ukubukaReader |
| 51 | + .readFileAsString(SupportedSource.FILE, |
| 52 | + this.getClass().getClassLoader() |
| 53 | + .getResource("test-dataset.csv").getFile(), |
| 54 | + null); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void test_readFileAsString_url_withEncoding_success() |
| 59 | + throws ReaderException { |
| 60 | + ukubukaReader.readFileAsString(SupportedSource.URL, |
| 61 | + this.getClass().getClassLoader().getResource("test-dataset.csv") |
| 62 | + .toString().replace("file:/", "file:///"), |
| 63 | + "UTF-8"); |
| 64 | + } |
| 65 | + |
| 66 | + @Test |
| 67 | + public void test_readFileAsString_url_withoutEncoding_success() |
| 68 | + throws ReaderException { |
| 69 | + ukubukaReader.readFileAsString(SupportedSource.URL, |
| 70 | + this.getClass().getClassLoader().getResource("test-dataset.csv") |
| 71 | + .toString().replace("file:/", "file:///"), |
| 72 | + null); |
| 73 | + } |
| 74 | + |
| 75 | + @Test(expected = ReaderException.class) |
| 76 | + public void test_readFileAsString_url_withoutEncoding_failure() |
| 77 | + throws ReaderException { |
| 78 | + ukubukaReader.readFileAsString(SupportedSource.URL, |
| 79 | + this.getClass().getClassLoader().getResource("test-dataset.csv") |
| 80 | + .toString().replace("file:/", "file://"), |
| 81 | + null); |
21 | 82 | } |
22 | 83 | } |
0 commit comments