Skip to Content.
Sympa Menu

perfsonar-dev - [GEANT/SA2/ps-java-services] r5672 - in trunk/perfsonar-java-base2/src: 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] r5672 - in trunk/perfsonar-java-base2/src: 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] r5672 - in trunk/perfsonar-java-base2/src: 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 14:17:51 +0100

Author: psnc.pietrzak
Date: 2010-05-24 14:17:51 +0100 (Mon, 24 May 2010)
New Revision: 5672

Added:

trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/validation/JREVersion.java

trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/AllTests.java

trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/validation/JREVersionTest.java
Removed:

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/ValidatorTest.java
Modified:

trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/axis2/Axis2RequestHandler.java
Log:
Added javadoc.
Renamed classes.
Added test suite gathering all test cases.

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 12:37:55 UTC (rev 5671)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/axis2/Axis2RequestHandler.java
2010-05-24 13:17:51 UTC (rev 5672)
@@ -19,7 +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.service.validation.JREVersion;
import org.perfsonar.base2.xml.AXIOMCreator;
import org.perfsonar.base2.xml.ConfigurationStaxParser;
import org.perfsonar.base2.xml.Element;
@@ -54,7 +54,7 @@


public Axis2RequestHandler() {
- if (!new Validator().isJRECompatibleWith(1, 6))
+ if (!new JREVersion().isJRECompatibleWith(1, 6))
System.exit(1);
}


Copied:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/validation/JREVersion.java
(from rev 5671,
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/JREVersion.java
(rev 0)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/validation/JREVersion.java
2010-05-24 13:17:51 UTC (rev 5672)
@@ -0,0 +1,44 @@
+package org.perfsonar.base2.service.validation;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Represents JRE version details.
+ * @author <a
href="mailto:">Blazej
Pietrzak</a>
+ */
+public class JREVersion {
+ private String jreVersion;
+
+ public JREVersion() {
+ setJREVersion(System.getProperty("java.runtime.version"));
+ }
+
+ /**
+ * Compares the provided version with the JRE version.
+ *
+ * @return <code>true</code> if the version provided is greater equal
to JRE 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;
+ }
+ public String getJREVersion() {
+ return jreVersion;
+ }
+}

Deleted:
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
2010-05-24 12:37:55 UTC (rev 5671)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/validation/Validator.java
2010-05-24 13:17:51 UTC (rev 5672)
@@ -1,35 +0,0 @@
-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/AllTests.java
===================================================================
---
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/AllTests.java
(rev 0)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/AllTests.java
2010-05-24 13:17:51 UTC (rev 5672)
@@ -0,0 +1,23 @@
+package org.perfsonar.base2.service;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.perfsonar.base2.service.configuration.migration.AllMigrationTests;
+import org.perfsonar.base2.service.validation.JREVersionTest;
+
+/**
+ * @author <a
href="">Blazej
Pietrzak</a>
+ */
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("All test cases");
+ //$JUnit-BEGIN$
+ suite.addTest(AllMigrationTests.suite());
+ suite.addTestSuite(JREVersionTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}

Copied:
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/validation/JREVersionTest.java
(from rev 5671,
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/JREVersionTest.java
(rev 0)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/validation/JREVersionTest.java
2010-05-24 13:17:51 UTC (rev 5672)
@@ -0,0 +1,41 @@
+package org.perfsonar.base2.service.validation;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a
href="">Blazej
Pietrzak</a>
+ */
+public class JREVersionTest extends TestCase {
+
+ private JREVersion jreVersion;
+ protected void setUp() throws Exception {
+ super.setUp();
+ jreVersion = new JREVersion();
+ jreVersion.setJREVersion("1.6.0");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ jreVersion = null;
+ }
+
+ public void testIsJRECompatibleWithEqualMajorLowerMinor() {
+ assertFalse(jreVersion.isJRECompatibleWith(1, 5));
+ }
+
+ public void testIsJRECompatibleWithEqualMajorEqualMinor() {
+ assertTrue(jreVersion.isJRECompatibleWith(1, 6));
+ }
+
+ public void testIsJRECompatibleWithEqualMajorGreaterMinor() {
+ assertTrue(jreVersion.isJRECompatibleWith(1, 7));
+ }
+
+ public void testIsJRECompatibleWithGreaterMajorLowerMinor() {
+ assertTrue(jreVersion.isJRECompatibleWith(2, 0));
+ }
+
+ public void testIsJRECompatibleWithGreaterMajorGreaterMinor() {
+ assertTrue(jreVersion.isJRECompatibleWith(2, 7));
+ }
+}

Deleted:
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
2010-05-24 12:37:55 UTC (rev 5671)
+++
trunk/perfsonar-java-base2/src/test/java/org/perfsonar/base2/service/validation/ValidatorTest.java
2010-05-24 13:17:51 UTC (rev 5672)
@@ -1,39 +0,0 @@
-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] r5672 - in trunk/perfsonar-java-base2/src: 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.

Top of Page