summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorM. Scot Breitenfeld <brtnfld@hdfgroup.org>2017-10-26 15:13:33 (GMT)
committerM. Scot Breitenfeld <brtnfld@hdfgroup.org>2017-10-26 15:13:33 (GMT)
commit59e7c7703e62717e7bf482bec2bbad52aada3c80 (patch)
tree59ebe294f77f57850a017ff9596234066d3acebd /java
parentc3aa3978b2873b158a1917f8961c035f413b5e56 (diff)
parent084704392fa93d1569861c53504e89236468a3b6 (diff)
downloadhdf5-59e7c7703e62717e7bf482bec2bbad52aada3c80.zip
hdf5-59e7c7703e62717e7bf482bec2bbad52aada3c80.tar.gz
hdf5-59e7c7703e62717e7bf482bec2bbad52aada3c80.tar.bz2
Merge branch 'develop' into hdf5_1_10
Diffstat (limited to 'java')
-rw-r--r--java/CMakeLists.txt2
-rw-r--r--java/test/TestH5PL.java88
2 files changed, 70 insertions, 20 deletions
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
index d37a409..68860be 100644
--- a/java/CMakeLists.txt
+++ b/java/CMakeLists.txt
@@ -10,6 +10,8 @@ include (${HDF_RESOURCES_DIR}/UseJava.cmake)
message (STATUS "JAVA: JAVA_HOME=$ENV{JAVA_HOME} JAVA_ROOT=$ENV{JAVA_ROOT}")
find_package (JNI)
+message ("JNI_LIBRARIES=${JNI_LIBRARIES}")
+message ("JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES ( ${JNI_INCLUDE_DIRS} )
diff --git a/java/test/TestH5PL.java b/java/test/TestH5PL.java
index aa59478..8ce708b 100644
--- a/java/test/TestH5PL.java
+++ b/java/test/TestH5PL.java
@@ -70,26 +70,74 @@ public class TestH5PL {
@Test
public void TestH5PLpaths() {
try {
- int original_entries = H5.H5PLsize();
- H5.H5PLappend("path_one");
- int plugin_entries = H5.H5PLsize();
- assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+1) == plugin_entries);
- H5.H5PLprepend("path_two");
- plugin_entries = H5.H5PLsize();
- assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+2) == plugin_entries);
- H5.H5PLinsert("path_three", original_entries);
- plugin_entries = H5.H5PLsize();
- assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+3) == plugin_entries);
- String first_path = H5.H5PLget(original_entries);
- assertTrue("First path was : "+first_path + " ",first_path.compareToIgnoreCase("path_three")==0);
- H5.H5PLreplace("path_four", original_entries);
- first_path = H5.H5PLget(original_entries);
- assertTrue("First path changed to : "+first_path + " ",first_path.compareToIgnoreCase("path_four")==0);
- H5.H5PLremove(original_entries);
- first_path = H5.H5PLget(original_entries);
- assertTrue("First path now : "+first_path + " ",first_path.compareToIgnoreCase("path_two")==0);
- plugin_entries = H5.H5PLsize();
- assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+2) == plugin_entries);
+ // Get the original number of paths
+ int nStartPaths = H5.H5PLsize();
+
+ int nPaths; /* # paths from H5PLSize() */
+ int nTruePaths = nStartPaths; /* What the # paths should be */
+ int index; /* Path table index */
+ String path; /* Path from H5PLget() */
+
+ // APPEND a path and ensure it was added correctly
+ String pathAppend = "path_append";
+ H5.H5PLappend(pathAppend);
+
+ nPaths = H5.H5PLsize();
+ nTruePaths++;
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ index = nTruePaths - 1;
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathAppend + " but was " + path, path.compareToIgnoreCase(pathAppend) == 0);
+
+ // PREPEND a path and ensure it was added correctly
+ String pathPrepend = "path_prepend";
+ H5.H5PLprepend(pathPrepend);
+
+ nPaths = H5.H5PLsize();
+ nTruePaths++;
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ index = 0;
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathPrepend + " but was " + path, path.compareToIgnoreCase(pathPrepend) == 0);
+
+ // INSERT a path and ensure it was added correctly
+ // Inserting at the index == # of start paths ensures we're in the middle
+ String pathInsert = "path_insert";
+ index = nStartPaths;
+ H5.H5PLinsert(pathInsert, index);
+
+ nPaths = H5.H5PLsize();
+ nTruePaths++;
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathInsert + " but was " + path, path.compareToIgnoreCase(pathInsert) == 0);
+
+ // REPLACE the path we just added and ensure it updated correctly
+ String pathReplace = "path_replace";
+ index = nStartPaths;
+ H5.H5PLreplace(pathReplace, index);
+
+ nPaths = H5.H5PLsize();
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathReplace + " but was " + path, path.compareToIgnoreCase(pathReplace) == 0);
+
+ // REMOVE the path we just replaced and check that the table was compacted
+ // The (index+1) path should move down to fill the space when the path is removed.
+ index = nStartPaths;
+ String pathRemove = H5.H5PLget(index + 1);
+ H5.H5PLremove(index);
+
+ nPaths = H5.H5PLsize();
+ nTruePaths--;
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathRemove + " but was " + path, path.compareToIgnoreCase(pathRemove) == 0);
}
catch (Throwable err) {
err.printStackTrace();