// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public abstract class Test {
    public abstract void writeRec(Data o) throws TestException;
    public abstract Data readRec() throws TestException;
    public abstract void close() throws TestException;
    public void testWrite(int n) throws TestException {
        for(int i = 0; i < n; i++) {
            Data o = new Data(i, i, "Test #" + i);
            writeRec(o);
        }
    }
    public void testRead(int n) throws TestException {
        for(int i = 0; i < n; i++) {
            Data o = readRec();
            if(o.getIv() != i || !o.getSv().equals("Test #" + i)) {
                throw new IllegalStateException("Ooops");
            }
        }
    }
}
