summaryrefslogtreecommitdiffstats
path: root/java/test
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2021-03-12 13:47:47 (GMT)
committerGitHub <noreply@github.com>2021-03-12 13:47:47 (GMT)
commit748da20bbc42aa119305ee84f863361816e1517e (patch)
treeb794e206001650235f2977e31e44db0af81d9f68 /java/test
parent6f760f200d6cb959c960b936af3fb2e68a55afde (diff)
downloadhdf5-748da20bbc42aa119305ee84f863361816e1517e.zip
hdf5-748da20bbc42aa119305ee84f863361816e1517e.tar.gz
hdf5-748da20bbc42aa119305ee84f863361816e1517e.tar.bz2
develop JNI export references and java updates (#467)
* OESS-98 convert plugin option to FetchContent, add tests * Fixes for pkcfg files because of plugin option * OESS-98 fix tools test for plugins * Keep doxygen comments under 100 chars long - format hint * Whitespace * HDFFV-11144 - Reclassify CMake messages * HDFFV-11099/11100 added help text * Reworked switch statement to compare string instead * Fix typo * Update CDash mode * Correct name of threadsafe * Correct option name * Undo accidental commit * Note LLVM 10 to 11 format default changes * Update format plugin * Undo clang-format version 11 changes * One more correction * Update supported platforms * Revert whitespace changes * Correct whitespace * Changes from PR#3 * HDFFV-11213 added option to control gcc10 warnings diagnostics * HDFFV-11212 Use the new references correctly in JNI utility and tests * format source * Fix typo * Add new test file * HDFFV-11212 - update test and remove unused arg * Minor non-space formatting changes * Use H5I_INVALID_ID instead of "-1" * source formatting * add missing testfile, update jni function * Undo commit of debug code * remove mislocated file * Fix h5repack test for handling of fapls and id close * Update h5diff test files usage text * HDFFV-11212 add new ref tests for JNI export dataset * src format update * Remove blank line typo * src format typo * long double requires %Lg * Another long double foramt specifer S.B. %Lg * issue with t128bit test * Windows issue with h5dump and type. * Fix review issues * refactor function nesting and fix error checks * format fixes * Remove untested functions and javadoc quiet comments * Restore TRY block. * Change string append errors to memory exception * revert to H5_JNI_FATAL_ERROR - support functions need work * Add assertion error for h5util functions * remove duplicate function * format fix * Revert HD function error handling * Update copyright comments * GH #386 java folder copyright corrections * Whitespace * GH #359 implement and fix tools 1.6 API usage * remove excessive comments * Flip inits to correct ifdef section * rework ifdef to be simpler * format issue * Reformat ifdef inits * remove static attribute * format compliance * Update names * Revert because logic relies on float not being int * Changes noticed from creating merge of #412 * Double underscore change * Correct compiler version variable used * Remove header guard underscores * Whitespace cleanup * Split format source and commit changes on repo push * remove pre-split setting * Change windows TS to use older VS. * correct window os name * HDFFV-11212 JNI export util and Javadoc * Suggested review changes * Another change found * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'java/test')
-rw-r--r--java/test/CMakeLists.txt4
-rw-r--r--java/test/TestH5.java119
-rw-r--r--java/test/TestH5D.java2
-rw-r--r--java/test/TestH5Rref.java2
-rw-r--r--java/test/TestH5T.java4
-rw-r--r--java/test/junit.sh.in2
-rw-r--r--java/test/testfiles/JUnit-TestH5.txt4
7 files changed, 118 insertions, 19 deletions
diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt
index c791c79..10f9d52 100644
--- a/java/test/CMakeLists.txt
+++ b/java/test/CMakeLists.txt
@@ -96,6 +96,8 @@ HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/h5ex_g_iterate.orig" "${PROJECT_BINARY_
HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/h5ex_g_iterate.orig" "${PROJECT_BINARY_DIR}/h5ex_g_iterateO2.hdf" "${HDF5_JAVA_TEST_LIB_TARGET}_files")
HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/trefer_reg.h5" "${PROJECT_BINARY_DIR}/trefer_reg.h5" "${HDF5_JAVA_TEST_LIB_TARGET}_files")
HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/trefer_attr.h5" "${PROJECT_BINARY_DIR}/trefer_attr.h5" "${HDF5_JAVA_TEST_LIB_TARGET}_files")
+HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tdatareg.h5" "${PROJECT_BINARY_DIR}/tdatareg.h5" "${HDF5_JAVA_TEST_LIB_TARGET}_files")
+HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tattrreg.h5" "${PROJECT_BINARY_DIR}/tattrreg.h5" "${HDF5_JAVA_TEST_LIB_TARGET}_files")
add_custom_target(${HDF5_JAVA_TEST_LIB_TARGET}_files ALL COMMENT "Copying files needed by ${HDF5_JAVA_TEST_LIB_TARGET} tests" DEPENDS ${${HDF5_JAVA_TEST_LIB_TARGET}_files_list})
@@ -213,6 +215,8 @@ if (HDF5_TEST_JAVA AND HDF5_TEST_SERIAL)
HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/h5ex_g_iterate.orig" "${PROJECT_BINARY_DIR}/${voltest}/h5ex_g_iterateO2.hdf" "${HDF5_JAVA_TEST_LIB_TARGET}_${voltest}_files")
HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/trefer_reg.h5" "${PROJECT_BINARY_DIR}/${voltest}/trefer_reg.h5" "${HDF5_JAVA_TEST_LIB_TARGET}_${voltest}_files")
HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/trefer_attr.h5" "${PROJECT_BINARY_DIR}/${voltest}/trefer_attr.h5" "${HDF5_JAVA_TEST_LIB_TARGET}_${voltest}_files")
+ HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tdatareg.h5" "${PROJECT_BINARY_DIR}/${voltest}/tdatareg.h5" "${HDF5_JAVA_TEST_LIB_TARGET}_${voltest}_files")
+ HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/tattrreg.h5" "${PROJECT_BINARY_DIR}/${voltest}/tattrreg.h5" "${HDF5_JAVA_TEST_LIB_TARGET}_${voltest}_files")
add_custom_target(${HDF5_JAVA_TEST_LIB_TARGET}_${voltest}_files ALL COMMENT "Copying files needed by ${HDF5_JAVA_TEST_LIB_TARGET} tests" DEPENDS ${${HDF5_JAVA_TEST_LIB_TARGET}_${voltest}_files_list})
diff --git a/java/test/TestH5.java b/java/test/TestH5.java
index c4f298e..1f298f3 100644
--- a/java/test/TestH5.java
+++ b/java/test/TestH5.java
@@ -49,9 +49,13 @@ public class TestH5 {
@Rule public TestName testname = new TestName();
private static final String H5_FILE = "testData.h5";
private static final String EXPORT_FILE = "testExport.txt";
- private static final String H5_DREG_FILE = "trefer_reg.h5";
- private static final String EXPORT_DREG_FILE = "testExportReg.txt";
- private static final String H5_AREG_FILE = "trefer_attr.h5";
+ private static final String H5_REGION_FILE = "trefer_reg.h5";
+ private static final String EXPORT_REGION_FILE = "testExportReg.txt";
+ private static final String H5_ATTR_FILE = "trefer_attr.h5";
+ private static final String EXPORT_ATTR_FILE = "testExportAttr.txt";
+ private static final String H5_DREG_FILE = "tdatareg.h5";
+ private static final String EXPORT_DREG_FILE = "testExportDReg.txt";
+ private static final String H5_AREG_FILE = "tattrreg.h5";
private static final String EXPORT_AREG_FILE = "testExportAReg.txt";
private static final int DIM_X = 4;
private static final int DIM_Y = 6;
@@ -129,7 +133,7 @@ public class TestH5 {
public void _openH5File(String filename, String dsetname) {
try {
H5fid = H5.H5Fopen(filename,
- HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
+ HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
@@ -162,6 +166,7 @@ public class TestH5 {
@After
public void closeH5File() throws HDF5LibraryException {
_closeH5File();
+ assertTrue("H5 open ids is 0", H5.getOpenIDCount()==0);
System.out.println();
}
@@ -415,8 +420,10 @@ public class TestH5 {
_closeH5File();
+ _openH5File(H5_FILE, "/dset");
+
try {
- H5.H5export_dataset(EXPORT_FILE, H5_FILE, "/dset", 99);
+ H5.H5export_dataset(EXPORT_FILE, H5fid, "/dset", 99);
}
catch (HDF5LibraryException err) {
err.printStackTrace();
@@ -454,6 +461,86 @@ public class TestH5 {
}
@Test
+ public void testH5export_region() {
+ int[] dset_data_expect = {66, 69, 72, 75, 78, 81, 96, 99, 102, 105, 108,
+ 111, 126, 129, 132, 135, 138, 141, 156, 159, 162, 165, 168, 171,
+ 186, 189, 192, 195, 198, 201, 216, 219, 222, 225, 228, 231,
+ 207, 66, 252, 48, 84, 96, 12, 14, 213, 99};
+ int[] dset_indata = new int[DIM_BLKS+DIM_PNTS];
+ String objName = "/Dataset1";
+
+ _openH5File(H5_REGION_FILE, objName);
+
+ try {
+ H5.H5export_dataset(EXPORT_REGION_FILE, H5fid, objName, 99);
+ }
+ catch (HDF5LibraryException err) {
+ err.printStackTrace();
+ fail("H5export_dataset failed: " + err);
+ }
+
+ File file = new File(EXPORT_REGION_FILE);
+
+ try {
+ Reader reader = new FileReader(EXPORT_REGION_FILE);
+ StreamTokenizer streamTokenizer = new StreamTokenizer(reader);
+ int indx = 0;
+ while(streamTokenizer.nextToken() != StreamTokenizer.TT_EOF){
+ if(streamTokenizer.ttype == StreamTokenizer.TT_NUMBER) {
+ dset_indata[indx] = (int)streamTokenizer.nval;
+ indx++;
+ }
+ }
+ reader.close();
+ }
+ catch (IOException err) {
+ err.printStackTrace();
+ fail("read file failed: " + err);
+ }
+ for(int row = 0; row < DIM_X; row++)
+ assertTrue("testH5export_region: <"+row+">"+dset_indata[row], dset_indata[row]==dset_data_expect[row]);
+ }
+
+ @Test
+ public void testH5export_attribute() {
+ int[] dset_data_expect = {0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11};
+ int[] dset_indata = new int[DIM_ATTR];
+ String objName = "/Dataset3";
+
+ _openH5File(H5_ATTR_FILE, objName);
+
+ try {
+ H5.H5export_dataset(EXPORT_ATTR_FILE, H5did, objName, 99);
+ }
+ catch (HDF5LibraryException err) {
+ err.printStackTrace();
+ fail("H5export_dataset failed: " + err);
+ }
+
+ File file = new File(EXPORT_ATTR_FILE);
+
+ try {
+ Reader reader = new FileReader(EXPORT_ATTR_FILE);
+ StreamTokenizer streamTokenizer = new StreamTokenizer(reader);
+ int indx = 0;
+ int jndx = 0;
+ while(streamTokenizer.nextToken() != StreamTokenizer.TT_EOF){
+ if(streamTokenizer.ttype == StreamTokenizer.TT_NUMBER) {
+ dset_indata[indx] = (int)streamTokenizer.nval;
+ indx++;
+ }
+ }
+ reader.close();
+ }
+ catch (IOException err) {
+ err.printStackTrace();
+ fail("read file failed: " + err);
+ }
+ for(int row = 0; row < DIM_X; row++)
+ assertTrue("testH5export_attribute: <"+row+">"+dset_indata[row], dset_indata[row]==dset_data_expect[row]);
+ }
+
+ @Test
public void testH5export_regdataset() {
int[] dset_data_expect = {66, 69, 72, 75, 78, 81, 96, 99, 102, 105, 108,
111, 126, 129, 132, 135, 138, 141, 156, 159, 162, 165, 168, 171,
@@ -465,7 +552,7 @@ public class TestH5 {
_openH5File(H5_DREG_FILE, objName);
try {
- H5.H5export_dataset(EXPORT_DREG_FILE, H5_DREG_FILE, objName, 99);
+ H5.H5export_dataset(EXPORT_DREG_FILE, H5fid, objName, 99);
}
catch (HDF5LibraryException err) {
err.printStackTrace();
@@ -491,23 +578,27 @@ public class TestH5 {
fail("read file failed: " + err);
}
for(int row = 0; row < DIM_X; row++)
- assertTrue("H5export_dataset: <"+row+">"+dset_indata[row], dset_indata[row]==dset_data_expect[row]);
+ assertTrue("testH5export_regdataset: <"+row+">"+dset_indata[row], dset_indata[row]==dset_data_expect[row]);
}
@Test
public void testH5export_attrdataset() {
- int[] dset_data_expect = {0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11};
- int[] dset_indata = new int[DIM_ATTR];
- String objName = "/Dataset3";
+ int[] dset_data_expect = {66, 69, 72, 75, 78, 81, 96, 99, 102, 105, 108,
+ 111, 126, 129, 132, 135, 138, 141, 156, 159, 162, 165, 168, 171,
+ 186, 189, 192, 195, 198, 201, 216, 219, 222, 225, 228, 231,
+ 207, 66, 252, 48, 84, 96, 12, 14, 213, 99};
+ int[] dset_indata = new int[DIM_BLKS+DIM_PNTS];
+ String dsetName = "/Dataset1";
+ String objName = "Attribute1";
- _openH5File(H5_AREG_FILE, objName);
+ _openH5File(H5_AREG_FILE, dsetName);
try {
- H5.H5export_dataset(EXPORT_AREG_FILE, H5_AREG_FILE, objName, 99);
+ H5.H5export_attribute(EXPORT_AREG_FILE, H5did, objName, 99);
}
catch (HDF5LibraryException err) {
err.printStackTrace();
- fail("H5export_dataset failed: " + err);
+ fail("H5export_attribute failed: " + err);
}
File file = new File(EXPORT_AREG_FILE);
@@ -530,6 +621,6 @@ public class TestH5 {
fail("read file failed: " + err);
}
for(int row = 0; row < DIM_X; row++)
- assertTrue("H5export_dataset: <"+row+">"+dset_indata[row], dset_indata[row]==dset_data_expect[row]);
+ assertTrue("testH5export_attrdataset: <"+row+">"+dset_indata[row], dset_indata[row]==dset_data_expect[row]);
}
}
diff --git a/java/test/TestH5D.java b/java/test/TestH5D.java
index 863ce79..dac3a9c 100644
--- a/java/test/TestH5D.java
+++ b/java/test/TestH5D.java
@@ -197,7 +197,7 @@ public class TestH5D {
private final void _openH5file(String filename, String dsetname, long dapl) {
try {
H5fid = H5.H5Fopen(filename,
- HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
+ HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
diff --git a/java/test/TestH5Rref.java b/java/test/TestH5Rref.java
index aeec64f..cbdabdd 100644
--- a/java/test/TestH5Rref.java
+++ b/java/test/TestH5Rref.java
@@ -53,7 +53,7 @@ public class TestH5Rref {
public void openH5file(String filename, String dsetname) {
try {
H5fid = H5.H5Fopen(filename,
- HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
+ HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
diff --git a/java/test/TestH5T.java b/java/test/TestH5T.java
index c882f8e..ed4e2a9 100644
--- a/java/test/TestH5T.java
+++ b/java/test/TestH5T.java
@@ -206,7 +206,7 @@ public class TestH5T {
@Test
public void testH5Tenum_functions() {
- long filetype_id =HDF5Constants.H5I_INVALID_HID;
+ long filetype_id = HDF5Constants.H5I_INVALID_HID;
String enum_type ="Enum_type";
byte[] enum_val = new byte[1];
String enum_name = null;
@@ -398,7 +398,7 @@ public class TestH5T {
@Test
public void testH5Tcompound_functions() {
- long filetype_id =HDF5Constants.H5I_INVALID_HID;
+ long filetype_id = HDF5Constants.H5I_INVALID_HID;
// Create a compound datatype
try {
diff --git a/java/test/junit.sh.in b/java/test/junit.sh.in
index 81ce13b..3774cbd 100644
--- a/java/test/junit.sh.in
+++ b/java/test/junit.sh.in
@@ -252,6 +252,8 @@ COPY_DATAFILES_TO_BLDDIR()
$CP -f $HDFTEST_HOME/h5ex_g_iterate.orig $BLDDIR/h5ex_g_iterateO2.hdf
$CP -f $TOOLS_TESTFILES/trefer_reg.h5 $BLDDIR/trefer_reg.h5
$CP -f $TOOLS_TESTFILES/trefer_attr.h5 $BLDDIR/trefer_attr.h5
+ $CP -f $TOOLS_TESTFILES/tdatareg.h5 $BLDDIR/tdatareg.h5
+ $CP -f $TOOLS_TESTFILES/tattrreg.h5 $BLDDIR/tattrreg.h5
}
CLEAN_DATAFILES_AND_BLDDIR()
diff --git a/java/test/testfiles/JUnit-TestH5.txt b/java/test/testfiles/JUnit-TestH5.txt
index 59765d9..fb50a57 100644
--- a/java/test/testfiles/JUnit-TestH5.txt
+++ b/java/test/testfiles/JUnit-TestH5.txt
@@ -1,4 +1,5 @@
JUnit version 4.11
+.testH5export_region
.testH5get_libversion_null_param
.testJ2C
.testH5export_dataset
@@ -7,6 +8,7 @@ JUnit version 4.11
.testH5garbage_collect
.testH5error_off
.testH5export_regdataset
+.testH5export_attribute
.serializeToDisk
.testH5open
.testH5check_version
@@ -15,5 +17,5 @@ JUnit version 4.11
Time: XXXX
-OK (13 tests)
+OK (15 tests)