forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEODE-7250 accomodate new versions greater than 1.9
- Loading branch information
1 parent
875294c
commit 3c0174c
Showing
12 changed files
with
141 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
geode-junit/src/main/java/org/apache/geode/test/version/TestVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* 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.geode.test.version; | ||
|
||
import java.util.Objects; | ||
|
||
public class TestVersion implements Comparable { | ||
private final int major; | ||
private final int minor; | ||
private final int patch; | ||
|
||
public TestVersion(String versionString) { | ||
String[] split = versionString.split("\\."); | ||
if (split.length != 3) { | ||
throw new IllegalArgumentException("Expected a version string but received " + versionString); | ||
} | ||
major = Integer.parseInt(split[0]); | ||
minor = Integer.parseInt(split[1]); | ||
if (split[2].contains("-incubating")) { | ||
split[2] = split[2].substring(0, split[2].length() - "-incubating".length()); | ||
} | ||
patch = Integer.parseInt(split[2]); | ||
} | ||
|
||
/** | ||
* Perform a comparison of the major, minor and patch versions of the two version strings. | ||
* The version strings should be in dot notation. | ||
*/ | ||
public static int compare(String version1, String version2) { | ||
return new TestVersion(version1).compareTo(new TestVersion(version2)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "" + major + "." + minor + "." + patch; | ||
} | ||
|
||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof TestVersion)) { | ||
return false; | ||
} | ||
TestVersion that = (TestVersion) o; | ||
return major == that.major && | ||
minor == that.minor && | ||
patch == that.patch; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(major, minor, patch); | ||
} | ||
|
||
public TestVersion(int major, int minor, int patch) { | ||
this.major = major; | ||
this.minor = minor; | ||
this.patch = patch; | ||
} | ||
|
||
@Override | ||
public int compareTo(Object o) { | ||
if (o == null) { | ||
throw new NullPointerException("parameter may not be null"); | ||
} | ||
TestVersion other = (TestVersion) o; | ||
int comparison = Integer.compare(major, other.major); | ||
if (comparison != 0) { | ||
return comparison; | ||
} | ||
comparison = Integer.compare(minor, other.minor); | ||
if (comparison != 0) { | ||
return comparison; | ||
} | ||
return Integer.compare(patch, other.patch); | ||
} | ||
|
||
public int compareTo(int major, int minor, int patch) { | ||
return compareTo(new TestVersion(major, minor, patch)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters