FileDocCategorySizeDatePackage
FieldTestFileGenerator.javaAPI DocAndroid 1.5 API4070Wed May 06 22:41:06 BST 2009tests.util

FieldTestFileGenerator

public class FieldTestFileGenerator extends Object
Writes three test files that are used as reference in {@code tests.api.java.io.ObjectInputStreamGetFieldTest} and {@code tests.api.java.io.ObjectOutputStreamPutFieldTest}. These files must be moved to {@code $ANDROID_BUILD_TOP/dalvik/libcore/luni/src/test/resources/tests/api/java/io} to be included at the correct location in the core tests package.

Important: Before executing this class, the contents of class {@code tests.support.Support_GetPutFieldsDefaulted} must be commented out. See the description there for further information.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        FileOutputStream fos = null;
        ObjectOutputStream oos = null;
        Support_GetPutFields toSerialize = new Support_GetPutFields();
        Support_GetPutFieldsDeprecated toSerializeDeprecated = 
                new Support_GetPutFieldsDeprecated();
        Support_GetPutFieldsDefaulted toSerializeDefaulted = 
                new Support_GetPutFieldsDefaulted();
        boolean success = true;
        
        toSerialize.initTestValues();
        toSerializeDeprecated.initTestValues();
        toSerializeDefaulted.initTestValues();

        System.out.println("Trying to write the test file 'testFields.ser'...");
        try {
            fos = new FileOutputStream("testFields.ser");
            oos = new ObjectOutputStream(fos);
            oos.writeObject(toSerialize);
            oos.close();
        }
        catch (Exception e) {
            System.out.println("Exception occured while writing the file: " + e);
            success = false;
        }
        finally {
            if (fos != null) fos.close();
        }
        
        System.out.println("Trying to write the test file 'testFieldsDeprecated.ser'...");
        try {
            fos = new FileOutputStream("testFieldsDeprecated.ser");
            oos = new ObjectOutputStream(fos);
            oos.writeObject(toSerializeDeprecated);
            oos.close();
        }
        catch (Exception e) {
            System.out.println("Exception occured while writing the file: " + e);
            success = false;
        }       
        finally {
            if (fos != null) fos.close();
        }
        
        System.out.println("Trying to write the test file 'testFieldsDefaulted.ser'...");
        try {
            fos = new FileOutputStream("testFieldsDefaulted.ser");
            oos = new ObjectOutputStream(fos);
            oos.writeObject(toSerializeDefaulted);
            oos.close();
        }
        catch (Exception e) {
            System.out.println("Exception occured while writing the file: " + e);
            success = false;
        }       
        finally {
            if (fos != null) fos.close();
        }

        if (success) { 
            System.out.println("Success!");
        } else {
            System.out.println("Failure!");
        }