Skip to content

Commit

Permalink
Ensure that tests actually load OpenSSL
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbASF committed Nov 1, 2023
1 parent 569c625 commit ed4ea61
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/apache/commons/crypto/CryptoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -58,6 +61,9 @@ public void testMain() throws Throwable {
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"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
*/
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 {

@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"));
}
}

0 comments on commit ed4ea61

Please sign in to comment.