summaryrefslogtreecommitdiffstats
path: root/java/test/TestH5Edefault.java
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2018-11-12 21:31:10 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2018-11-12 21:31:10 (GMT)
commitef29549f0d66612fcdeefc763785c6826c67ad8b (patch)
tree31762fcc3becf3d162ef1dfd9fc4cf53b9e9acf7 /java/test/TestH5Edefault.java
parent6a2e97bead3c4d366f28b6a1e4e338fc07014954 (diff)
downloadhdf5-ef29549f0d66612fcdeefc763785c6826c67ad8b.zip
hdf5-ef29549f0d66612fcdeefc763785c6826c67ad8b.tar.gz
hdf5-ef29549f0d66612fcdeefc763785c6826c67ad8b.tar.bz2
Updated the Java tests so that they don't fail when the
error stack changes.
Diffstat (limited to 'java/test/TestH5Edefault.java')
-rw-r--r--java/test/TestH5Edefault.java92
1 files changed, 52 insertions, 40 deletions
diff --git a/java/test/TestH5Edefault.java b/java/test/TestH5Edefault.java
index 4676205..591793f 100644
--- a/java/test/TestH5Edefault.java
+++ b/java/test/TestH5Edefault.java
@@ -30,7 +30,6 @@ public class TestH5Edefault {
@Rule public TestName testname = new TestName();
public static final int ERRSTACK_CNT = 6;
- public static final int ERRSTACK_MTY_CNT = 0;
@Before
public void H5Eset_default_stack() {
@@ -76,6 +75,7 @@ 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 {
@@ -86,7 +86,7 @@ public class TestH5Edefault {
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,6 +141,7 @@ 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", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
@@ -148,7 +150,7 @@ public class TestH5Edefault {
//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,9 +190,9 @@ 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", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
@@ -197,7 +200,7 @@ public class TestH5Edefault {
//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)
@@ -281,6 +285,9 @@ 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", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
@@ -288,7 +295,7 @@ public class TestH5Edefault {
//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,9 +325,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);
- //Generate errors on default stack
+ // Generate errors on default stack (again, in the same way)
try {
H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
@@ -327,7 +335,7 @@ public class TestH5Edefault {
//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,6 +386,7 @@ public class TestH5Edefault {
@Test
public void testH5Epop() throws Throwable {
long num_msg = -1;
+ long saved_num_msg = -1;
try {
H5.H5Fopen("test", HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT);
}
@@ -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)
@@ -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,7 +530,7 @@ 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
@@ -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);
}
}
+