You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/05/01 17:53:01 UTC

(commons-crypto) branch master updated: Use SystemProperties in tests instead of a magic string lookup

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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git


The following commit(s) were added to refs/heads/master by this push:
     new c11d6d9b Use SystemProperties in tests instead of a magic string lookup
c11d6d9b is described below

commit c11d6d9bf25061034c121e3d67823b5dfdc9ce0f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed May 1 13:52:57 2024 -0400

    Use SystemProperties in tests instead of a magic string lookup
---
 pom.xml                                                             | 6 ++++++
 .../org/apache/commons/crypto/random/CryptoRandomFactoryTest.java   | 3 ++-
 .../java/org/apache/commons/crypto/random/OsCryptoRandomTest.java   | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 561c19ca..02994833 100644
--- a/pom.xml
+++ b/pom.xml
@@ -662,6 +662,12 @@ The following provides more details on the included cryptographic software:
       <version>2.2</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>3.14.0</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <developers>
diff --git a/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java b/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java
index d6157d3d..bef46890 100644
--- a/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java
@@ -27,6 +27,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.security.GeneralSecurityException;
 import java.util.Properties;
 
+import org.apache.commons.lang3.SystemProperties;
 import org.junit.jupiter.api.Test;
 
 public class CryptoRandomFactoryTest {
@@ -116,7 +117,7 @@ public class CryptoRandomFactoryTest {
     @Test
     public void testGetOSRandom() throws GeneralSecurityException, IOException {
         // Windows does not have a /dev/random device
-        assumeTrue(!System.getProperty("os.name").contains("Windows"));
+        assumeTrue(!SystemProperties.getOsName().contains("Windows"));
         final Properties properties = new Properties();
         properties.setProperty(CryptoRandomFactory.CLASSES_KEY, CryptoRandomFactory.RandomProvider.OS.getClassName());
         try (final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(properties)) {
diff --git a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java
index a6a4fe1b..0d85e7f0 100644
--- a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java
+++ b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java
@@ -27,6 +27,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.security.GeneralSecurityException;
 import java.util.Properties;
 
+import org.apache.commons.lang3.SystemProperties;
 import org.junit.jupiter.api.Test;
 
 public class OsCryptoRandomTest extends AbstractRandomTest {
@@ -34,7 +35,7 @@ public class OsCryptoRandomTest extends AbstractRandomTest {
     @Override
     public CryptoRandom getCryptoRandom() throws GeneralSecurityException {
         // Windows does not have a /dev/random device
-        assumeTrue(!System.getProperty("os.name").contains("Windows"));
+        assumeTrue(!SystemProperties.getOsName().contains("Windows"));
         final Properties props = new Properties();
         props.setProperty(CryptoRandomFactory.CLASSES_KEY, OsCryptoRandom.class.getName());
         final CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props);