You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by kr...@apache.org on 2012/02/17 10:00:15 UTC
svn commit: r1245349 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting:
junit/DerbyVersion.java junit/DerbyVersionSimple.java junit/Version.java
unitTests/junit/DerbyVersionTest.java
Author: kristwaa
Date: Fri Feb 17 09:00:15 2012
New Revision: 1245349
URL: http://svn.apache.org/viewvc?rev=1245349&view=rev
Log:
DERBY-5475: Formalize use of old Derby distributions in tests
Another preparation patch, mostly renaming a class and some methods.
Renamed DerbyVersionSimple to Version to indicate that it isn't coded
specifically to represent a Derby version - it can be used to represent any
version consisting of a major and a minor version component.
Made variables final, some formatting changes.
Renamed 'atLeastAs' to 'atLeast' to follow existing pattern.
Patch file: derby-5475-2a-rename_and_cleanup.diff
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Version.java
- copied, changed from r1245342, db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersionSimple.java
Removed:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersionSimple.java
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersion.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/DerbyVersionTest.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersion.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersion.java?rev=1245349&r1=1245348&r2=1245349&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersion.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersion.java Fri Feb 17 09:00:15 2012
@@ -82,7 +82,7 @@ public class DerbyVersion
private final int minor;
private final int fixpack;
private final int point;
- private final DerbyVersionSimple simpleVersion;
+ private final Version simpleVersion;
/**
* Parses the given string as a Derby version.
@@ -114,7 +114,7 @@ public class DerbyVersion
this.minor = minor;
this.fixpack = fixpack;
this.point = point;
- this.simpleVersion = new DerbyVersionSimple(major, minor);
+ this.simpleVersion = new Version(major, minor);
}
public int getMajor() {
@@ -164,10 +164,10 @@ public class DerbyVersion
* version.
*
* @param other version to compare with
- * @return {@code true} if this version is equal/higher than {@code other},
- * {@code false} otherwise.
+ * @return {@code true} if this version is equal to or higher than
+ * {@code other}, {@code false} otherwise.
*/
- public boolean atLeastAs(DerbyVersion other) {
+ public boolean atLeast(DerbyVersion other) {
return compareTo(other) >= 0;
}
@@ -176,10 +176,10 @@ public class DerbyVersion
* version.
*
* @param other version to compare with
- * @return {@code true} if this version is equal/lower than {@code other},
- * {@code false} otherwise.
+ * @return {@code true} if this version is equal to or lower than
+ * {@code other}, {@code false} otherwise.
*/
- public boolean atMostAs(DerbyVersion other) {
+ public boolean atMost(DerbyVersion other) {
return compareTo(other) <= 0;
}
@@ -283,7 +283,7 @@ public class DerbyVersion
*
* @return A simplified version view.
*/
- public DerbyVersionSimple asSimpleVersion() {
+ public Version asSimpleVersion() {
return this.simpleVersion;
}
Copied: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Version.java (from r1245342, db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersionSimple.java)
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Version.java?p2=db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Version.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersionSimple.java&r1=1245342&r2=1245349&rev=1245349&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersionSimple.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Version.java Fri Feb 17 09:00:15 2012
@@ -1,6 +1,6 @@
/*
- Derby - Class org.apache.derbyTesting.junit.DerbyVersionSimple
+ Derby - Class org.apache.derbyTesting.junit.Version
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -23,63 +23,50 @@ package org.apache.derbyTesting.junit;
import java.util.StringTokenizer;
/**
+ * A generic class for storing a major and minor version number.
* <p>
- * A class for storing a major and minor version number. This class
- * assumes that more capable versions compare greater than less capable versions.
- * </p>
+ * This class assumes that more capable versions compare greater than less
+ * capable versions.
+ *
+ * @see DerbyVersion
*/
-public final class DerbyVersionSimple
+public final class Version
implements Comparable {
- private int _major;
- private int _minor;
+ private final int _major;
+ private final int _minor;
- DerbyVersionSimple( int major, int minor )
- {
- constructorMinion( major, minor );
- }
-
- public DerbyVersionSimple( String desc )
- throws NumberFormatException
- {
- StringTokenizer tokens = new StringTokenizer( desc, "." );
-
- constructorMinion
- (
- java.lang.Integer.parseInt( tokens.nextToken() ),
- java.lang.Integer.parseInt( tokens.nextToken() )
- );
- }
-
- private void constructorMinion( int major, int minor )
- {
- _major = major;
- _minor = minor;
+ Version(int major, int minor) {
+ this._major = major;
+ this._minor = minor;
+ }
+
+ public Version(String desc)
+ throws NumberFormatException {
+ StringTokenizer tokens = new StringTokenizer( desc, "." );
+ this._major = Integer.parseInt(tokens.nextToken());
+ this._minor = Integer.parseInt(tokens.nextToken());
}
/**
- * <p>
- * Returns true if this Version is at least as advanced
- * as that Version.
- * </p>
+ * Returns {@code true} if this version is at least as advanced
+ * as the other version.
*/
- public boolean atLeast( DerbyVersionSimple that )
- {
+ public boolean atLeast(Version that) {
return this.compareTo( that ) > -1;
}
////////////////////////////////////////////////////////
//
- // Comparable BEHAVIOR
+ // Comparable BEHAVIOR
//
////////////////////////////////////////////////////////
public int compareTo(Object o) {
- return compareTo((DerbyVersionSimple)o);
+ return compareTo((Version)o);
}
- public int compareTo(DerbyVersionSimple that) {
-
+ public int compareTo(Version that) {
if ( this._major < that._major ) { return -1; }
if ( this._major > that._major ) { return 1; }
@@ -88,27 +75,23 @@ public final class DerbyVersionSimple
////////////////////////////////////////////////////////
//
- // Object OVERLOADS
+ // Object OVERLOADS
//
////////////////////////////////////////////////////////
- public String toString()
- {
+ public String toString() {
return Integer.toString( _major ) + '.' + Integer.toString( _minor );
}
- public boolean equals(Object other)
- {
- if (other instanceof DerbyVersionSimple) {
- return compareTo((DerbyVersionSimple)other) == 0;
+ public boolean equals(Object other) {
+ if (other instanceof Version) {
+ return compareTo((Version)other) == 0;
} else {
return false;
}
}
- public int hashCode()
- {
+ public int hashCode() {
return _major ^ _minor;
}
}
-
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/DerbyVersionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/DerbyVersionTest.java?rev=1245349&r1=1245348&r2=1245349&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/DerbyVersionTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/DerbyVersionTest.java Fri Feb 17 09:00:15 2012
@@ -72,14 +72,14 @@ public class DerbyVersionTest
assertFalse(_11_9.lessThan(_10_7));
}
- public void testAtLeastAs() {
- assertTrue(_10_4.atLeastAs(_10_4));
- assertTrue(_10_4.atLeastAs(_10_3));
- assertTrue(_10_5_2_0.atLeastAs(_10_5_1_1));
-
- assertFalse(_10_2.atLeastAs(_10_4));
- assertFalse(_10_2.atLeastAs(_11_0));
- assertFalse(_10_5_1_1.atLeastAs(_10_5_3_0));
+ public void testAtLeast() {
+ assertTrue(_10_4.atLeast(_10_4));
+ assertTrue(_10_4.atLeast(_10_3));
+ assertTrue(_10_5_2_0.atLeast(_10_5_1_1));
+
+ assertFalse(_10_2.atLeast(_10_4));
+ assertFalse(_10_2.atLeast(_11_0));
+ assertFalse(_10_5_1_1.atLeast(_10_5_3_0));
}
public void testGreaterThan() {
@@ -92,12 +92,12 @@ public class DerbyVersionTest
}
- public void testAtMostAs() {
- assertTrue(_10_4.atMostAs(_10_5));
- assertTrue(_10_8.atMostAs(_11_9));
+ public void testAtMost() {
+ assertTrue(_10_4.atMost(_10_5));
+ assertTrue(_10_8.atMost(_11_9));
- assertFalse(_10_7.atMostAs(_10_2));
- assertFalse(_11_0.atMostAs(_10_5_3_0));
+ assertFalse(_10_7.atMost(_10_2));
+ assertFalse(_11_0.atMost(_10_5_3_0));
}
public void testAtMajorMinor() {