// 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) 
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class TestXml extends Test {
    public static void main(String[] args) throws IOException {
        long t1 = System.currentTimeMillis();
        XMLEncoder xe = new XMLEncoder(new FileOutputStream("C:\\serxml.dat"));
        for(int i = 0; i < N; i++) {
            SomeData o = new SomeData(IV + i, XV, SV);
            xe.writeObject(o);
        }
        xe.close();
        XMLDecoder xd = new XMLDecoder(new FileInputStream("C:\\serxml.dat"));
        for(int i = 0; i < N; i++) {
            SomeData o2 = (SomeData)xd.readObject();
            if((o2.getIv() != IV + i) || (o2.getXv() != XV) || !o2.getSv().equals(SV)) {
                throw new RuntimeException("Data corruption");
            }
        }
        xd.close();
        long t2 = System.currentTimeMillis();
        System.out.println(t2 - t1);
    }
}
