Package org.apache.axiom.attachments

Examples of org.apache.axiom.attachments.AttachmentCacheMonitor


        Thread t = Thread.currentThread();

      
        // Get the AttachmentCacheMonitor and force it to remove files after
        // 10 seconds.
        AttachmentCacheMonitor acm = AttachmentCacheMonitor.getAttachmentCacheMonitor();
        int previousTime = acm.getTimeout();
       
        try {
            acm.setTimeout(10);


            File aFile = new File("A");
            aFile.createNewFile();
            String aFileName = aFile.getCanonicalPath();
            acm.register(aFileName);

            t.sleep(INTERVAL);

            File bFile = new File("B");
            bFile.createNewFile();
            String bFileName = bFile.getCanonicalPath();
            acm.register(bFileName);

            t.sleep(INTERVAL);

            acm.access(aFileName);

            // time since file A registration <= cached file expiration
            assertTrue("File A should still exist", aFile.exists());

            t.sleep(INTERVAL);

            acm.access(bFileName);

            // time since file B registration <= cached file expiration
            assertTrue("File B should still exist", bFile.exists());

            t.sleep(INTERVAL);

            File cFile = new File("C");
            cFile.createNewFile();
            String cFileName = cFile.getCanonicalPath();
            acm.register(cFileName);
            acm.access(bFileName);

            t.sleep(INTERVAL);

            acm.checkForAgedFiles();

            // time since file C registration <= cached file expiration
            assertTrue("File C should still exist", cFile.exists());

            t.sleep(10* INTERVAL)// Give task loop time to delete aged files


            // All files should be gone by now
            assertFalse("File A should no longer exist", aFile.exists());
            assertFalse("File B should no longer exist", bFile.exists());
            assertFalse("File C should no longer exist", cFile.exists());
        } finally {
      
            // Reset the timeout to the previous value so that no
            // other tests are affected
            acm.setTimeout(previousTime);
        }
    }
View Full Code Here


        Thread t = Thread.currentThread();

      
        // Get the AttachmentCacheMonitor and force it to remove files after
        // 10 seconds.
        AttachmentCacheMonitor acm = AttachmentCacheMonitor.getAttachmentCacheMonitor();
        int previousTime = acm.getTimeout();
       
        try {
            acm.setTimeout(10);


            File aFile = new File("A");
            aFile.createNewFile();
            String aFileName = aFile.getCanonicalPath();
            acm.register(aFileName);

            t.sleep(INTERVAL);

            File bFile = new File("B");
            bFile.createNewFile();
            String bFileName = bFile.getCanonicalPath();
            acm.register(bFileName);

            t.sleep(INTERVAL);

            acm.access(aFileName);

            // time since file A registration <= cached file expiration
            assertTrue("File A should still exist", aFile.exists());

            t.sleep(INTERVAL);

            acm.access(bFileName);

            // time since file B registration <= cached file expiration
            assertTrue("File B should still exist", bFile.exists());

            t.sleep(INTERVAL);

            File cFile = new File("C");
            cFile.createNewFile();
            String cFileName = cFile.getCanonicalPath();
            acm.register(cFileName);
            acm.access(bFileName);

            t.sleep(INTERVAL);

            acm.checkForAgedFiles();

            // time since file C registration <= cached file expiration
            assertTrue("File C should still exist", cFile.exists());

            t.sleep(10* INTERVAL)// Give task loop time to delete aged files


            // All files should be gone by now
            assertFalse("File A should no longer exist", aFile.exists());
            assertFalse("File B should no longer exist", bFile.exists());
            assertFalse("File C should no longer exist", cFile.exists());
        } finally {
      
            // Reset the timeout to the previous value so that no
            // other tests are affected
            acm.setTimeout(previousTime);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.attachments.AttachmentCacheMonitor

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.