diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 139bd5a..a42a67e 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -9,8 +9,10 @@ # - Java 17 (LTS; officially supported since Gradle 7.3) # - Java 18 (deprecated; officially supported since Gradle 7.5) # - Java 19 (deprecated; officially supported since Gradle 7.6) -# - Java 20 (current; will be deprecated in September 2023; officially supported since Gradle 8.1) -# - Java 21 (LTS; to be released in September 2023; not officially supported by Gradle) +# - Java 20 (deprecated; officially supported since Gradle 8.1) +# - Java 21 (current; LTS; officially supported since Gradle 8.4) +# - Java 22 (to be released in March 2024; not officially supported by Gradle) +# - Java 23 (to be released in September 2024; not officially supported by Gradle) name: CS321 Bioinformatics CI with Gradle on: @@ -26,17 +28,17 @@ jobs: strategy: matrix: - java: [ '8', '11', '15', '16', '17', '18', '19', '20' ] + java: [ '8', '11', '15', '16', '17', '18', '19', '20', '21' ] name: Java version ${{ matrix.Java }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK ${{ matrix.Java }} - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} # the distribution can be either 'adopt' or 'zulu' - distribution: 'adopt' + distribution: 'zulu' - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/README.md b/README.md index 3c201a9..9414869 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,13 @@ Use the following command to check our installed JDK version: $ javac -version ``` -This project **does not work** with JDK 21. +This project **does not work** with JDK 22. -It is recommended to use either JDK 8, JDK 11 or JDK 17 or JDK 19 or 20. +It is recommended to use any of the following versions: +- JDK 8 (LTS) +- JDK 11 (LTS) +- JDK 17 (LTS) +- JDK 21 (LTS) :book: See this [wiki page for additional details regarding the supported Java versions and links to download the correct JDK versions](https://github.com/BoiseState/CS321_Bioinformatics/wiki/Install-the-correct-JDK-version). diff --git a/build.gradle b/build.gradle index 7e41e59..90fd931 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,9 @@ plugins { group 'cs321' version '1.0' -sourceCompatibility = 1.8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 +} repositories { mavenCentral() diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cb..c1962a7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d..744c64d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68..aeb74cb 100755 --- a/gradlew +++ b/gradlew @@ -85,9 +85,6 @@ done APP_BASE_NAME=${0##*/} APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -144,7 +141,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/src/test/java/cs321/btree/BTreeTest.java b/src/test/java/cs321/btree/BTreeTest.java index ce4bf09..57b650e 100644 --- a/src/test/java/cs321/btree/BTreeTest.java +++ b/src/test/java/cs321/btree/BTreeTest.java @@ -205,7 +205,8 @@ public void testInsertTenDuplicates() throws BTreeException, IOException { assertEquals(1, b.getSize()); assertEquals(0, b.getHeight()); - assertTrue(validateSearchTreeProperty(b)); + + assertTrue(validateBTreeInserts(b, new long[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1})); } @@ -220,13 +221,17 @@ public void testInsertTenThousandObjects() throws BTreeException, IOException { BTree b = new BTree(2, testFilename); + long[] input = new long[10000]; + for (int i = 0; i < 10000; i++) { + input[i] = i; b.insert(new TreeObject(i)); } assertEquals(10000, b.getSize()); assertEquals(12, b.getHeight()); - assertTrue(validateSearchTreeProperty(b)); + + assertTrue(validateBTreeInserts(b, input)); } /** @@ -242,24 +247,24 @@ public void testCLRSExample18_6() throws BTreeException, IOException { BTree b = new BTree(4, testFilename); - b.insert(new TreeObject(1)); //A - b.insert(new TreeObject(4)); //D - b.insert(new TreeObject(6)); //F - b.insert(new TreeObject(8)); //H - b.insert(new TreeObject(12)); //L - b.insert(new TreeObject(14)); //N - b.insert(new TreeObject(16)); //P + // A D F H L N P B + long[] input = new long[]{1, 4, 6, 8, 12, 14, 16, 2}; + + for (int i = 0; i < input.length - 1; i++) { + b.insert(new TreeObject(input[i])); + } assertEquals(7, b.getSize()); assertEquals(0, b.getHeight()); assertEquals(1, b.getNumberOfNodes()); - b.insert(new TreeObject(2)); //Insert 'B' + b.insert(new TreeObject(input[7])); //Insert 'B' assertEquals(8, b.getSize()); assertEquals(1, b.getHeight()); assertEquals(3, b.getNumberOfNodes()); - assertTrue(validateSearchTreeProperty(b)); + + assertTrue(validateBTreeInserts(b, input)); } /** @@ -401,22 +406,21 @@ public void testInsertToNotLeaf() throws BTreeException, IOException { BTree b = new BTree(4, testFilename); - b.insert(new TreeObject(1)); //A - b.insert(new TreeObject(4)); //D - b.insert(new TreeObject(6)); //F - b.insert(new TreeObject(8)); //H - b.insert(new TreeObject(12)); //L - b.insert(new TreeObject(14)); //N - b.insert(new TreeObject(16)); //P - b.insert(new TreeObject(2)); //B + // A D F H L N P B H + long[] input = new long[]{1, 4, 6, 8, 12, 14, 16, 2, 8}; + + for (int i = 0; i < input.length - 1; i++) { + b.insert(new TreeObject(input[i])); + } //by inserting a duplicate into a non leaf node, another branch is tested. - b.insert(new TreeObject(8)); //H + b.insert(new TreeObject(input[8])); //H TreeObject obj = b.search(8); assertEquals(2, obj.getCount()); - assertTrue(validateSearchTreeProperty(b)); + + assertTrue(validateBTreeInserts(b, input)); } @@ -426,8 +430,8 @@ public void testInsertToNotLeaf() throws BTreeException, IOException { * a full child. * Assertion is that key 'H' (8) has been counted twice in a search * - * @throws BTreeException - * @throws IOException + * @throws BTreeException Exception thrown when BTree encounters an unexpected problem + * @throws IOException Exception thrown when testing fails due to IO errors */ @Test public void testInsertToNotLeafFullChild() throws BTreeException, IOException { @@ -437,14 +441,14 @@ public void testInsertToNotLeafFullChild() throws BTreeException, IOException { // A D F H L H long[] input = new long[]{1, 4, 6, 8, 12, 8}; - for (int i = 0; i < input.length; i++) { - b.insert(new TreeObject(input[i])); + for (long l : input) { + b.insert(new TreeObject(l)); } TreeObject obj = b.search(8); assertEquals(2, obj.getCount()); - assertTrue(validateSearchTreeProperty(b)); + assertTrue(validateBTreeInserts(b, input)); } @@ -457,7 +461,7 @@ public void testInsertToNotLeafFullChild() throws BTreeException, IOException { * @return true if there are no keys in the BTree, or if the keys are indeed in sorted order. * */ - private boolean validateSearchTreeProperty(BTree b) { + private boolean validateSearchTreeProperty(BTree b) throws IOException { long[] keys = b.getSortedKeyArray(); @@ -492,7 +496,7 @@ private boolean validateSearchTreeProperty(BTree b) { * * @return true if BTree in order traversal matches provide input */ - private boolean validateBTreeInserts(BTree b, long[] inputKeys) { + private boolean validateBTreeInserts(BTree b, long[] inputKeys) throws IOException { long[] bTreeKeys = b.getSortedKeyArray(); @@ -522,7 +526,7 @@ private boolean validateBTreeInserts(BTree b, long[] inputKeys) { long prev = bTreeKeys[0]; - for (int i = 0; i < inputKeys.length; i++) { + for (int i = 0; i < bTreeKeys.length; i++) { if (bTreeKeys[i] != inputNoDuplicates.get(i)) { return false; }