This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new e7abc42  Make sure the WS-Security cache files are deleted correctly 
after test runs
e7abc42 is described below

commit e7abc42184717e5f5e9263ce93ef026de5dd7a3b
Author: Colm O hEigeartaigh <[email protected]>
AuthorDate: Wed May 13 17:46:10 2020 +0100

    Make sure the WS-Security cache files are deleted correctly after test runs
---
 parent/pom.xml                                            |  6 ++++++
 rt/ws/security/pom.xml                                    |  5 +++++
 .../cxf/ws/security/wss4j/AbstractSecurityTest.java       |  9 ++++++---
 services/sts/systests/advanced/pom.xml                    |  6 ++++++
 .../apache/cxf/systest/sts/common/SecurityTestUtil.java   | 15 +++++++++------
 services/sts/systests/basic/pom.xml                       |  5 +++++
 .../apache/cxf/systest/sts/common/SecurityTestUtil.java   | 15 +++++++++------
 systests/kerberos/pom.xml                                 |  5 +++++
 .../cxf/systest/kerberos/common/SecurityTestUtil.java     | 11 +++++++----
 systests/ws-security-examples/pom.xml                     |  5 +++++
 .../systest/wssec/examples/common/SecurityTestUtil.java   | 15 +++++++++------
 systests/ws-security/pom.xml                              |  5 +++++
 .../apache/cxf/systest/ws/common/SecurityTestUtil.java    | 11 +++++++----
 13 files changed, 84 insertions(+), 29 deletions(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index 59673a5..d655935 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -96,6 +96,7 @@
         <cxf.classmate.version>1.5.1</cxf.classmate.version>
         <cxf.commons-codec.version>1.14</cxf.commons-codec.version>
         
<cxf.commons-collections.version>3.2.2</cxf.commons-collections.version>
+        <cxf.commons-io.version>2.6</cxf.commons-io.version>
         <cxf.commons-jcs-jcache.version>2.1</cxf.commons-jcs-jcache.version>
         <cxf.commons-lang3.version>3.10</cxf.commons-lang3.version>
         <cxf.commons-logging.version>1.2</cxf.commons-logging.version>
@@ -1443,6 +1444,11 @@
                 <version>${cxf.commons-codec.version}</version>
             </dependency>
             <dependency>
+                <groupId>commons-io</groupId>
+                <artifactId>commons-io</artifactId>
+                <version>${cxf.commons-io.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>commons-logging</groupId>
                 <artifactId>commons-logging</artifactId>
                 <version>1.2</version>
diff --git a/rt/ws/security/pom.xml b/rt/ws/security/pom.xml
index b1f506d..cf5ae57 100644
--- a/rt/ws/security/pom.xml
+++ b/rt/ws/security/pom.xml
@@ -133,6 +133,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-frontend-jaxws</artifactId>
             <version>${project.version}</version>
diff --git 
a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
 
b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
index 2b99cf4..9765b9c 100644
--- 
a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
+++ 
b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/AbstractSecurityTest.java
@@ -21,6 +21,7 @@ package org.apache.cxf.ws.security.wss4j;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
 import java.util.Map;
@@ -36,6 +37,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -152,17 +154,18 @@ public abstract class AbstractSecurityTest extends 
AbstractCXFTest {
     }
 
     @org.junit.AfterClass
-    public static void cleanup() {
+    public static void cleanup() throws IOException {
         String tmpDir = System.getProperty("java.io.tmpdir");
         if (tmpDir != null) {
             File[] tmpFiles = new File(tmpDir).listFiles();
             if (tmpFiles != null) {
                 for (File tmpFile : tmpFiles) {
                     if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache.instance")
-                            || 
tmpFile.getName().startsWith("wss4j-nonce-cache")
                             || 
tmpFile.getName().startsWith("ws-security.timestamp.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.saml.cache.instance")
+                            || 
tmpFile.getName().startsWith("wss4j-nonce-cache")
                             || 
tmpFile.getName().startsWith("wss4j-timestamp-cache"))) {
-                        tmpFile.delete();
+                        FileUtils.forceDeleteOnExit(tmpFile);
                     }
                 }
             }
diff --git a/services/sts/systests/advanced/pom.xml 
b/services/sts/systests/advanced/pom.xml
index 6cc36a9..298d0ad 100644
--- a/services/sts/systests/advanced/pom.xml
+++ b/services/sts/systests/advanced/pom.xml
@@ -148,6 +148,12 @@
             <artifactId>jackson-jaxrs-json-provider</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
     <build>
         <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
diff --git 
a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/common/SecurityTestUtil.java
 
b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/common/SecurityTestUtil.java
index a56081e..e42477e 100644
--- 
a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/common/SecurityTestUtil.java
+++ 
b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/common/SecurityTestUtil.java
@@ -19,9 +19,11 @@
 package org.apache.cxf.systest.sts.common;
 
 import java.io.File;
+import java.io.IOException;
 
 import javax.xml.ws.BindingProvider;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.example.contract.doubleit.DoubleItPortType;
 
@@ -34,17 +36,18 @@ public final class SecurityTestUtil {
         // complete
     }
 
-    public static void cleanup() {
+    public static void cleanup() throws IOException {
         String tmpDir = System.getProperty("java.io.tmpdir");
         if (tmpDir != null) {
             File[] tmpFiles = new File(tmpDir).listFiles();
             if (tmpFiles != null) {
                 for (File tmpFile : tmpFiles) {
-                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache")
-                        || tmpFile.getName().startsWith("wss4j-nonce-cache")
-                        || 
tmpFile.getName().startsWith("ws-security.timestamp.cache")
-                        || 
tmpFile.getName().startsWith("wss4j-timestamp-cache"))) {
-                        tmpFile.delete();
+                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.timestamp.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.saml.cache.instance")
+                            || 
tmpFile.getName().startsWith("wss4j-nonce-cache")
+                            || 
tmpFile.getName().startsWith("wss4j-timestamp-cache"))) {
+                        FileUtils.forceDeleteOnExit(tmpFile);
                     }
                 }
             }
diff --git a/services/sts/systests/basic/pom.xml 
b/services/sts/systests/basic/pom.xml
index 09f16ef..fbed0ca 100644
--- a/services/sts/systests/basic/pom.xml
+++ b/services/sts/systests/basic/pom.xml
@@ -132,6 +132,11 @@
             <artifactId>jackson-jaxrs-json-provider</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <scope>test</scope>
+        </dependency>
 
     </dependencies>
     <build>
diff --git 
a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/SecurityTestUtil.java
 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/SecurityTestUtil.java
index a56081e..e42477e 100644
--- 
a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/SecurityTestUtil.java
+++ 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/SecurityTestUtil.java
@@ -19,9 +19,11 @@
 package org.apache.cxf.systest.sts.common;
 
 import java.io.File;
+import java.io.IOException;
 
 import javax.xml.ws.BindingProvider;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.example.contract.doubleit.DoubleItPortType;
 
@@ -34,17 +36,18 @@ public final class SecurityTestUtil {
         // complete
     }
 
-    public static void cleanup() {
+    public static void cleanup() throws IOException {
         String tmpDir = System.getProperty("java.io.tmpdir");
         if (tmpDir != null) {
             File[] tmpFiles = new File(tmpDir).listFiles();
             if (tmpFiles != null) {
                 for (File tmpFile : tmpFiles) {
-                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache")
-                        || tmpFile.getName().startsWith("wss4j-nonce-cache")
-                        || 
tmpFile.getName().startsWith("ws-security.timestamp.cache")
-                        || 
tmpFile.getName().startsWith("wss4j-timestamp-cache"))) {
-                        tmpFile.delete();
+                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.timestamp.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.saml.cache.instance")
+                            || 
tmpFile.getName().startsWith("wss4j-nonce-cache")
+                            || 
tmpFile.getName().startsWith("wss4j-timestamp-cache"))) {
+                        FileUtils.forceDeleteOnExit(tmpFile);
                     }
                 }
             }
diff --git a/systests/kerberos/pom.xml b/systests/kerberos/pom.xml
index cd349a1..fa5a5de 100644
--- a/systests/kerberos/pom.xml
+++ b/systests/kerberos/pom.xml
@@ -204,6 +204,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
diff --git 
a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/common/SecurityTestUtil.java
 
b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/common/SecurityTestUtil.java
index 6bfdb24..e7bd6dc 100644
--- 
a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/common/SecurityTestUtil.java
+++ 
b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/common/SecurityTestUtil.java
@@ -19,12 +19,14 @@
 package org.apache.cxf.systest.kerberos.common;
 
 import java.io.File;
+import java.io.IOException;
 
 import javax.crypto.Cipher;
 import javax.crypto.SecretKey;
 import javax.crypto.spec.SecretKeySpec;
 import javax.xml.ws.BindingProvider;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.cxf.ws.security.trust.STSClient;
 import org.example.contract.doubleit.DoubleItPortType;
@@ -59,17 +61,18 @@ public final class SecurityTestUtil {
         // complete
     }
 
-    public static void cleanup() {
+    public static void cleanup() throws IOException {
         String tmpDir = System.getProperty("java.io.tmpdir");
         if (tmpDir != null) {
             File[] tmpFiles = new File(tmpDir).listFiles();
             if (tmpFiles != null) {
                 for (File tmpFile : tmpFiles) {
-                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache")
+                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.timestamp.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.saml.cache.instance")
                             || 
tmpFile.getName().startsWith("wss4j-nonce-cache")
-                            || 
tmpFile.getName().startsWith("ws-security.timestamp.cache")
                             || 
tmpFile.getName().startsWith("wss4j-timestamp-cache"))) {
-                        tmpFile.delete();
+                        FileUtils.forceDeleteOnExit(tmpFile);
                     }
                 }
             }
diff --git a/systests/ws-security-examples/pom.xml 
b/systests/ws-security-examples/pom.xml
index d09eff1..0fe73f3 100644
--- a/systests/ws-security-examples/pom.xml
+++ b/systests/ws-security-examples/pom.xml
@@ -177,6 +177,11 @@
             <artifactId>spring-core</artifactId>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
diff --git 
a/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/common/SecurityTestUtil.java
 
b/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/common/SecurityTestUtil.java
index 6dbf76c..414d4d1 100644
--- 
a/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/common/SecurityTestUtil.java
+++ 
b/systests/ws-security-examples/src/test/java/org/apache/cxf/systest/wssec/examples/common/SecurityTestUtil.java
@@ -19,9 +19,11 @@
 package org.apache.cxf.systest.wssec.examples.common;
 
 import java.io.File;
+import java.io.IOException;
 
 import javax.xml.ws.BindingProvider;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.example.contract.doubleit.DoubleItPortType;
 
@@ -34,17 +36,18 @@ public final class SecurityTestUtil {
         // complete
     }
 
-    public static void cleanup() {
+    public static void cleanup() throws IOException {
         String tmpDir = System.getProperty("java.io.tmpdir");
         if (tmpDir != null) {
             File[] tmpFiles = new File(tmpDir).listFiles();
             if (tmpFiles != null) {
                 for (File tmpFile : tmpFiles) {
-                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache")
-                        || tmpFile.getName().startsWith("wss4j-nonce-cache")
-                        || 
tmpFile.getName().startsWith("ws-security.timestamp.cache")
-                        || 
tmpFile.getName().startsWith("wss4j-timestamp-cache"))) {
-                        tmpFile.delete();
+                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.timestamp.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.saml.cache.instance")
+                            || 
tmpFile.getName().startsWith("wss4j-nonce-cache")
+                            || 
tmpFile.getName().startsWith("wss4j-timestamp-cache"))) {
+                        FileUtils.forceDeleteOnExit(tmpFile);
                     }
                 }
             }
diff --git a/systests/ws-security/pom.xml b/systests/ws-security/pom.xml
index ddf68a9..c7768ce 100644
--- a/systests/ws-security/pom.xml
+++ b/systests/ws-security/pom.xml
@@ -215,6 +215,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
diff --git 
a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/SecurityTestUtil.java
 
b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/SecurityTestUtil.java
index 76512cb..396e08e 100644
--- 
a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/SecurityTestUtil.java
+++ 
b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/common/SecurityTestUtil.java
@@ -19,9 +19,11 @@
 package org.apache.cxf.systest.ws.common;
 
 import java.io.File;
+import java.io.IOException;
 
 import javax.xml.ws.BindingProvider;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.cxf.ws.security.SecurityConstants;
 import org.example.contract.doubleit.DoubleItPortType;
 
@@ -34,17 +36,18 @@ public final class SecurityTestUtil {
         // complete
     }
 
-    public static void cleanup() {
+    public static void cleanup() throws IOException {
         String tmpDir = System.getProperty("java.io.tmpdir");
         if (tmpDir != null) {
             File[] tmpFiles = new File(tmpDir).listFiles();
             if (tmpFiles != null) {
                 for (File tmpFile : tmpFiles) {
-                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache")
+                    if (tmpFile.exists() && 
(tmpFile.getName().startsWith("ws-security.nonce.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.timestamp.cache.instance")
+                            || 
tmpFile.getName().startsWith("ws-security.saml.cache.instance")
                             || 
tmpFile.getName().startsWith("wss4j-nonce-cache")
-                            || 
tmpFile.getName().startsWith("ws-security.timestamp.cache")
                             || 
tmpFile.getName().startsWith("wss4j-timestamp-cache"))) {
-                        tmpFile.delete();
+                        FileUtils.forceDeleteOnExit(tmpFile);
                     }
                 }
             }

Reply via email to