Package com.sun.enterprise.ee.synchronization.store

Examples of com.sun.enterprise.ee.synchronization.store.SynchronizationMemento


        Command cGet = getGetCommand();
        cGet.execute();
        _response = (SynchronizationResponse) cGet.getResult();
       
        // saves the previous state before rendering the new response
        _memento = new SynchronizationMemento(_response);
        _memento.saveState();

        // renders the response into the local file cache
        Command cProcess = getResponseCommand();
        cProcess.execute();
View Full Code Here


    private void testSaveRollback(boolean dir) {

        try {
            // synchronization memento
            SynchronizationResponse res = getResponseObj(dir, null);
            SynchronizationMemento m = new SynchronizationMemento(res);
            SynchronizationRequest[] req = res.getReply();
            SynchronizationRequest r = req[0];

            // synchronized file
            File f = new File( r.getFileName() );

            if (dir) {
                System.out.println("Memento Directory: " + f.getPath());
            } else {
                System.out.println("Memento File: " + f.getPath());
            }

            // ensures that the file exists
            assertTrue( f.exists() );

            // create a backup
            m.saveState();

            // ensures that the backup exists
            assertTrue( getBackupFile(f).exists() );
            System.out.println("Memento after backup: "
                + getBackupFile(f).getPath());

            // rollback
            m.rollback();

            // ensures that the original file exists
            assertTrue( f.exists() );
            assertFalse( getBackupFile(f).exists() );
            System.out.println("Memento after rollback: " + f.getPath());
View Full Code Here

            File tmpFile = new File(tmpName);
            tmpFile.mkdirs();

            // synchronization memento
            SynchronizationResponse res = getResponseObj(true, tmpName);
            SynchronizationMemento m = new SynchronizationMemento(res);

            // populate the dir
            RandomDirTree tree = new RandomDirTree(tmpName);
            tree.populate(true);
            InventoryMgr iMgr = new InventoryMgr(tmpFile);
            List inventory = iMgr.getInventory();

            System.out.println("Number of files in directory [" +tmpName+ "]: "
                + inventory.size());

            // saves a snapshot in memento
            m.saveState();

            // populates the new dir
            RandomFileMover mover =
                new RandomFileMover(getBackupFile(tmpFile),tmpFile,copyEnabled);
            mover.move();
            List moved = mover.getMoveList();
            List copied = mover.getCopyList();

            System.out.println("Number of files moved to directory ["
                + getBackupFile(tmpFile) + "]: " + moved.size());
       
            System.out.println("Number of files copied to directory ["
                + getBackupFile(tmpFile) + "]: " + copied.size());
       
            // merges the two trees
            m.commit();

            List newInventory = iMgr.getInventory();

            System.out.println("Number of files in directory ["
                + tmpFile + "]: " + newInventory.size());
View Full Code Here

TOP

Related Classes of com.sun.enterprise.ee.synchronization.store.SynchronizationMemento

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.