From 16d3f5ada7415f0c75b15c22205d57771dd52bc5 Mon Sep 17 00:00:00 2001 From: Tara Drwenski Date: Wed, 17 Apr 2024 16:06:02 +0200 Subject: [PATCH] Rewrite groovy test as junit --- netcdf4/build.gradle | 1 - .../nc2/jni/netcdf/UnloadedNc4IospSpec.groovy | 38 ------------------- .../nc2/jni/netcdf/TestUnloadedNc4Iosp.java | 20 ++++++++++ 3 files changed, 20 insertions(+), 39 deletions(-) delete mode 100644 netcdf4/src/unloadedTest/groovy/ucar/nc2/jni/netcdf/UnloadedNc4IospSpec.groovy create mode 100644 netcdf4/src/unloadedTest/java/ucar/nc2/jni/netcdf/TestUnloadedNc4Iosp.java diff --git a/netcdf4/build.gradle b/netcdf4/build.gradle index 7f1cf95400..3cddb0e1ad 100644 --- a/netcdf4/build.gradle +++ b/netcdf4/build.gradle @@ -31,7 +31,6 @@ dependencies { sourceSets { unloadedTest { - groovy.srcDir file('src/unloadedTest/groovy') resources.srcDir file('src/unloadedTest/resources') compileClasspath += sourceSets.main.output + configurations.testCompileClasspath runtimeClasspath += output + sourceSets.main.output + configurations.testRuntimeClasspath diff --git a/netcdf4/src/unloadedTest/groovy/ucar/nc2/jni/netcdf/UnloadedNc4IospSpec.groovy b/netcdf4/src/unloadedTest/groovy/ucar/nc2/jni/netcdf/UnloadedNc4IospSpec.groovy deleted file mode 100644 index 05e308a10f..0000000000 --- a/netcdf4/src/unloadedTest/groovy/ucar/nc2/jni/netcdf/UnloadedNc4IospSpec.groovy +++ /dev/null @@ -1,38 +0,0 @@ -package ucar.nc2.jni.netcdf - -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import spock.lang.Specification -import ucar.nc2.Attribute - -/** - * Test various aspects of Nc4Iosp when the C lib is NOT loaded. - * - * @author cwardgar - * @since 2016-12-27 - */ -class UnloadedNc4IospSpec extends Specification { - private static final Logger logger = LoggerFactory.getLogger(UnloadedNc4IospSpec) - - def "flush in define mode, without C lib loaded"() { - setup: - Nc4Iosp nc4Iosp = new Nc4Iosp() - - when: "flush while still in define mode" - nc4Iosp.flush() - - then: "no NullPointerException is thrown" - notThrown NullPointerException // Would fail before the bug fix in this commit. - } - - def "updateAttribute in define mode, without C lib loaded"() { - setup: - Nc4Iosp nc4Iosp = new Nc4Iosp() - - when: "updateAttribute while still in define mode" - nc4Iosp.updateAttribute(null, new Attribute("foo", "bar")) - - then: "no IOException is thrown" - notThrown NullPointerException // Would fail before the bug fix in this commit. - } -} diff --git a/netcdf4/src/unloadedTest/java/ucar/nc2/jni/netcdf/TestUnloadedNc4Iosp.java b/netcdf4/src/unloadedTest/java/ucar/nc2/jni/netcdf/TestUnloadedNc4Iosp.java new file mode 100644 index 0000000000..3db804c4c7 --- /dev/null +++ b/netcdf4/src/unloadedTest/java/ucar/nc2/jni/netcdf/TestUnloadedNc4Iosp.java @@ -0,0 +1,20 @@ +package ucar.nc2.jni.netcdf; + +import java.io.IOException; +import org.junit.Test; +import ucar.nc2.Attribute; + +public class TestUnloadedNc4Iosp { + + @Test + public void shouldFlushInDefineModeWithoutCLib() throws IOException { + Nc4Iosp nc4Iosp = new Nc4Iosp(); + nc4Iosp.flush(); + } + + @Test + public void shouldUpdateAttributeInDefineModeWithoutCLib() throws IOException { + Nc4Iosp nc4Iosp = new Nc4Iosp(); + nc4Iosp.updateAttribute(null, new Attribute("foo", "bar")); + } +}