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 2011/10/31 14:27:16 UTC

svn commit: r1195449 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: junit/DerbyVersion.java junit/DerbyVersionSimple.java unitTests/junit/DerbyVersionTest.java unitTests/junit/_Suite.java

Author: kristwaa
Date: Mon Oct 31 13:27:16 2011
New Revision: 1195449

URL: http://svn.apache.org/viewvc?rev=1195449&view=rev
Log:
DERBY-5475 (partial): Formalize use of old Derby distributions in tests

Added support classes DerbyVersion and DerbyVersionSimple (may be removed later
if possible). DerbyVersion represents a Derby version number and has methods
for comparing versions against each other, plus a few other helper methods.
Added a basic unit test for DerbyVersion.

Patch file: derby-5475-1b-DerbyVersion.diff

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersion.java   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersionSimple.java   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/DerbyVersionTest.java   (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java

Added: 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=1195449&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersion.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersion.java Mon Oct 31 13:27:16 2011
@@ -0,0 +1,301 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.junit.DerbyVersion
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.junit;
+
+/**
+ * Representation of a Derby version on the form major.minor.fixpack.point,
+ * for instance "10.8.1.2".
+ * <p>
+ * This class doesn't consider the alpha/beta flag nor the revision number.
+ */
+public class DerbyVersion
+        implements Comparable {
+
+    // A list of all known "branches" (major and minor levels).
+    public static final DerbyVersion _10_0     = new DerbyVersion(10,0,0,0);
+    public static final DerbyVersion _10_1     = new DerbyVersion(10,1,0,0);
+    public static final DerbyVersion _10_2     = new DerbyVersion(10,2,0,0);
+    public static final DerbyVersion _10_3     = new DerbyVersion(10,3,0,0);
+    public static final DerbyVersion _10_4     = new DerbyVersion(10,4,0,0);
+    public static final DerbyVersion _10_5     = new DerbyVersion(10,5,0,0);
+    public static final DerbyVersion _10_6     = new DerbyVersion(10,6,0,0);
+    public static final DerbyVersion _10_7     = new DerbyVersion(10,7,0,0);
+    public static final DerbyVersion _10_8     = new DerbyVersion(10,8,0,0);
+
+    // A list of all known official Derby releases.
+
+    /** 10.0.2.1 (incubator release) */
+    public static final DerbyVersion _10_0_2_1 = new DerbyVersion(10,0,2,1);
+    /** 10.1.1.0 (Aug 3, 2005 / SVN 208786) */
+    public static final DerbyVersion _10_1_1_0 = new DerbyVersion(10,1,1,0);
+    /** 10.1.2.1 (Nov 18, 2005 / SVN 330608) */
+    public static final DerbyVersion _10_1_2_1 = new DerbyVersion(10,1,2,1);
+    /** 10.1.3.1 (Jun 30, 2006 / SVN 417277) */
+    public static final DerbyVersion _10_1_3_1 = new DerbyVersion(10,1,3,1);
+    /** 10.2.1.6 (Oct 02, 2006 / SVN 452058) */
+    public static final DerbyVersion _10_2_1_6 = new DerbyVersion(10,2,1,6);
+    /** 10.2.2.0 (Dec 12, 2006 / SVN 485682) */
+    public static final DerbyVersion _10_2_2_0 = new DerbyVersion(10,2,2,0);
+    /** 10.3.1.4 (Aug 1, 2007 / SVN 561794) */
+    public static final DerbyVersion _10_3_1_4 = new DerbyVersion(10,3,1,4);
+    /** 10.3.3.0 (May 12, 2008 / SVN 652961) */
+    public static final DerbyVersion _10_3_3_0 = new DerbyVersion(10,3,3,0);
+    /** 10.4.1.3 (April 24, 2008 / SVN 648739) */
+    public static final DerbyVersion _10_4_1_3 = new DerbyVersion(10,4,1,3);
+    /** 10.4.2.0 (September 05, 2008 / SVN 693552) */
+    public static final DerbyVersion _10_4_2_0 = new DerbyVersion(10,4,2,0);
+    /** 10.5.1.1 (April 28, 2009 / SVN 764942) */
+    public static final DerbyVersion _10_5_1_1 = new DerbyVersion(10,5,1,1);
+    /** 10.5.3.0 (August 21, 2009 / SVN 802917) */
+    public static final DerbyVersion _10_5_3_0 = new DerbyVersion(10,5,3,0);
+    /** 10.6.1.0 (May 18, 2010/ SVN 938214) */
+    public static final DerbyVersion _10_6_1_0 = new DerbyVersion(10,6,1,0);
+    /** 10.6.2.1 (Oct 6, 2010/ SVN 999685) */
+    public static final DerbyVersion _10_6_2_1 = new DerbyVersion(10,6,2,1);
+    /** 10.7.1.1 (December 14, 2010/ SVN 1040133) */
+    public static final DerbyVersion _10_7_1_1 = new DerbyVersion(10,7,1,1);
+    /** 10.8.1.2 (April 29, 2011/ SVN 1095077) */
+    public static final DerbyVersion _10_8_1_2 = new DerbyVersion(10,8,1,2);
+    /** 10.8.2.2 (October 24, 2011/ SVN 1181258) */
+    public static final DerbyVersion _10_8_2_2 = new DerbyVersion(10,8,2,2);
+
+    private final int major;
+    private final int minor;
+    private final int fixpack;
+    private final int point;
+    private final DerbyVersionSimple simpleVersion;
+
+    /**
+     * Parses the given string as a Derby version.
+     *
+     * @param versionString the string to parse, for instance "10.7.1.1" or
+     *      "10.9.0.0 alpha - (1180861M)"
+     * @return A Derby version object.
+     * @throws IllegalArgumentException if the specified version string cannot
+     *      be parsed
+     */
+    public static DerbyVersion parseVersionString(String versionString)
+            throws IllegalArgumentException {
+        String[] components = Utilities.split(versionString.trim(), ' ');
+        components = Utilities.split(components[0], '.');
+        if (components.length != 4) {
+            throw new IllegalArgumentException(
+                    "invalid number of version components, got " +
+                    components.length + " expected 4: " + versionString);
+        }
+        return new DerbyVersion(
+                Integer.parseInt(components[0]),
+                Integer.parseInt(components[1]),
+                Integer.parseInt(components[2]),
+                Integer.parseInt(components[3]));
+    }
+
+    public DerbyVersion(int major, int minor, int fixpack, int point) {
+        this.major = major;
+        this.minor = minor;
+        this.fixpack = fixpack;
+        this.point = point;
+        this.simpleVersion = new DerbyVersionSimple(major, minor);
+    }
+
+    public int getMajor() {
+        return major;
+    }
+
+    public int getMinor() {
+        return minor;
+    }
+
+    public int getFixpack() {
+        return fixpack;
+    }
+
+    public int getPoint() {
+        return point;
+    }
+
+    public boolean lessThan(DerbyVersion other) {
+        return compareTo(other) < 0;
+    }
+
+    public boolean greaterThan(DerbyVersion other) {
+        return compareTo(other) > 0;
+    }
+
+    /**
+     * Checks if this version is at a greater minor level than the other
+     * version.
+     *
+     * @param other version to compare with
+     * @return {@code true} if the minor level is greater, {@code false} if the
+     *      minor level is the same or smaller.
+     * @throws IllegalArgumentException if the major level of the two versions
+     *      are unequal
+     */
+    public boolean greaterMinorThan(DerbyVersion other) {
+        if (!sameMajorAs(other)) {
+            throw new IllegalArgumentException(
+                    "major versions must be equal");
+        }
+        return minor > other.minor;
+    }
+
+    /**
+     * Checks if this version is at the same or higher level as the other
+     * version.
+     *
+     * @param other version to compare with
+     * @return {@code true} if this version is equal/higher than {@code other},
+     *      {@code false} otherwise.
+     */
+    public boolean atLeastAs(DerbyVersion other) {
+        return compareTo(other) >= 0;
+    }
+
+    /**
+     * Checks if this version is at the same or lower level as the other
+     * version.
+     *
+     * @param other version to compare with
+     * @return {@code true} if this version is equal/lower than {@code other},
+     *      {@code false} otherwise.
+     */
+    public boolean atMostAs(DerbyVersion other) {
+        return compareTo(other) <= 0;
+    }
+
+    /**
+     * Checks if this version is at the same major and minor level as the other
+     * version.
+     *
+     * @param major major level to compare with
+     * @param minor minor level to compare with
+     * @return {@code true} if major and minor level of the two versions are
+     *      the same, {@code false} otherwise.
+     */
+    public boolean atMajorMinor(int major, int minor) {
+        return this.major == major && this.minor == minor;
+    }
+
+    /**
+     * Checks if this version is at the same major and minor level as the other
+     * version.
+     *
+     * @param other version to compare with
+     * @return {@code true} if major and minor level of the two versions are
+     *      the same, {@code false} otherwise.
+     */
+    public boolean atMajorMinorOf(DerbyVersion other) {
+        return major == other.major && minor == other.minor;
+    }
+
+    //@Override
+    public String toString() {
+        return major + "." + minor + "." + fixpack + "." + point;
+    }
+
+    //@Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final DerbyVersion other = (DerbyVersion) obj;
+        if (this.major != other.major) {
+            return false;
+        }
+        if (this.minor != other.minor) {
+            return false;
+        }
+        if (this.fixpack != other.fixpack) {
+            return false;
+        }
+        if (this.point != other.point) {
+            return false;
+        }
+        return true;
+    }
+
+    //@Override
+    public int hashCode() {
+        int hash = 3;
+        hash = 23 * hash + this.major;
+        hash = 23 * hash + this.minor;
+        hash = 23 * hash + this.fixpack;
+        hash = 23 * hash + this.point;
+        return hash;
+    }
+
+    public int compareTo(Object o) {
+        return compareTo((DerbyVersion)o);
+    }
+
+    public int compareTo(DerbyVersion o) {
+        if (major < o.major) {
+            return -1;
+        } else if (major > o.major) {
+            return 1;
+        }
+        if (minor < o.minor) {
+            return -1;
+        } else if (minor > o.minor) {
+            return 1;
+        }
+        if (fixpack < o.fixpack) {
+            return -1;
+        } else if (fixpack > o.fixpack) {
+            return 1;
+        }
+        if (point < o.point) {
+            return -1;
+        } else if (point > o.point) {
+            return 1;
+        }
+        return 0;
+    }
+
+    /**
+     * Returns a simplified view of this version, where only the major and the
+     * minor versions are included.
+     * <p>
+     * Introduced for compatibility with existing/older test code.
+     *
+     * @return A simplified version view.
+     */
+    public DerbyVersionSimple asSimpleVersion() {
+        return this.simpleVersion;
+    }
+
+    /**
+     * Checks if the major level of this version is the same as for the other
+     * version.
+     *
+     * @param other version to compare with
+     * @return {@code true} if the major levels match, {@code false} otherwise.
+     */
+    private boolean sameMajorAs(DerbyVersion other) {
+        return major == other.major;
+    }
+}
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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/DerbyVersionSimple.java?rev=1195449&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersionSimple.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersionSimple.java Mon Oct 31 13:27:16 2011
@@ -0,0 +1,114 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.junit.DerbyVersionSimple
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.derbyTesting.junit;
+
+import java.util.StringTokenizer;
+
+/**
+ * <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>
+ */
+public final class DerbyVersionSimple
+        implements Comparable {
+    private	int	_major;
+    private	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;
+    }
+
+    /**
+     * <p>
+     * Returns true if this Version is at least as advanced
+     * as that Version.
+     * </p>
+     */
+    public	boolean	atLeast( DerbyVersionSimple that )
+    {
+        return this.compareTo( that ) > -1;
+    }
+
+
+    ////////////////////////////////////////////////////////
+    //
+    //	Comparable BEHAVIOR
+    //
+    ////////////////////////////////////////////////////////
+
+    public int compareTo(Object o) {
+        return compareTo((DerbyVersionSimple)o);
+    }
+
+    public int compareTo(DerbyVersionSimple that) {
+
+        if ( this._major < that._major ) { return -1; }
+        if ( this._major > that._major ) { return 1; }
+
+        return this._minor - that._minor;
+    }
+
+    ////////////////////////////////////////////////////////
+    //
+    //	Object OVERLOADS
+    //
+    ////////////////////////////////////////////////////////
+
+    public	String	toString()
+    {
+        return Integer.toString( _major ) + '.' + Integer.toString( _minor );
+    }
+
+    public	boolean	equals(Object other)
+    {
+        if (other instanceof DerbyVersionSimple) {
+            return compareTo((DerbyVersionSimple)other) == 0;
+        } else {
+            return false;
+        }
+    }
+
+    public	int	hashCode()
+    {
+        return _major ^ _minor;
+    }
+}
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DerbyVersionSimple.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=1195449&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/DerbyVersionTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/DerbyVersionTest.java Mon Oct 31 13:27:16 2011
@@ -0,0 +1,210 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.junit.InputStreamUtilTest
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+*/
+
+package org.apache.derbyTesting.unitTests.junit;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.DerbyVersion;
+
+/**
+ * Tests the functionality of {@code DerbyVersion}.
+ */
+public class DerbyVersionTest
+        extends BaseTestCase {
+
+    private static final DerbyVersion _10_2     = new DerbyVersion(10,2,0,0);
+    private static final DerbyVersion _10_2_2_0 = new DerbyVersion(10,2,2,2);
+    private static final DerbyVersion _10_3     = new DerbyVersion(10,3,0,0);
+    private static final DerbyVersion _10_4     = new DerbyVersion(10,4,0,0);
+    private static final DerbyVersion _10_5     = new DerbyVersion(10,5,0,0);
+    private static final DerbyVersion _10_5_1_1 = new DerbyVersion(10,5,1,1);
+    private static final DerbyVersion _10_5_2_0 = new DerbyVersion(10,5,2,0);
+    private static final DerbyVersion _10_5_3_0 = new DerbyVersion(10,5,3,0);
+    private static final DerbyVersion _10_6     = new DerbyVersion(10,6,0,0);
+    private static final DerbyVersion _10_7     = new DerbyVersion(10,7,0,0);
+    private static final DerbyVersion _10_8     = new DerbyVersion(10,8,0,0);
+    private static final DerbyVersion _10_8_1_2 = new DerbyVersion(10,8,1,2);
+    private static final DerbyVersion _10_9     = new DerbyVersion(10,9,0,0);
+
+    private static final DerbyVersion _11_0 = new DerbyVersion(11,0,0,0);
+    private static final DerbyVersion _11_9 = new DerbyVersion(11,9,9,9);
+
+
+    public DerbyVersionTest(String name) {
+        super(name);
+    }
+    public static Test suite() {
+        return new TestSuite(DerbyVersionTest.class, "DerbyVersionTest tests");
+    }
+
+    public void testLessThan() {
+        assertTrue(_10_2.lessThan(_10_2_2_0));
+        assertTrue(_10_2.lessThan(_10_3));
+        assertTrue(_10_5.lessThan(_10_5_1_1));
+        assertTrue(_10_5_1_1.lessThan(_10_5_2_0));
+        assertTrue(_10_5_2_0.lessThan(_10_5_3_0));
+        assertTrue(_10_8_1_2.lessThan(_11_0));
+        assertTrue(_10_8_1_2.lessThan(_11_9));
+
+        assertFalse(_10_5.lessThan(_10_4));
+        assertFalse(_10_5.lessThan(_10_5));
+        assertFalse(_11_0.lessThan(_10_8));
+        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 testGreaterThan() {
+        assertTrue(_10_5_3_0.greaterThan(_10_5_2_0));
+        assertTrue(_10_5_3_0.greaterThan(_10_5_1_1));
+        assertTrue(_10_5_3_0.greaterThan(_10_2));
+
+        assertFalse(_10_2.greaterThan(_10_3));
+        assertFalse(_10_8.greaterThan(_11_0));
+    }
+
+
+    public void testAtMostAs() {
+        assertTrue(_10_4.atMostAs(_10_5));
+        assertTrue(_10_8.atMostAs(_11_9));
+
+        assertFalse(_10_7.atMostAs(_10_2));
+        assertFalse(_11_0.atMostAs(_10_5_3_0));
+    }
+
+    public void testAtMajorMinor() {
+        assertTrue(_10_4.atMajorMinor(10, 4));
+
+        assertFalse(_10_2.atMajorMinor(10, 1));
+        assertFalse(_10_2.atMajorMinor(10, 3));
+        assertFalse(_10_2.atMajorMinor(11, 2));
+    }
+
+    public void testAtMajorMinorOf() {
+        assertTrue(_10_5.atMajorMinorOf(_10_5_1_1));
+        assertTrue(_10_5.atMajorMinorOf(_10_5_2_0));
+        assertTrue(_10_5.atMajorMinorOf(_10_5_3_0));
+        assertTrue(_10_5_3_0.atMajorMinorOf(_10_5_3_0));
+        assertTrue(_10_5_3_0.atMajorMinorOf(_10_5_1_1));
+
+        assertFalse(_10_5_2_0.atMajorMinorOf(_10_3));
+        assertFalse(_10_5_2_0.atMajorMinorOf(_11_9));
+        assertFalse(_10_5_2_0.atMajorMinorOf(_10_2));
+        assertFalse(_10_5_2_0.atMajorMinorOf(_10_2_2_0));
+    }
+
+    public void testGetMajor() {
+        assertEquals(10, _10_5_1_1.getMajor());
+        assertEquals(10, _10_8.getMajor());
+        assertEquals(11, _11_9.getMajor());
+    }
+
+    public void testGetMinor() {
+        assertEquals(5, _10_5_1_1.getMinor());
+        assertEquals(8, _10_8.getMinor());
+        assertEquals(9, _11_9.getMinor());
+    }
+
+    public void testGetFixpack() {
+        assertEquals(1, _10_5_1_1.getFixpack());
+        assertEquals(0, _10_8.getFixpack());
+        assertEquals(9, _11_9.getFixpack());
+    }
+
+    public void testGetPoint() {
+        assertEquals(1, _10_5_1_1.getPoint());
+        assertEquals(0, _10_8.getPoint());
+        assertEquals(9, _11_9.getPoint());
+    }
+
+    public void testCreateGet() {
+        DerbyVersion v = new DerbyVersion(1, 2, 3, 4);
+        assertEquals(1, v.getMajor());
+        assertEquals(2, v.getMinor());
+        assertEquals(3, v.getFixpack());
+        assertEquals(4, v.getPoint());
+    }
+
+    public void testCompareTo() {
+        assertTrue(_10_5_1_1.compareTo(_10_2) > 0);
+        assertTrue(_10_5_1_1.compareTo(_10_8) < 0);
+        assertTrue(_11_0.compareTo(_11_9) < 0);
+
+        assertEquals(0, _11_0.compareTo(_11_0));
+        assertEquals(0, _10_2.compareTo(_10_2));
+    }
+
+    public void testEquals() {
+        assertTrue(_10_6.equals(_10_6));
+
+        assertFalse(_10_2.equals(this));
+        assertFalse(_10_2.equals(null));
+        assertFalse(_11_0.equals(_10_8));
+        assertFalse(_10_5_2_0.equals(_10_5_3_0));
+    }
+
+    public void testParseString() {
+        DerbyVersion dv = DerbyVersion.parseVersionString(
+                "10.9.0.0 alpha - (1180861M)");
+        assertTrue(dv.equals(_10_9));
+        assertEquals(0, dv.compareTo(_10_9));
+
+        dv = DerbyVersion.parseVersionString("10.8.1.2");
+        assertTrue(dv.equals(_10_8_1_2));
+        assertEquals(0, dv.compareTo(_10_8_1_2));
+        
+        dv = DerbyVersion.parseVersionString("   10.8.1.2   ");
+        assertTrue(dv.equals(_10_8_1_2));
+        assertEquals(0, dv.compareTo(_10_8_1_2));
+
+        try {
+            dv = DerbyVersion.parseVersionString("10.8.1");
+            fail("should have failed");
+        } catch (IllegalArgumentException iae) {
+            // As expected.
+        }
+
+        try {
+            dv = DerbyVersion.parseVersionString("10.8.1.");
+            fail("should have failed");
+        } catch (IllegalArgumentException iae) {
+            // As expected.
+        }
+
+        try {
+            dv = DerbyVersion.parseVersionString("10.8.1.two");
+            fail("should have failed");
+        } catch (IllegalArgumentException iae) {
+            // As expected.
+        }
+    }
+}
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/DerbyVersionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java?rev=1195449&r1=1195448&r2=1195449&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java Mon Oct 31 13:27:16 2011
@@ -59,6 +59,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(VirtualFileTest.suite());
         suite.addTest(ReaderToUTF8StreamTest.suite());
         suite.addTest(DataInputUtilTest.suite());
+        suite.addTest(DerbyVersionTest.suite());
 
         return suite;
     }