summaryrefslogtreecommitdiffstats
path: root/java/test/TestH5.java
diff options
context:
space:
mode:
authorAllen Byrne <50328838+byrnHDF@users.noreply.github.com>2021-03-12 13:48:16 (GMT)
committerGitHub <noreply@github.com>2021-03-12 13:48:16 (GMT)
commit579b266e65974fad1f7c30ac5c7c24405e2d326e (patch)
tree5ffbf27400a32e5b68493c6f4e41af2d5919818e /java/test/TestH5.java
parentc6a2cc29f3623af0ab9cc7a80922d7ef6502e7a8 (diff)
downloadhdf5-579b266e65974fad1f7c30ac5c7c24405e2d326e.zip
hdf5-579b266e65974fad1f7c30ac5c7c24405e2d326e.tar.gz
hdf5-579b266e65974fad1f7c30ac5c7c24405e2d326e.tar.bz2
1 12 JNI export references and java updates (#464)
* OESS-98 fix tools test for plugins * sync fork * Merge of changes from dev * Move problem option to bottom of the list until fixed * HDFFV-11106 - fix parsing optional args * HDFFV-11106 add note * grammer fix * Whitespace after clang formatting * Undo format version 11 changes * Update check to working version * Merge workflow and minor changes from develop * Update supported platforms * PR#3 merge from develop * Merge gcc 10 diagnostics option from develop * Merge #318 OSX changes from develop * Merge serval small changes from dev * fix typo * Minor non-space formatting changes * GH #386 copyright corrections for java folder * revert because logic requires false return * Merges from develop #358 patches from vtk #361 fix header guard spelling * Remove case statement for H5I_EVENTSET * Correct call with versioning * Remove tabs * Double underscore change * Merges from develop #340 clang -Wformat-security warnings #360 Fixed uninitialized warnings Remove more underscores from header guards * Merge #380 from develop * Correct date entry * Split format source and commit changes on repo push * remove pre-split setting * Change windows TS to use older VS. * 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/TestH5.java')
-rw-r--r--java/test/TestH5.java119
1 files changed, 105 insertions, 14 deletions
diff --git a/java/test/TestH5.java b/java/test/TestH5.java
index a6b60d3..bef0627 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]);
}
}