summaryrefslogtreecommitdiffstats
path: root/java/test
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2018-12-19 18:58:51 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2018-12-19 18:59:05 (GMT)
commitf9e9c1ad0eeabce09b2f8613427b83daebbf8cb0 (patch)
tree72453927d8e767e342d1b1b1129c66e0bb98cac3 /java/test
parentfc7f4e59aa233e06e8ca7c3c334bb539c62079e5 (diff)
downloadhdf5-f9e9c1ad0eeabce09b2f8613427b83daebbf8cb0.zip
hdf5-f9e9c1ad0eeabce09b2f8613427b83daebbf8cb0.tar.gz
hdf5-f9e9c1ad0eeabce09b2f8613427b83daebbf8cb0.tar.bz2
HDFFV-10664 Add new functions and constants to java interface
Diffstat (limited to 'java/test')
-rw-r--r--java/test/CMakeLists.txt1
-rw-r--r--java/test/Makefile.am1
-rw-r--r--java/test/TestH5VL.java117
-rw-r--r--java/test/junit.sh.in21
-rw-r--r--java/test/testfiles/JUnit-TestH5VL.txt11
5 files changed, 151 insertions, 0 deletions
diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt
index b76f572..937b129 100644
--- a/java/test/CMakeLists.txt
+++ b/java/test/CMakeLists.txt
@@ -38,6 +38,7 @@ set (HDF5_JAVA_TEST_SOURCES
TestH5Ocreate
TestH5Ocopy
TestH5PL
+ TestH5VL
TestH5Z
)
diff --git a/java/test/Makefile.am b/java/test/Makefile.am
index 6635ef7..af99d92 100644
--- a/java/test/Makefile.am
+++ b/java/test/Makefile.am
@@ -69,6 +69,7 @@ noinst_JAVA = \
TestH5Ocreate.java \
TestH5Ocopy.java \
TestH5PL.java \
+ TestH5VL.java \
TestH5Z.java \
TestH5E.java \
TestH5Edefault.java \
diff --git a/java/test/TestH5VL.java b/java/test/TestH5VL.java
new file mode 100644
index 0000000..0397be1
--- /dev/null
+++ b/java/test/TestH5VL.java
@@ -0,0 +1,117 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+package test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import hdf.hdf5lib.H5;
+import hdf.hdf5lib.HDF5Constants;
+import hdf.hdf5lib.exceptions.HDF5LibraryException;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+public class TestH5VL {
+ @Rule public TestName testname = new TestName();
+
+ private final void _deleteFile(String filename) {
+ File file = new File(filename);
+
+ if (file.exists()) {
+ try {file.delete();} catch (SecurityException e) {}
+ }
+ }
+
+ @Before
+ public void checkOpenIDs() {
+ assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0);
+ System.out.print(testname.getMethodName());
+ }
+ @After
+ public void nextTestName() {
+ System.out.println();
+ }
+
+ @Test
+ public void testH5VLnative_init() {
+ try {
+ boolean is_registered;
+
+ is_registered = H5.H5VLis_connector_registered(HDF5Constants.H5VL_NATIVE_NAME);
+ assertTrue("H5.H5VLis_connector_registered H5VL_NATIVE_NAME", is_registered);
+
+ is_registered = H5.H5VLis_connector_registered("FAKE_VOL_NAME");
+ assertFalse("H5.H5VLis_connector_registered FAKE_VOL_NAME", is_registered);
+ }
+ catch (Throwable err) {
+ err.printStackTrace();
+ fail("H5.H5VLis_connector_registered " + err);
+ }
+ }
+
+ @Test
+ public void testH5VLget_connector_id() {
+ try {
+ long native_id = H5.H5VLget_connector_id(HDF5Constants.H5VL_NATIVE_NAME);
+ assertTrue("H5.H5VLget_connector_id H5VL_NATIVE_NAME", native_id >= 0);
+ assertEquals(HDF5Constants.H5VL_NATIVE, native_id);
+ }
+ catch (Throwable err) {
+ err.printStackTrace();
+ fail("H5.H5VLget_connector_id " + err);
+ }
+ }
+
+ @Test
+ public void testH5VLget_connector_name() {
+ String H5_FILE = "testFvl.h5";
+
+ long H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC,
+ HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL);
+
+ try {
+ String native_name = H5.H5VLget_connector_name(H5fid);
+ assertTrue("H5.H5VLget_connector_name H5VL_NATIVE", native_name.compareToIgnoreCase(HDF5Constants.H5VL_NATIVE_NAME)==0);
+ }
+ catch (Throwable err) {
+ err.printStackTrace();
+ fail("H5.H5VLget_connector_name " + err);
+ }
+ finally {
+ if (H5fid > 0) {
+ try {H5.H5Fclose(H5fid);} catch (Exception ex) {}
+ }
+ _deleteFile(H5_FILE);
+ }
+ }
+
+ @Test(expected = HDF5LibraryException.class)
+ public void testH5VLclose_NegativeID() throws Throwable {
+ H5.H5VLclose(-1);
+ }
+
+ @Test(expected = HDF5LibraryException.class)
+ public void testH5VLunregister_connector_NegativeID() throws Throwable {
+ H5.H5VLunregister_connector(-1);
+ }
+}
+
diff --git a/java/test/junit.sh.in b/java/test/junit.sh.in
index 350fb7b..42e16ee 100644
--- a/java/test/junit.sh.in
+++ b/java/test/junit.sh.in
@@ -989,6 +989,27 @@ else
test yes = "$verbose" && $DIFF JUnit-TestH5PL.txt JUnit-TestH5PL.out |sed 's/^/ /'
fi
+echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5VL"
+TESTING JUnit-TestH5VL
+($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5VL > JUnit-TestH5VL.ext)
+
+# Extract file name, line number, version and thread IDs because they may be different
+sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \
+ -e 's/line [0-9]*/line (number)/' \
+ -e 's/Time: [0-9]*\.[0-9]*/Time: XXXX/' \
+ -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \
+ -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \
+ JUnit-TestH5VL.ext > JUnit-TestH5VL.out
+
+if diff JUnit-TestH5VL.out JUnit-TestH5VL.txt > /dev/null; then
+ echo " PASSED JUnit-TestH5VL"
+else
+ echo "**FAILED** JUnit-TestH5VL"
+ echo " Expected result differs from actual result"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF JUnit-TestH5VL.txt JUnit-TestH5VL.out |sed 's/^/ /'
+fi
+
echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Z"
TESTING JUnit-TestH5Z
($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Z > JUnit-TestH5Z.ext)
diff --git a/java/test/testfiles/JUnit-TestH5VL.txt b/java/test/testfiles/JUnit-TestH5VL.txt
new file mode 100644
index 0000000..caadf26
--- /dev/null
+++ b/java/test/testfiles/JUnit-TestH5VL.txt
@@ -0,0 +1,11 @@
+JUnit version 4.11
+.testH5VLget_connector_id
+.testH5VLnative_init
+.testH5VLget_connector_name
+.testH5VLclose_NegativeID
+.testH5VLunregister_connector_NegativeID
+
+Time: XXXX
+
+OK (5 tests)
+