summaryrefslogtreecommitdiffstats
path: root/java/test/TestH5Edefault.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/test/TestH5Edefault.java')
-rw-r--r--java/test/TestH5Edefault.java105
1 files changed, 60 insertions, 45 deletions
diff --git a/java/test/TestH5Edefault.java b/java/test/TestH5Edefault.java
index 5324d3a..591793f 100644
--- a/java/test/TestH5Edefault.java
+++ b/java/test/TestH5Edefault.java
@@ -29,6 +29,8 @@ import org.junit.rules.TestName;
public class TestH5Edefault {
@Rule public TestName testname = new TestName();
+ public static final int ERRSTACK_CNT = 6;
+
@Before
public void H5Eset_default_stack() {
assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0);
@@ -56,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) {
}
@@ -73,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);
}
@@ -91,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 == 4);
+ 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();
}
@@ -104,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);
}
@@ -114,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);
}
@@ -122,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 == 4);
+ assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == saved_num_msg);
try {
H5.H5Eclose_stack(stack_id);
@@ -137,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);
}
@@ -153,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 == 4);
+ 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();
}
@@ -166,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);
}
@@ -176,7 +182,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 correct number of messages
try {
num_msg = H5.H5Eget_num(stack_id);
}
@@ -184,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 == 4);
+ 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);
}
@@ -202,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 == 4);
+ 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);
@@ -213,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 == 3);
+ 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);
}
@@ -223,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 == 4);
+ assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == saved_num_msg);
}
@Test(expected = IllegalArgumentException.class)
@@ -278,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);
}
@@ -293,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 == 4);
+ 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();
}
@@ -306,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);
}
@@ -314,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 == 4);
+ 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);
}
@@ -332,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 == 4);
+ 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);
@@ -343,9 +354,9 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eset_current_stack: " + err);
}
- assertTrue("H5.H5Eset_current_stack: pop #:" + num_msg, num_msg == 3);
+ 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);
}
@@ -353,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 == 4);
+ 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);
@@ -363,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 == 4);
+ assertTrue("H5.H5Eset_current_stack: get_num - " + num_msg, num_msg == saved_num_msg);
}
@Test(expected = IllegalArgumentException.class)
@@ -374,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) {
}
@@ -386,7 +399,8 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Epop: " + err);
}
- assertTrue("H5.H5Epop before #:" + num_msg, num_msg == 4);
+ 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);
@@ -395,7 +409,7 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Epop: " + err);
}
- assertTrue("H5.H5Epop after #:" + num_msg, num_msg == 3);
+ assertTrue("H5.H5Epop after #:" + num_msg, num_msg == saved_num_msg - 1);
}
@Test(expected = IllegalArgumentException.class)
@@ -416,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) {
}
@@ -460,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) {
}
@@ -471,7 +485,7 @@ public class TestH5Edefault {
err.printStackTrace();
fail("H5.H5Eclear2_with_msg: " + err);
}
- assertTrue("H5.H5Eclear2_with_msg before #:" + num_msg, num_msg == 4);
+ 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);
@@ -523,7 +537,7 @@ public class TestH5Edefault {
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) {
}
@@ -538,3 +552,4 @@ public class TestH5Edefault {
}
}
+