summaryrefslogtreecommitdiffstats
path: root/java/test/TestH5Edefault.java
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2019-12-09 16:30:58 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2019-12-09 16:30:58 (GMT)
commitc8f533cfc33ac743227cbed8eba361c715a2976f (patch)
treebcae5320f80bac774647cacbbd8493604f9384d2 /java/test/TestH5Edefault.java
parentadcf8a315e82c0848d126e7e46b662930c081896 (diff)
downloadhdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.zip
hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.tar.gz
hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.tar.bz2
Merge all of my changes from merge-back-to-feature-vfd_swmr-attempt-1,
including the merge of `hdffv/hdf5/develop`, back to the branch that Vailin and I share. Now I need to put this branch on a fork with a less confusing name than vchoi_fork!
Diffstat (limited to 'java/test/TestH5Edefault.java')
-rw-r--r--java/test/TestH5Edefault.java116
1 files changed, 64 insertions, 52 deletions
diff --git a/java/test/TestH5Edefault.java b/java/test/TestH5Edefault.java
index b510936..ee2850b 100644
--- a/java/test/TestH5Edefault.java
+++ b/java/test/TestH5Edefault.java
@@ -29,8 +29,7 @@ import org.junit.rules.TestName;
public class TestH5Edefault {
@Rule public TestName testname = new TestName();
- public static final int ERRSTACK_CNT = 3;
- public static final int ERRSTACK_MTY_CNT = 0;
+ public static final int ERRSTACK_CNT = 6;
@Before
public void H5Eset_default_stack() {
@@ -59,7 +58,7 @@ public class TestH5Edefault {
@Test
public void testH5Eprint() {
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
}
@@ -76,17 +75,18 @@ public class TestH5Edefault {
public void testH5Eget_current_stack() {
long num_msg = -1;
long num_msg_default = -1;
+ long saved_num_msg = -1;
long stack_id = -1;
long stack_id_default = HDF5Constants.H5E_DEFAULT;
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
//default stack id will be different after exception
stack_id_default = HDF5Constants.H5E_DEFAULT;
//err.printStackTrace(); //This will clear the error stack
}
- // Verify we have the correct number of messages
+ // Verify we have messages on the error stack
try {
num_msg_default = H5.H5Eget_num(stack_id_default);
}
@@ -94,9 +94,10 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_current_stack: " + err);
}
- assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default > 0);
+ saved_num_msg = num_msg_default;
- //Save a copy of the current stack and clears the current stack
+ // Save a copy of the current stack and clear the current stack
try {
stack_id = H5.H5Eget_current_stack();
}
@@ -107,7 +108,7 @@ public class TestH5Edefault {
assertFalse("H5.H5Eget_current_stack: get_current_stack - " + stack_id, stack_id < 0);
assertFalse("H5.H5Eget_current_stack: get_current_stack - " + stack_id, stack_id == stack_id_default);
- // Verify we have the correct number of messages
+ // Verify the default stack is empty
try {
num_msg_default = H5.H5Eget_num(stack_id_default);
}
@@ -117,7 +118,7 @@ public class TestH5Edefault {
}
assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 0);
- //Verify the copy has the correct number of messages
+ // Verify the copy has the same number of messages as the original
try {
num_msg = H5.H5Eget_num(stack_id);
}
@@ -125,7 +126,7 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_current_stack: " + err);
}
- assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == saved_num_msg);
try {
H5.H5Eclose_stack(stack_id);
@@ -140,15 +141,16 @@ public class TestH5Edefault {
public void testH5Eget_current_stack_pop() {
long num_msg = -1;
long num_msg_default = -1;
+ long saved_num_msg = -1;
long stack_id = -1;
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
//err.printStackTrace(); //This will clear the error stack
}
- // Verify we have the correct number of messages
+ // Verify there are error messages on the stack and save it
try {
num_msg_default = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
}
@@ -156,9 +158,10 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_current_stack: " + err);
}
- assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default > 0);
+ saved_num_msg = num_msg_default;
- //Save a copy of the current stack and clears the current stack
+ // Save a copy of the current stack and clear the current stack
try {
stack_id = H5.H5Eget_current_stack();
}
@@ -169,7 +172,7 @@ public class TestH5Edefault {
assertFalse("H5.H5Eget_current_stack: get_current_stack - " + stack_id, stack_id < 0);
assertFalse("H5.H5Eget_current_stack: get_current_stack - " + stack_id, stack_id == HDF5Constants.H5E_DEFAULT);
- // Verify we have the correct number of messages
+ // Verify the stack is empty
try {
num_msg_default = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
}
@@ -177,9 +180,9 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_current_stack: " + err);
}
- assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_MTY_CNT);
+ assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 0);
- //Verify the copy has the correct number of messages
+ // Verify the copy has the correct number of messages
try {
num_msg = H5.H5Eget_num(stack_id);
}
@@ -187,17 +190,17 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_current_stack: " + err);
}
- assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == saved_num_msg);
- //Generate errors on default stack
+ // Generate errors on default stack
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
//err.printStackTrace(); //This will clear the error stack
}
- // Verify we have the correct number of messages
+ // Verify we have a nonzero number of messages and save it
try {
num_msg_default = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
}
@@ -205,9 +208,10 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_current_stack: " + err);
}
- assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default > 0);
+ saved_num_msg = num_msg;
- //Remove one message from the current stack
+ // Remove one message from the current stack
try {
H5.H5Epop(HDF5Constants.H5E_DEFAULT, 1);
num_msg_default = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
@@ -216,9 +220,9 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_current_stack: " + err);
}
- assertTrue("H5.H5Eget_current_stack: pop #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT - 1);
+ assertTrue("H5.H5Eget_current_stack: pop #:" + num_msg_default, num_msg_default == saved_num_msg - 1);
- //Verify the copy still has the correct number of messages
+ // Verify the copy still has the old number of messages
try {
num_msg = H5.H5Eget_num(stack_id);
}
@@ -226,7 +230,7 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_current_stack: " + err);
}
- assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == saved_num_msg);
}
@Test(expected = IllegalArgumentException.class)
@@ -239,7 +243,7 @@ public class TestH5Edefault {
H5.H5Eget_class_name(-1);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = HDF5LibraryException.class)
public void testH5Eget_class_name_invalid_classname() throws Throwable {
H5.H5Eget_class_name(HDF5Constants.H5E_DEFAULT);
}
@@ -281,14 +285,17 @@ public class TestH5Edefault {
public void testH5Eset_current_stack() {
long num_msg = -1;
long stack_id = -1;
+ long saved_num_msg = -1;
+
+ // Generate errors on the default stack
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
//err.printStackTrace(); //This will clear the error stack
}
- // Verify we have the correct number of messages
+ // Verify we have a nonzero number of messages and save it
try {
num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
}
@@ -296,9 +303,10 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eset_current_stack: " + err);
}
- assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg > 0);
+ saved_num_msg = num_msg;
- //Save a copy of the current stack
+ // Save a copy of the current stack
try {
stack_id = H5.H5Eget_current_stack();
}
@@ -309,7 +317,7 @@ public class TestH5Edefault {
assertFalse("H5.H5Eset_current_stack: get_current_stack - " + stack_id, stack_id < 0);
assertFalse("H5.H5Eset_current_stack: get_current_stack - " + stack_id, stack_id == HDF5Constants.H5E_DEFAULT);
- //Verify the copy has the correct number of messages
+ // Verify the copy has the same number of messages as the original stack
try {
num_msg = H5.H5Eget_num(stack_id);
}
@@ -317,17 +325,17 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eset_current_stack: " + err);
}
- assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == saved_num_msg);
- //Generate errors on default stack
+ // Generate errors on default stack (again, in the same way)
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
//err.printStackTrace(); //This will clear the error stack
}
- // Verify we have the correct number of messages
+ // Verify we have the same number of messages as before
try {
num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
}
@@ -335,9 +343,9 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_current_stack: " + err);
}
- assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == saved_num_msg);
- //Remove one message from the current stack
+ // Remove one message from the current stack
try {
H5.H5Epop(HDF5Constants.H5E_DEFAULT, 1);
num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
@@ -346,9 +354,9 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eset_current_stack: " + err);
}
- assertTrue("H5.H5Eset_current_stack: pop #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT - 1);
+ assertTrue("H5.H5Eset_current_stack: pop #:" + num_msg, num_msg == saved_num_msg - 1);
- //Verify the copy still has the correct number of messages
+ // Verify the copy still has the correct number of messages
try {
num_msg = H5.H5Eget_num(stack_id);
}
@@ -356,8 +364,9 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eset_current_stack: " + err);
}
- assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == saved_num_msg);
+ // Se the current stack to be the default and try that again
try {
H5.H5Eset_current_stack(stack_id);
num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
@@ -366,7 +375,7 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eset_current_stack: " + err);
}
- assertTrue("H5.H5Eset_current_stack: get_num - " + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eset_current_stack: get_num - " + num_msg, num_msg == saved_num_msg);
}
@Test(expected = IllegalArgumentException.class)
@@ -377,8 +386,9 @@ public class TestH5Edefault {
@Test
public void testH5Epop() throws Throwable {
long num_msg = -1;
+ long saved_num_msg = -1;
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
}
@@ -389,7 +399,8 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Epop: " + err);
}
- assertTrue("H5.H5Epop before #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Epop before #:" + num_msg, num_msg > 0);
+ saved_num_msg = num_msg;
try {
H5.H5Epop(HDF5Constants.H5E_DEFAULT, 1);
num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
@@ -398,7 +409,7 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Epop: " + err);
}
- assertTrue("H5.H5Epop after #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT - 1);
+ assertTrue("H5.H5Epop after #:" + num_msg, num_msg == saved_num_msg - 1);
}
@Test(expected = IllegalArgumentException.class)
@@ -419,7 +430,7 @@ public class TestH5Edefault {
@Test
public void testH5EprintInt() {
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
}
@@ -463,7 +474,7 @@ public class TestH5Edefault {
public void testH5Eclear2_with_msg() {
long num_msg = -1;
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
}
@@ -474,7 +485,7 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eclear2_with_msg: " + err);
}
- assertTrue("H5.H5Eclear2_with_msg before #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT);
+ assertTrue("H5.H5Eclear2_with_msg before #:" + num_msg, num_msg > 0);
try {
H5.H5Eclear2(HDF5Constants.H5E_DEFAULT);
num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT);
@@ -483,7 +494,7 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eclear2_with_msg: " + err);
}
- assertTrue("H5.H5Eclear2_with_msg after #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_MTY_CNT);
+ assertTrue("H5.H5Eclear2_with_msg after #:" + num_msg, num_msg == 0);
}
@Test(expected = IllegalArgumentException.class)
@@ -519,14 +530,14 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_num: " + err);
}
- assertTrue("H5.H5Eget_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_MTY_CNT);
+ assertTrue("H5.H5Eget_num #:" + num_msg, num_msg == 0);
}
@Test
public void testH5Eget_num_with_msg() {
long num_msg = -1;
try {
- H5.H5Fopen("test", 0, 1);
+ H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
}
@@ -537,7 +548,8 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eget_num_with_msg: " + err);
}
- assertTrue("H5.H5Eget_num_with_msg #:" + num_msg, num_msg > TestH5Edefault.ERRSTACK_MTY_CNT);
+ assertTrue("H5.H5Eget_num_with_msg #:" + num_msg, num_msg > 0);
}
}
+