Author: markt
Date: Fri Nov 30 20:59:37 2018
New Revision: 1847854

URL: http://svn.apache.org/viewvc?rev=1847854&view=rev
Log:
Clean-up file created during test

Modified:
    
tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncryptInterceptor.java

Modified: 
tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncryptInterceptor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncryptInterceptor.java?rev=1847854&r1=1847853&r2=1847854&view=diff
==============================================================================
--- 
tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncryptInterceptor.java
 (original)
+++ 
tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncryptInterceptor.java
 Fri Nov 30 20:59:37 2018
@@ -25,6 +25,7 @@ import java.util.Collection;
 import org.hamcrest.core.IsEqual;
 import org.hamcrest.core.IsNot;
 
+import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.FixMethodOrder;
@@ -51,6 +52,8 @@ import org.apache.catalina.tribes.io.XBy
  */
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class TestEncryptInterceptor {
+    private static final String MESSAGE_FILE = "message.bin";
+
     private static final String encryptionKey128 = 
"cafebabedeadbeefbeefcafecafebabe";
     private static final String encryptionKey192 = 
"cafebabedeadbeefbeefcafecafebabedeadbeefbeefcafe";
     private static final String encryptionKey256 = 
"cafebabedeadbeefcafebabedeadbeefcafebabedeadbeefcafebabedeadbeef";
@@ -58,6 +61,15 @@ public class TestEncryptInterceptor {
     EncryptInterceptor src;
     EncryptInterceptor dest;
 
+
+    @AfterClass
+    public static void cleanup() {
+        File f = new File(MESSAGE_FILE);
+        if (f.isFile()) {
+            Assert.assertTrue(f.delete());
+        }
+    }
+
     @Before
     public void setup() {
         src = new EncryptInterceptor();
@@ -294,7 +306,7 @@ public class TestEncryptInterceptor {
 
         byte[] bytes = ((ValueCaptureInterceptor)src.getNext()).getValue();
 
-        try (FileOutputStream out = new FileOutputStream("message.bin")) {
+        try (FileOutputStream out = new FileOutputStream(MESSAGE_FILE)) {
             out.write(bytes);
         }
 
@@ -303,7 +315,7 @@ public class TestEncryptInterceptor {
         bytes = new byte[8192];
         int read;
 
-        try (FileInputStream in = new FileInputStream("message.bin")) {
+        try (FileInputStream in = new FileInputStream(MESSAGE_FILE)) {
             read = in.read(bytes);
         }
 
@@ -339,7 +351,7 @@ public class TestEncryptInterceptor {
 
     @Test
     public void testPickup() throws Exception {
-        File file = new File("message.bin");
+        File file = new File(MESSAGE_FILE);
         if(!file.exists()) {
             System.err.println("File message.bin does not exist. Skipping 
test.");
             return;
@@ -350,7 +362,7 @@ public class TestEncryptInterceptor {
         byte[] bytes = new byte[8192];
         int read;
 
-        try (FileInputStream in = new FileInputStream("message.bin")) {
+        try (FileInputStream in = new FileInputStream(file)) {
             read = in.read(bytes);
         }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to