This is an automated email from the ASF dual-hosted git repository.
sebb 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 ed4ea615 Ensure that tests actually load OpenSSL
ed4ea615 is described below
commit ed4ea61508844f7953bc047373a8afcffbcb491b
Author: Sebb <[email protected]>
AuthorDate: Wed Nov 1 23:31:52 2023 +0000
Ensure that tests actually load OpenSSL
---
pom.xml | 6 ++++++
src/test/java/org/apache/commons/crypto/CryptoTest.java | 6 ++++++
src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java | 6 ++++++
3 files changed, 18 insertions(+)
diff --git a/pom.xml b/pom.xml
index cdb99e9a..6b86cb76 100644
--- a/pom.xml
+++ b/pom.xml
@@ -639,6 +639,12 @@ The following provides more details on the included
cryptographic software:
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<developers>
diff --git a/src/test/java/org/apache/commons/crypto/CryptoTest.java
b/src/test/java/org/apache/commons/crypto/CryptoTest.java
index 9c1a532e..1c5cff2f 100644
--- a/src/test/java/org/apache/commons/crypto/CryptoTest.java
+++ b/src/test/java/org/apache/commons/crypto/CryptoTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.commons.crypto;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -58,6 +61,9 @@ public class CryptoTest {
assertTrue(Crypto.isNativeCodeLoaded(), "Native code loaded OK");
Crypto.main(new String[] { }); // show the JNI library details
assertTrue(Crypto.isNativeCodeLoaded(), "Completed OK");
+ // Ensure that test loaded OpenSSL, not some other library
+ // This may require jni.library.path to be defined if the default
library is not OpenSSL
+ assertThat(OpenSslInfoNative.OpenSSLVersion(0),
containsString("OpenSSL"));
}
}
diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java
b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java
index 96911e58..94b26463 100644
--- a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java
+++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java
@@ -17,6 +17,9 @@
*/
package org.apache.commons.crypto.jna;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import org.junit.jupiter.api.Test;
public class OpenSslJnaTest {
@@ -24,5 +27,8 @@ public class OpenSslJnaTest {
@Test
public void testMain() throws Throwable {
OpenSslJna.main(new String[0]);
+ // Ensure that test loaded OpenSSL, not some other library
+ // This may require jna.library.path to be defined if the default
library is not OpenSSL
+ assertThat(OpenSslNativeJna.OpenSSLVersion(0),
containsString("OpenSSL"));
}
}