[java-opensaml] branch master updated: JSPT-76 - centralise detection of Java runtime version
Ian Young
ian at iay.org.uk
Fri Nov 10 09:19:56 EST 2017
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=4e61df8730f26fbcf0254139e5c4143fd097e290
The following commit(s) were added to refs/heads/master by this push:
new 4e61df8 JSPT-76 - centralise detection of Java runtime version
4e61df8 is described below
commit 4e61df8730f26fbcf0254139e5c4143fd097e290
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Fri Nov 10 14:15:17 2017 +0000
JSPT-76 - centralise detection of Java runtime version
---
.../security/SecurityProviderTestSupport.java | 19 ----------------
.../xmlsec/algorithm/AlgorithmRegistryTest.java | 6 ++++--
.../xmlsec/encryption/support/AESGCMTest.java | 25 ++++++++++++----------
.../AlgorithmRuntimeSupportedPredicateTest.java | 6 ++++--
4 files changed, 22 insertions(+), 34 deletions(-)
diff --git a/opensaml-security-api/src/test/java/org/opensaml/security/SecurityProviderTestSupport.java b/opensaml-security-api/src/test/java/org/opensaml/security/SecurityProviderTestSupport.java
index 808fb0a..8f8a63e 100644
--- a/opensaml-security-api/src/test/java/org/opensaml/security/SecurityProviderTestSupport.java
+++ b/opensaml-security-api/src/test/java/org/opensaml/security/SecurityProviderTestSupport.java
@@ -85,25 +85,6 @@ public class SecurityProviderTestSupport {
}
/**
- * Return whether the current Java major version (e.g. 6, 7, 8) is greater than or equal to the specified version.
- *
- * @param requiredVersion
- * @return true if greater or equal, false otherwise
- */
- public boolean haveJavaGreaterOrEqual(int requiredVersion) {
- return getJavaVersion() >= requiredVersion;
- }
-
- /**
- * Return the current Java major version, e.g. 6, 7 or 8.
- * @return the Java major version
- */
- public int getJavaVersion() {
- String versionStr = System.getProperty("java.version");
- return Integer.parseInt(versionStr.split("\\.")[1]);
- }
-
- /**
* Determine if we're running on OpenJDK.
* @return true or false
*/
diff --git a/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java b/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java
index 8b4934a..55906ca 100644
--- a/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java
+++ b/opensaml-xmlsec-api/src/test/java/org/opensaml/xmlsec/algorithm/AlgorithmRegistryTest.java
@@ -31,6 +31,8 @@ import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import net.shibboleth.utilities.java.support.testing.TestSupport;
+
/**
* Tests for the AlgorithmRegistry.
*/
@@ -231,7 +233,7 @@ public class AlgorithmRegistryTest extends OpenSAMLInitBaseTestCase {
Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA384));
Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA512));
- if (providerSupport.haveBC() || providerSupport.haveJavaGreaterOrEqual(8)) {
+ if (providerSupport.haveBC() || TestSupport.isJavaV8OrLater()) {
Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA224));
}
} else {
@@ -242,7 +244,7 @@ public class AlgorithmRegistryTest extends OpenSAMLInitBaseTestCase {
Assert.assertFalse(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA512));
}
- if (providerSupport.haveBC() || providerSupport.haveJavaGreaterOrEqual(8)) {
+ if (providerSupport.haveBC() || TestSupport.isJavaV8OrLater()) {
Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_DIGEST_SHA224));
Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
Assert.assertTrue(registry.isRuntimeSupported(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
diff --git a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/AESGCMTest.java b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/AESGCMTest.java
index 14b3e75..ee08c28 100644
--- a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/AESGCMTest.java
+++ b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/encryption/support/AESGCMTest.java
@@ -36,6 +36,8 @@ import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import net.shibboleth.utilities.java.support.testing.TestSupport;
+
/**
*
*/
@@ -63,23 +65,24 @@ public class AESGCMTest extends XMLObjectBaseTestCase {
AlgorithmDescriptor aesGCM256 = registry.get(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM);
return new Object[][] {
- new Object[] {aesGCM128, 7, true},
- new Object[] {aesGCM192, 7, true},
- new Object[] {aesGCM256, 7, true},
+ new Object[] {aesGCM128, 7, TestSupport.isJavaV7OrLater(), true},
+ new Object[] {aesGCM192, 8, TestSupport.isJavaV8OrLater(), true},
+ new Object[] {aesGCM256, 8, TestSupport.isJavaV8OrLater(), true},
- new Object[] {aesGCM128, 8, false},
- new Object[] {aesGCM192, 8, false},
- new Object[] {aesGCM256, 8, false},
+ new Object[] {aesGCM128, 8, TestSupport.isJavaV8OrLater(), false},
+ new Object[] {aesGCM192, 8, TestSupport.isJavaV8OrLater(), false},
+ new Object[] {aesGCM256, 8, TestSupport.isJavaV8OrLater(), false},
- new Object[] {aesGCM128, 8, true},
- new Object[] {aesGCM192, 8, true},
- new Object[] {aesGCM256, 8, true},
+ new Object[] {aesGCM128, 8, TestSupport.isJavaV8OrLater(), true},
+ new Object[] {aesGCM192, 8, TestSupport.isJavaV8OrLater(), true},
+ new Object[] {aesGCM256, 8, TestSupport.isJavaV8OrLater(), true},
};
}
@Test(dataProvider="testDataAESGCM")
- public void testEncryptDecrypt(AlgorithmDescriptor descriptor, int minJavaVersion, boolean loadBC) throws Exception {
- if (!providerSupport.haveJavaGreaterOrEqual(minJavaVersion)) {
+ public void testEncryptDecrypt(AlgorithmDescriptor descriptor, int minJavaVersion,
+ boolean haveJavaVersion, boolean loadBC) throws Exception {
+ if (!haveJavaVersion) {
log.debug("Not Java {}+, skipping test", minJavaVersion);
return;
}
diff --git a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/AlgorithmRuntimeSupportedPredicateTest.java b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/AlgorithmRuntimeSupportedPredicateTest.java
index 3ad8819..5c7a8a3 100644
--- a/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/AlgorithmRuntimeSupportedPredicateTest.java
+++ b/opensaml-xmlsec-impl/src/test/java/org/opensaml/xmlsec/impl/AlgorithmRuntimeSupportedPredicateTest.java
@@ -31,6 +31,8 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import net.shibboleth.utilities.java.support.testing.TestSupport;
+
public class AlgorithmRuntimeSupportedPredicateTest extends OpenSAMLInitBaseTestCase {
private AlgorithmRuntimeSupportedPredicate predicate;
@@ -111,7 +113,7 @@ public class AlgorithmRuntimeSupportedPredicateTest extends OpenSAMLInitBaseTest
Assert.assertTrue(predicate.apply(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA384));
Assert.assertTrue(predicate.apply(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA512));
- if (providerSupport.haveBC() || providerSupport.haveJavaGreaterOrEqual(8)) {
+ if (providerSupport.haveBC() || TestSupport.isJavaV8OrLater()) {
Assert.assertTrue(predicate.apply(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA224));
}
} else {
@@ -122,7 +124,7 @@ public class AlgorithmRuntimeSupportedPredicateTest extends OpenSAMLInitBaseTest
Assert.assertFalse(predicate.apply(SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA512));
}
- if (providerSupport.haveBC() || providerSupport.haveJavaGreaterOrEqual(8)) {
+ if (providerSupport.haveBC() || TestSupport.isJavaV8OrLater()) {
Assert.assertTrue(predicate.apply(SignatureConstants.ALGO_ID_DIGEST_SHA224));
Assert.assertTrue(predicate.apply(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA224));
Assert.assertTrue(predicate.apply(SignatureConstants.ALGO_ID_MAC_HMAC_SHA224));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list