From a638bc903339cac26e522df787ad4fcbca2344aa Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Wed, 1 Oct 2014 23:48:14 +0000 Subject: QPID-6126: Add ability to validate CO attributes on creation, transit COs into ERRORED state if exception occurs on recovery, allow ERRORED CO restart after remediation of configuration problem git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1628867 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/test/utils/TestFileUtils.java | 49 ++++++++++++---------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'qpid/java/qpid-test-utils/src/main') diff --git a/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java b/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java index 26bbe151d2..00231039c3 100644 --- a/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java +++ b/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestFileUtils.java @@ -121,33 +121,38 @@ public class TestFileUtils File file = createTempFile(testcase, suffix); if (content != null) { - FileOutputStream fos = null; - try - { - fos = new FileOutputStream(file); - fos.write(content.getBytes("UTF-8")); - fos.flush(); - } - catch (Exception e) - { - throw new RuntimeException("Cannot add the content into temp file " + file.getAbsolutePath(), e); - } - finally + saveTextContentInFile(content, file); + } + return file; + } + + public static void saveTextContentInFile(String content, File file) + { + FileOutputStream fos = null; + try + { + fos = new FileOutputStream(file); + fos.write(content.getBytes("UTF-8")); + fos.flush(); + } + catch (Exception e) + { + throw new RuntimeException("Cannot add the content into temp file " + file.getAbsolutePath(), e); + } + finally + { + if (fos != null) { - if (fos != null) + try { - try - { - fos.close(); - } - catch (IOException e) - { - throw new RuntimeException("Cannot close output stream into temp file " + file.getAbsolutePath(), e); - } + fos.close(); + } + catch (IOException e) + { + throw new RuntimeException("Cannot close output stream into temp file " + file.getAbsolutePath(), e); } } } - return file; } /** -- cgit v1.2.1