Skip to content

Commit

Permalink
modified file-path lines and readFileData method concerning the reloc…
Browse files Browse the repository at this point in the history
…ation of test data files
  • Loading branch information
akio-sone committed Jul 22, 2013
1 parent c8e58df commit 1e3996f
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions DVN-root/unf/src/test/java/edu/harvard/iq/dvn/unf/UNF5UtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
Expand Down Expand Up @@ -53,7 +54,7 @@ public void tearDown() {
@Test
public void testCalculateUNF_doubleArr() throws Exception {
System.out.println("calculateDoubleUNF");
List testData = readFileData("test/DoubleTest");
List testData = readFileData("/DoubleTest");
double[] numb = new double[testData.size()-1];
String expResult = (String) testData.get(0);
for (int i=1; i < testData.size(); i++){
Expand All @@ -69,7 +70,7 @@ public void testCalculateUNF_doubleArr() throws Exception {
@Test
public void testCalculateUNF_floatArr() throws Exception {
System.out.println("calculateFloatUNF");
List testData = readFileData("test/FloatTest");
List testData = readFileData("/FloatTest");
float[] numb = new float[testData.size() - 1];
String expResult = (String) testData.get(0);
for (int i = 1; i < testData.size(); i++) {
Expand All @@ -85,7 +86,7 @@ public void testCalculateUNF_floatArr() throws Exception {
@Test
public void testCalculateUNF_shortArr() throws Exception {
System.out.println("calculateShortUNF");
List testData = readFileData("test/ShortTest");
List testData = readFileData("/ShortTest");
short[] numb = new short[testData.size() - 1];
String expResult = (String) testData.get(0);
for (int i = 1; i < testData.size(); i++) {
Expand All @@ -101,7 +102,7 @@ public void testCalculateUNF_shortArr() throws Exception {
@Test
public void testCalculateUNF_byteArr() throws Exception {
System.out.println("calculateByteUNF");
List testData = readFileData("test/ByteTest");
List testData = readFileData("/ByteTest");
byte[] numb = new byte[testData.size() - 1];
String expResult = (String) testData.get(0);
for (int i = 1; i < testData.size(); i++) {
Expand All @@ -117,7 +118,7 @@ public void testCalculateUNF_byteArr() throws Exception {
@Test
public void testCalculateUNF_longArr() throws Exception {
System.out.println("calculateLongUNF");
List testData = readFileData("test/LongTest");
List testData = readFileData("/LongTest");
long[] numb = new long[testData.size() - 1];
String expResult = (String) testData.get(0);
for (int i = 1; i < testData.size(); i++) {
Expand All @@ -133,7 +134,7 @@ public void testCalculateUNF_longArr() throws Exception {
@Test
public void testCalculateUNF_intArr() throws Exception {
System.out.println("calculateIntUNF");
List testData = readFileData("test/IntTest");
List testData = readFileData("/IntTest");
int[] numb = new int[testData.size() - 1];
String expResult = (String) testData.get(0);
for (int i = 1; i < testData.size(); i++) {
Expand All @@ -149,7 +150,7 @@ public void testCalculateUNF_intArr() throws Exception {
@Test
public void testCalculateUNF_booleanArr() throws Exception {
System.out.println("calculateBooleanUNF");
List testData = readFileData("test/BooleanTest");
List testData = readFileData("/BooleanTest");
boolean[] numb = new boolean[testData.size() - 1];
String expResult = (String) testData.get(0);
for (int i = 1; i < testData.size(); i++) {
Expand All @@ -165,7 +166,7 @@ public void testCalculateUNF_booleanArr() throws Exception {
@Test
public void testCalculateUNF_StringArr() throws Exception {
System.out.println("calculateStringUNF");
List testData = readFileData("test/StringTest");
List testData = readFileData("/StringTest");
String[] chr = new String[testData.size() - 1];
String expResult = (String) testData.get(0);
for (int i = 1; i < testData.size(); i++) {
Expand All @@ -182,7 +183,7 @@ public void testCalculateUNF_StringArr() throws Exception {
@Test
public void testCalculateUNF_StringArr_StringArr() throws Exception {
System.out.println("calculateDateTimeUNF");
List testData = readFileData("test/DateTimeTest");
List testData = readFileData("/DateTimeTest");
String[] chr = new String[testData.size() - 1];
String[] sdfFormat = new String[testData.size() - 1];
String expResult = (String) testData.get(0);
Expand All @@ -201,7 +202,7 @@ public void testCalculateUNF_StringArr_StringArr() throws Exception {
@Test
public void testCalculateUNF_BitStringArr() throws Exception {
System.out.println("calculateUNF");
List testData = readFileData("test/BitStringTest");
List testData = readFileData("/BitStringTest");
BitString[] numb = new BitString[testData.size() - 1];
String expResult = (String) testData.get(0);
for (int i = 1; i < testData.size(); i++) {
Expand All @@ -213,10 +214,12 @@ public void testCalculateUNF_BitStringArr() throws Exception {

private List readFileData(String filename) {
List retList = new ArrayList();
File file = new File(filename);
URL url = this.getClass().getResource(filename);

File file = new File(url.getFile());
InputStream in = null;
try {
in = new FileInputStream(filename);
in = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = reader.readLine()) != null) {
Expand Down

0 comments on commit 1e3996f

Please sign in to comment.