Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E26D99A5B for ; Fri, 17 Feb 2012 09:00:46 +0000 (UTC) Received: (qmail 83716 invoked by uid 500); 17 Feb 2012 09:00:46 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 83553 invoked by uid 500); 17 Feb 2012 09:00:43 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 83479 invoked by uid 99); 17 Feb 2012 09:00:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2012 09:00:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2012 09:00:37 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DDF712388ABC; Fri, 17 Feb 2012 09:00:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Fri, 17 Feb 2012 09:00:15 -0000 To: derby-commits@db.apache.org From: kristwaa@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120217090015.DDF712388ABC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. *

- * A class for storing a major and minor version number. This class - * assumes that more capable versions compare greater than less capable versions. - *

+ * 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()); } /** - *

- * Returns true if this Version is at least as advanced - * as that Version. - *

+ * 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() {