You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2017/11/17 12:50:07 UTC

qpid-broker-j git commit: NO-JIRA: [Broker-J Tests] Prevent tests leaving temporary files behind

Repository: qpid-broker-j
Updated Branches:
  refs/heads/master 35ed69903 -> a3c00bbfc


NO-JIRA: [Broker-J Tests] Prevent tests leaving temporary files behind


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/a3c00bbf
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/a3c00bbf
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/a3c00bbf

Branch: refs/heads/master
Commit: a3c00bbfc78f4157dafee2ab243a2775f88db9d3
Parents: 35ed699
Author: Keith Wall <kw...@apache.org>
Authored: Fri Nov 17 12:48:03 2017 +0000
Committer: Keith Wall <kw...@apache.org>
Committed: Fri Nov 17 12:49:44 2017 +0000

----------------------------------------------------------------------
 .../apache/qpid/server/util/FileUtilsTest.java  | 56 +++++++++++++-------
 .../rest/AuthenticationProviderRestTest.java    |  6 ++-
 2 files changed, 40 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a3c00bbf/broker-core/src/test/java/org/apache/qpid/server/util/FileUtilsTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/util/FileUtilsTest.java b/broker-core/src/test/java/org/apache/qpid/server/util/FileUtilsTest.java
index 10ec648..d7cd507 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/util/FileUtilsTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/util/FileUtilsTest.java
@@ -188,7 +188,7 @@ public class FileUtilsTest extends QpidTestCase
     /**
      * Helper method to create a temporary file with test content.
      *
-     * @param test_data The data to store in the file
+     * @param testData The data to store in the file
      *
      * @return The File reference
      */
@@ -634,15 +634,23 @@ public class FileUtilsTest extends QpidTestCase
      */
     public void testSearchSucceed() throws IOException
     {
-        File _logfile = File.createTempFile("FileUtilsTest-testSearchSucceed", ".out");
+        final File logfile = File.createTempFile("FileUtilsTest-testSearchSucceed", ".out");
+        logfile.deleteOnExit();
 
-        prepareFileForSearchTest(_logfile);
+        try
+        {
+            prepareFileForSearchTest(logfile);
 
-        List<String> results = FileUtils.searchFile(_logfile, SEARCH_STRING);
+            List<String> results = FileUtils.searchFile(logfile, SEARCH_STRING);
 
-        assertNotNull("Null result set returned", results);
+            assertNotNull("Null result set returned", results);
 
-        assertEquals("Results do not contain expected count", 1, results.size());
+            assertEquals("Results do not contain expected count", 1, results.size());
+        }
+        finally
+        {
+            logfile.delete();
+        }
     }
 
     /**
@@ -653,27 +661,35 @@ public class FileUtilsTest extends QpidTestCase
      */
     public void testSearchFail() throws IOException
     {
-        File _logfile = File.createTempFile("FileUtilsTest-testSearchFail", ".out");
+        final File logfile = File.createTempFile("FileUtilsTest-testSearchFail", ".out");
+        logfile.deleteOnExit();
 
-        prepareFileForSearchTest(_logfile);
+        try
+        {
+            prepareFileForSearchTest(logfile);
 
-        List<String> results = FileUtils.searchFile(_logfile, "Hello");
+            List<String> results = FileUtils.searchFile(logfile, "Hello");
 
-        assertNotNull("Null result set returned", results);
+            assertNotNull("Null result set returned", results);
 
-        //Validate we only got one message
-        if (results.size() > 0)
-        {
-            System.err.println("Unexpected messages");
-
-            for (String msg : results)
+            //Validate we only got one message
+            if (results.size() > 0)
             {
-                System.err.println(msg);
+                System.err.println("Unexpected messages");
+
+                for (String msg : results)
+                {
+                    System.err.println(msg);
+                }
             }
-        }
 
-        assertEquals("Results contains data when it was not expected",
-                     0, results.size());
+            assertEquals("Results contains data when it was not expected",
+                         0, results.size());
+        }
+        finally
+        {
+            logfile.delete();
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a3c00bbf/systests/src/test/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java b/systests/src/test/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java
index 52df20d..214c701 100644
--- a/systests/src/test/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java
+++ b/systests/src/test/java/org/apache/qpid/systest/rest/AuthenticationProviderRestTest.java
@@ -222,12 +222,13 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase
     {
         stopDefaultBroker();
 
-        File file = new File(TMP_FOLDER, getTestName());
+        final File file = new File(TMP_FOLDER, getTestName());
+        file.deleteOnExit();
         if (file.exists())
         {
             file.delete();
         }
-        assertFalse("Group file should not exist", file.exists());
+        assertFalse(String.format("File '%s' should not exist", file), file.exists());
 
         TestBrokerConfiguration config = getDefaultBrokerConfiguration();
 
@@ -276,6 +277,7 @@ public class AuthenticationProviderRestTest extends QpidRestTestCase
             {
                 principalDatabase.delete();
             }
+            file.delete();
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org