Skip to content

Commit

Permalink
Use SystemProperties in tests instead of a magic string lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed May 1, 2024
1 parent 450e80f commit c11d6d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -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>
Expand Down
Expand Up @@ -27,6 +27,7 @@
import java.security.GeneralSecurityException;
import java.util.Properties;

import org.apache.commons.lang3.SystemProperties;
import org.junit.jupiter.api.Test;

public class CryptoRandomFactoryTest {
Expand Down Expand Up @@ -116,7 +117,7 @@ public void testFullClassName() throws GeneralSecurityException, IOException {
@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)) {
Expand Down
Expand Up @@ -27,14 +27,15 @@
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 {

@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);
Expand Down

0 comments on commit c11d6d9

Please sign in to comment.