From 396eced29178ef40ed2ddd13b7b4420fb4933cbb Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Sat, 7 May 2011 17:15:02 +0100 Subject: [PATCH] Add test to check version information. --- core/core.gradle | 3 +++ .../core/SpringSecurityCoreVersion.java | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/core.gradle b/core/core.gradle index 732b8589b5..b41465facd 100644 --- a/core/core.gradle +++ b/core/core.gradle @@ -26,6 +26,9 @@ dependencies { int maxAESKeySize = javax.crypto.Cipher.getMaxAllowedKeyLength('AES') test { + systemProperties['springSecurityVersion'] = version + systemProperties['springVersion'] = springVersion + if (maxAESKeySize < 256) { logger.warn("AES keysize limited to $maxAESKeySize, skipping EncryptorsTests") exclude '**/EncryptorsTests.class' diff --git a/core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java b/core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java index f0a16f0a9c..638d227d29 100644 --- a/core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java +++ b/core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java @@ -20,6 +20,10 @@ public class SpringSecurityCoreVersion { */ public static final long SERIAL_VERSION_UID = 310L; + static final String SPRING_MAJOR_VERSION = "3"; + + static final String MIN_SPRING_VERSION = "3.0.5.RELEASE"; + static { // Check Spring Compatibility String springVersion = SpringVersion.getVersion(); @@ -27,14 +31,15 @@ public class SpringSecurityCoreVersion { if (springVersion != null) { logger.info("You are running with Spring Security Core " + version); - if (!springVersion.startsWith("3")) { - logger.error("Spring Major version '3' expected, but you are running with version: " - + springVersion + ". Please check your classpath for unwanted jar files."); + if (!springVersion.startsWith(SPRING_MAJOR_VERSION)) { + logger.error("*** Spring Major version '" + SPRING_MAJOR_VERSION + + "' expected, but you are running with version: " + springVersion + + ". Please check your classpath for unwanted jar files."); } - if (springVersion.compareTo("3.0.5") < 0) { - logger.warn("You are advised to use Spring 3.0.5 or later with this version. You are running: " + - springVersion); + if (springVersion.compareTo(MIN_SPRING_VERSION) < 0) { + logger.warn("**** You are advised to use Spring " + MIN_SPRING_VERSION + + " or later with this version. You are running: " + springVersion); } } }