Fix for ASTERIXDB-1200
Fixes an issue where in the Hyracks integration tests,
if the result size is 0, a NPE is thrown instead of
an assert passing or failing.
Change-Id: Ib519882b9cbca941addcd66232c176a2eaeecc4b
Reviewed-on: https://asterix-gerrit.ics.uci.edu/524
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/AbstractIntegrationTest.java b/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/AbstractIntegrationTest.java
index 44dc231..7a339b7 100644
--- a/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/AbstractIntegrationTest.java
+++ b/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/AbstractIntegrationTest.java
@@ -145,7 +145,6 @@
hcc.waitForCompletion(jobId);
}
-
protected List<String> readResults(JobSpecification spec, JobId jobId, ResultSetId resultSetId) throws Exception {
int nReaders = 1;
@@ -190,6 +189,10 @@
results = readResults(spec, jobId, spec.getResultSetIds().get(i));
BufferedReader expectedFile = new BufferedReader(new FileReader(expectedFileNames[i]));
+ //We're expecting some sort of result.
+ Assert.assertTrue(results != null);
+ Assert.assertTrue(results.size() > 0);
+
String expectedLine, actualLine;
int j = 0;
while ((expectedLine = expectedFile.readLine()) != null) {
@@ -197,6 +200,7 @@
Assert.assertEquals(expectedLine, actualLine);
j++;
}
+ //We also expect the same amount of results.
Assert.assertEquals(j, results.size());
expectedFile.close();
}
@@ -212,7 +216,7 @@
List<String> results;
for (int i = 0; i < spec.getResultSetIds().size(); i++) {
results = readResults(spec, jobId, spec.getResultSetIds().get(i));
- for(String str : results) {
+ for (String str : results) {
output.write(str);
}
}
@@ -229,4 +233,4 @@
outputFiles.add(tempFile);
return tempFile;
}
-}
\ No newline at end of file
+}