Skip to content

Commit 8540916

Browse files
committed
Simple fix for bug when running test from a path containing a space.
1 parent 33bc0d0 commit 8540916

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

library/src/test/java/com/digi/xbee/api/models/XBeeProtocolTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
import static org.junit.Assert.*;
1717

1818
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;
2221
import java.io.IOException;
2322
import java.util.ArrayList;
2423

@@ -192,15 +191,15 @@ public void testDetermineProtocolHardwareVersionNotInTheList() {
192191
* <p>Verify that the {@code determineProtocol()} method is able to obtain the protocol of any firmware file
193192
* contained in the XCTU application.</p>
194193
*
195-
* @throws FileNotFoundException
194+
* @throws IOException
196195
*/
197196
@Test
198-
public void testDetermineProtocol() throws FileNotFoundException {
197+
public void testDetermineProtocol() throws IOException {
199198
ArrayList<FirmwareEntry> firmwareEntries = new ArrayList<FirmwareEntry>();
200199

201200
// 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));
204203
try {
205204
String line = reader.readLine();
206205
while (line != null) {
@@ -232,6 +231,10 @@ public void testDetermineProtocol() throws FileNotFoundException {
232231
try {
233232
reader.close();
234233
} catch (IOException e1) { }
234+
} finally {
235+
try {
236+
inputStream.close();
237+
} catch (IOException e) { }
235238
}
236239

237240
// Verify that the determineProtocol method is able to determine the protocol of all the firmware entries of the list.

0 commit comments

Comments
 (0)