Search in sources :

Example 1 with StructureMismatchError

use of com.ibm.j9ddr.tools.store.StructureMismatchError in project openj9 by eclipse.

the class J9DDRStructureStoreTest method add.

@Test
public void add() {
    // Test
    J9DDRStructureStore store = null;
    try {
        store = new J9DDRStructureStore("newDir", "superset.dat");
    } catch (IOException e) {
        e.printStackTrace();
        fail("Could not open store");
    }
    String original = "E:\\workspaces\\j9ddr\\DDR_VM\\data\\structure blobs\\j9ddr.dat";
    String newOne = "E:\\workspaces\\j9ddr\\DDR_VM\\data\\structure blobs\\newj9ddr.dat";
    StructureKey keyOne = new StructureKey("windows", "foo");
    StructureKey keyTwo = new StructureKey("windows", "bar");
    // String structureFileName = original;
    // StructureKey key = keyOne;
    String structureFileName = newOne;
    StructureKey key = keyTwo;
    try {
        store.add(key, structureFileName, true);
        store.close();
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    } catch (StructureMismatchError e) {
        e.printStackTrace();
        fail(e.getMessage());
    } finally {
        try {
            store.close();
        } catch (IOException e) {
            fail("Could not close store");
        }
    }
    // TODO: Open file and make sure it is good.
    try {
        store.close();
        store = null;
        store = new J9DDRStructureStore("newDir", "superset.dat");
        ImageInputStream is = store.get(key);
        FileInputStream fis = new FileInputStream(structureFileName);
        assertTrue("Files where not the same", compare(is, fis));
    } catch (IOException e) {
        fail();
    }
}
Also used : StructureKey(com.ibm.j9ddr.tools.store.StructureKey) J9DDRStructureStore(com.ibm.j9ddr.tools.store.J9DDRStructureStore) ImageInputStream(javax.imageio.stream.ImageInputStream) StructureMismatchError(com.ibm.j9ddr.tools.store.StructureMismatchError) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 2 with StructureMismatchError

use of com.ibm.j9ddr.tools.store.StructureMismatchError in project openj9 by eclipse.

the class AddStructureBlob method run.

private void run() {
    String directoryName = opts.get("-d");
    String supersetName = opts.get("-s");
    if (supersetName == null) {
        supersetName = J9DDRStructureStore.DEFAULT_SUPERSET_FILE_NAME;
    }
    try {
        J9DDRStructureStore store = new J9DDRStructureStore(directoryName, supersetName);
        String path = opts.get("-c");
        if ((null == path) || (path.length() == 0)) {
            // path for properties file not specified so default to adding from a single file or directory
            addFromFile(store);
        } else {
            // a property file controls the order in which blobs are processed
            addFromPropertiesFile(store);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (StructureMismatchError e) {
        e.printStackTrace();
    }
}
Also used : J9DDRStructureStore(com.ibm.j9ddr.tools.store.J9DDRStructureStore) StructureMismatchError(com.ibm.j9ddr.tools.store.StructureMismatchError) IOException(java.io.IOException)

Aggregations

J9DDRStructureStore (com.ibm.j9ddr.tools.store.J9DDRStructureStore)2 StructureMismatchError (com.ibm.j9ddr.tools.store.StructureMismatchError)2 IOException (java.io.IOException)2 StructureKey (com.ibm.j9ddr.tools.store.StructureKey)1 FileInputStream (java.io.FileInputStream)1 ImageInputStream (javax.imageio.stream.ImageInputStream)1 Test (org.junit.Test)1