|
16 | 16 | import static org.junit.Assert.*; |
17 | 17 |
|
18 | 18 | import java.io.BufferedReader; |
19 | | -import java.io.File; |
20 | | -import java.io.FileNotFoundException; |
21 | | -import java.io.FileReader; |
| 19 | +import java.io.InputStream; |
| 20 | +import java.io.InputStreamReader; |
22 | 21 | import java.io.IOException; |
23 | 22 | import java.util.ArrayList; |
24 | 23 |
|
@@ -192,15 +191,15 @@ public void testDetermineProtocolHardwareVersionNotInTheList() { |
192 | 191 | * <p>Verify that the {@code determineProtocol()} method is able to obtain the protocol of any firmware file |
193 | 192 | * contained in the XCTU application.</p> |
194 | 193 | * |
195 | | - * @throws FileNotFoundException |
| 194 | + * @throws IOException |
196 | 195 | */ |
197 | 196 | @Test |
198 | | - public void testDetermineProtocol() throws FileNotFoundException { |
| 197 | + public void testDetermineProtocol() throws IOException { |
199 | 198 | ArrayList<FirmwareEntry> firmwareEntries = new ArrayList<FirmwareEntry>(); |
200 | 199 |
|
201 | 200 | // Generate the list of firmware entries from the firmware_entries_xctu.txt file. |
202 | | - File firmwareEntriesFile = new File(getClass().getResource(FILE_FIRMWARE_ENTRIES).getFile()); |
203 | | - BufferedReader reader = new BufferedReader(new FileReader(firmwareEntriesFile.getAbsolutePath())); |
| 201 | + InputStream inputStream = getClass().getResourceAsStream(FILE_FIRMWARE_ENTRIES); |
| 202 | + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); |
204 | 203 | try { |
205 | 204 | String line = reader.readLine(); |
206 | 205 | while (line != null) { |
@@ -232,6 +231,10 @@ public void testDetermineProtocol() throws FileNotFoundException { |
232 | 231 | try { |
233 | 232 | reader.close(); |
234 | 233 | } catch (IOException e1) { } |
| 234 | + } finally { |
| 235 | + try { |
| 236 | + inputStream.close(); |
| 237 | + } catch (IOException e) { } |
235 | 238 | } |
236 | 239 |
|
237 | 240 | // Verify that the determineProtocol method is able to determine the protocol of all the firmware entries of the list. |
|
0 commit comments