You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2018/11/30 20:59:37 UTC

svn commit: r1847854 - /tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncryptInterceptor.java

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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1847854 - /tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncryptInterceptor.java

Posted by Mark Thomas <ma...@apache.org>.
On 02/12/2018 23:05, Christopher Schultz wrote:
> Mark,
> 
> On 11/30/18 15:59, markt@apache.org wrote:
>> 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
> 
> It was actually intentional to leave this file behind after the test,

Worth finding a different location for the file and telling svn and git
to ignore it...

> but after verifying that "different JVM instances" wasn't the problem
> with the implementation (the stupidly non-thread-safeness of the
> interceptor was) it's really no longer necessary.

... or may just remove those tests then.

Mark

> 
> Thanks,
> -chris
> 
>> Modified: 
>> tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEn
> cryptInterceptor.java
> 
>>  Modified:
>> tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEn
> cryptInterceptor.java
> 
> 
> URL:
> http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribe
> s/group/interceptors/TestEncryptInterceptor.java?rev=1847854&r1=1847853&
> r2=1847854&view=diff
>> ======================================================================
> ========
> 
> 
> ---
> tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncr
> yptInterceptor.java
> (original)
>> +++
>> tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEn
> cryptInterceptor.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-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


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


Re: svn commit: r1847854 - /tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncryptInterceptor.java

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 11/30/18 15:59, markt@apache.org wrote:
> 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

It was actually intentional to leave this file behind after the test,
but after verifying that "different JVM instances" wasn't the problem
with the implementation (the stupidly non-thread-safeness of the
interceptor was) it's really no longer necessary.

Thanks,
- -chris

> Modified: 
> tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEn
cryptInterceptor.java
>
>  Modified:
> tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEn
cryptInterceptor.java
>
> 
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribe
s/group/interceptors/TestEncryptInterceptor.java?rev=1847854&r1=1847853&
r2=1847854&view=diff
> ======================================================================
========
>
> 
- ---
tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEncr
yptInterceptor.java
(original)
> +++
> tomcat/trunk/test/org/apache/catalina/tribes/group/interceptors/TestEn
cryptInterceptor.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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlwEZS0ACgkQHPApP6U8
pFjNuw/+JiY+Urw3K+v1+A9CvG8Ix4Zb3j3TSTTnv7RAGX4Bx4O3drEutnyPquZt
ATCyS9NUlUCUaDj0Mvxd/S3HSv7Rd+aOtbtHAZgx1evSacDpMA4EdBwr2aq5+nfp
3Wi2TH6E3ZvbtGcB/+bXp/cy2egF01d9AgpCt1zI0XMeKxSZGEjochZb/3efbfiF
YTYctblCRCZ6RlhOmcd1ADG8zOGc2bqwyXbeFgzS5mSwWjXN3DOSzHKdkGjg24ug
FWupbm5ppjhl4XqE/M3tnHjHwmFKmpt4Kc7+b8+1AVsRQRUEdHsJqJ27Hp2Rvm0d
gZBbp7+SHw1xi89um6GGuZP4kxIkUrcpV14nqNo9UvkQ3m7Lt8WjNqV/sF/jvIQR
3ks31sVK446t4B/kgW/abZoScxRvJbzNN4MVCXviApVDEwEReizSgzWqTNbG3w3p
gpglZsYdbvtkd6tPq9mNO6MuZusBfnI2apLDh1WtjzadOJwZYC7FgB9T90P6iLP9
U2lEk692G0qiTYYK18/DqBrF7y5SiH9MJ/kwpIICmdDUYU5sbBcJvTPaPF+XlzWM
ZiG9y6Lc6ZnG7ILMTtlgU5eJ3/t4K6+rG1avhP7uf9QVOZepEdHAO1o0RPo07shv
Ro9ET2w8CEALTK6bEF6c/STWeknUNOT/7ts9TUlKubivaHGs/rQ=
=Eb8a
-----END PGP SIGNATURE-----

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