Added printing of output files for tests when logging is enabled
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_dev_next@805 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/integration/AbstractIntegrationTest.java b/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/integration/AbstractIntegrationTest.java
index 9acb46a..abedf4a 100644
--- a/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/integration/AbstractIntegrationTest.java
+++ b/hyracks-examples/hyracks-integration-tests/src/test/java/edu/uci/ics/hyracks/tests/integration/AbstractIntegrationTest.java
@@ -16,10 +16,13 @@
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -46,9 +49,15 @@
private static NodeControllerService nc2;
private static IHyracksClientConnection hcc;
+ private final List<File> outputFiles;
+
@Rule
public TemporaryFolder outputFolder = new TemporaryFolder();
+ public AbstractIntegrationTest() {
+ outputFiles = new ArrayList<File>();
+ }
+
@BeforeClass
public static void init() throws Exception {
CCConfig ccConfig = new CCConfig();
@@ -103,9 +112,32 @@
LOGGER.info(jobId.toString());
}
cc.waitForCompletion(jobId);
+ dumpOutputFiles();
+ }
+
+ private void dumpOutputFiles() {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ for (File f : outputFiles) {
+ if (f.exists() && f.isFile()) {
+ try {
+ LOGGER.info("Reading file: " + f.getAbsolutePath() + " in test: " + getClass().getName());
+ String data = FileUtils.readFileToString(f);
+ LOGGER.info(data);
+ } catch (IOException e) {
+ LOGGER.info("Error reading file: " + f.getAbsolutePath());
+ LOGGER.info(e.getMessage());
+ }
+ }
+ }
+ }
}
protected File createTempFile() throws IOException {
- return File.createTempFile(getClass().getName(), ".tmp", outputFolder.getRoot());
+ File tempFile = File.createTempFile(getClass().getName(), ".tmp", outputFolder.getRoot());
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Output file: " + tempFile.getAbsolutePath());
+ }
+ outputFiles.add(tempFile);
+ return tempFile;
}
}
\ No newline at end of file