perfsonar-dev - [GEANT/SA2/ps-java-services] r5671 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service main/java/org/perfsonar/base2/service/requesthandler/axis2 main/java/org/perfsonar/base2/service/validation test/java/org/perfsonar/base2/service test/java/org/perfsonar/base2/service/validation
Subject: perfsonar development work
List archive
[GEANT/SA2/ps-java-services] r5671 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service main/java/org/perfsonar/base2/service/requesthandler/axis2 main/java/org/perfsonar/base2/service/validation test/java/org/perfsonar/base2/service test/java/org/perfsonar/base2/service/validation
Chronological Thread
- From:
- To:
- Subject: [GEANT/SA2/ps-java-services] r5671 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service main/java/org/perfsonar/base2/service/requesthandler/axis2 main/java/org/perfsonar/base2/service/validation test/java/org/perfsonar/base2/service test/java/org/perfsonar/base2/service/validation
- Date: Mon, 24 May 2010 13:37:55 +0100
Author: psnc.pietrzak
Date: 2010-05-24 13:37:55 +0100 (Mon, 24 May 2010)
New Revision: 5671
Added:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/validation/
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/validation/Validator.java
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/validation/
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/validation/ValidatorTest.java
Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/axis2/Axis2RequestHandler.java
Log:
Added JRE version validation. If the version < 1.6 System.exit will be
invoked.
Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/axis2/Axis2RequestHandler.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/axis2/Axis2RequestHandler.java
2010-05-24 11:41:10 UTC (rev 5670)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/axis2/Axis2RequestHandler.java
2010-05-24 12:37:55 UTC (rev 5671)
@@ -19,6 +19,7 @@
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.requesthandler.RequestHandler;
import org.perfsonar.base2.service.requesthandler.ServiceMessage;
+import org.perfsonar.base2.service.validation.Validator;
import org.perfsonar.base2.xml.AXIOMCreator;
import org.perfsonar.base2.xml.ConfigurationStaxParser;
import org.perfsonar.base2.xml.Element;
@@ -53,6 +54,8 @@
public Axis2RequestHandler() {
+ if (!new Validator().isJRECompatibleWith(1, 6))
+ System.exit(1);
}
Added:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/validation/Validator.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/validation/Validator.java
(rev 0)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/validation/Validator.java
2010-05-24 12:37:55 UTC (rev 5671)
@@ -0,0 +1,35 @@
+package org.perfsonar.base2.service.validation;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Validator {
+ private String jreVersion;
+
+ public Validator() {
+ setJREVersion(System.getProperty("java.runtime.version"));
+ }
+
+ public boolean isJRECompatibleWith(int major, int minor) {
+ final Pattern pattern =
Pattern.compile("([0-9])\\.([0-9])\\.([0-9])(?:_([0-9]{2}))?(?:-([a-zA-Z0-9]+))?");
+ final Matcher m = pattern.matcher(getJREVersion());
+
+ if (!m.find())
+ return false;
+ if (major < Integer.parseInt(m.group(1)))
+ return false;
+ if (major > Integer.parseInt(m.group(1)))
+ return true;
+ if (minor < Integer.parseInt(m.group(2)))
+ return false;
+
+ return true;
+ }
+
+ protected void setJREVersion(String version) {
+ this.jreVersion = version;
+ }
+ protected String getJREVersion() {
+ return jreVersion;
+ }
+}
Added:
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/validation/ValidatorTest.java
===================================================================
---
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/validation/ValidatorTest.java
(rev 0)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/validation/ValidatorTest.java
2010-05-24 12:37:55 UTC (rev 5671)
@@ -0,0 +1,39 @@
+package org.perfsonar.base2.service.validation;
+
+import junit.framework.TestCase;
+
+public class ValidatorTest extends TestCase {
+
+ private Validator validator;
+ protected void setUp() throws Exception {
+ super.setUp();
+ validator = new Validator();
+ validator.setJREVersion("1.6.0");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ validator = null;
+ }
+
+ public void testIsJRECompatibleWithEqualMajorLowerMinor() {
+ assertFalse(validator.isJRECompatibleWith(1, 5));
+ }
+
+ public void testIsJRECompatibleWithEqualMajorEqualMinor() {
+ assertTrue(validator.isJRECompatibleWith(1, 6));
+ }
+
+ public void testIsJRECompatibleWithEqualMajorGreaterMinor() {
+ assertTrue(validator.isJRECompatibleWith(1, 7));
+ }
+
+ public void testIsJRECompatibleWithGreaterMajorLowerMinor() {
+ assertTrue(validator.isJRECompatibleWith(2, 0));
+ }
+
+ public void testIsJRECompatibleWithGreaterMajorGreaterMinor() {
+ assertTrue(validator.isJRECompatibleWith(2, 7));
+ }
+
+}
- [GEANT/SA2/ps-java-services] r5671 - in trunk/perfsonar-java-base2/src: main/java/org/perfsonar/base2/service main/java/org/perfsonar/base2/service/requesthandler/axis2 main/java/org/perfsonar/base2/service/validation test/java/org/perfsonar/base2/service test/java/org/perfsonar/base2/service/validation, svn-noreply, 05/24/2010
Archive powered by MHonArc 2.6.16.