Package org.jboss.virtual.plugins.cache

Examples of org.jboss.virtual.plugins.cache.CombinedVFSCache


      editor.setAsText("file:/home/csams/tmp/sym_deploy");

      //this should resolve as file:/home/csams/tmp/deploy
      URL dir = (URL) editor.getValue();

      CombinedVFSCache cache = new CombinedVFSCache();
      VFSCacheFactory.setInstance(cache);
      VFSCache realCache = new NoopVFSCache();
      realCache.start();
      cache.setRealCache(realCache);

      try
      {
        cache.setPermanentRoots(Collections.<URL, ExceptionHandler>singletonMap(dir, null));
        cache.start();
       
        URL sub = new URL(resourceName);
        VFS dirVFS = VFS.getVFS(dir);

        VirtualFile rootFile = VFS.getRoot(dir);
        System.out.println(rootFile);

        VirtualFile subFile1 = VFS.getRoot(sub);
        System.out.println(subFile1);

        VirtualFile subFile2 = VFS.getRoot(sub);
        System.out.println(subFile2);

        //they should have parents, and those parents' VFSContexts should be the one stored as permanentRoot
        assertNotNull(subFile1.getParent());
        assertNotNull(subFile2.getParent());

        //the parent VFSContext of the ZipEntryContext should be the VFSContext of the permanentRoot
        assertEquals(rootFile.getVFS(), dirVFS);
        assertEquals(rootFile.getVFS(), subFile1.getParent().getVFS());
        assertEquals(rootFile.getVFS(), subFile2.getParent().getVFS());

        //the VFSContexts also should be the same
        assertEquals(subFile1.getVFS(), subFile2.getVFS());
      }
      finally
      {
         VFSCacheFactory.setInstance(null);
         if(cache != null)
           cache.stop();
      }
   }
View Full Code Here


         return;

      assertNotNull(testPath);
      assertNotNull(testName);

      CombinedVFSCache cache = new CombinedVFSCache();                          
      VFSCache realCache = new NoopVFSCache();
      realCache.start();
      cache.setRealCache(realCache);
      VFSCacheFactory.setInstance(cache);
      try
      {
         String rootText = StringPropertyReplacer.replaceProperties("${test.dir}");
         URL rootURL;
         if (useEditor)
         {
            URLEditor editor = new URLEditor();
            editor.setAsText(rootText);
            rootURL = (URL) editor.getValue();
         }
         else
         {
            rootURL = new URL("file://" + rootText);
         }
         cache.setPermanentRoots(Collections.<URL, ExceptionHandler>singletonMap(rootURL, null));
         cache.start();

         // setup VFS
         VFS vfs = VFS.getVFS(rootURL);
         VFSUtils.enableCopy(vfs);
         TrackingTempStore store = new TrackingTempStore(new MockTempStore(new Random().nextLong()));
         vfs.setTempStore(store);

         try
         {
            URL directRootURL = new URL("file://" + rootText);
            VirtualFile root = VFS.getRoot(directRootURL);
            // assertEquals(vfs, root.getVFS()); // this is actually the real cause
            VirtualFile file = root.getChild(testPath);
            assertNotNull(file);
            assertTrue(file.getSize() > 0);
            assertCopies(store);
            URL url = file.toURL();
            URLConnection conn = url.openConnection();
            assertCopies(store);
            assertEquals(file.getLastModified(), conn.getLastModified());

            directRootURL = new URL("vfszip://" + rootText + testPath);
            conn = directRootURL.openConnection();
            assertCopies(store);
            assertEquals(file.getLastModified(), conn.getLastModified());
         }
         finally
         {
            store.clear();
         }
      }
      finally
      {
         VFSCacheFactory.setInstance(null);
         cache.stop();
      }
   }
View Full Code Here

         return;

      assertNotNull(testPath);
      assertNotNull(testName);

      CombinedVFSCache cache = new CombinedVFSCache();                          
      VFSCache realCache = new NoopVFSCache();
      realCache.start();
      cache.setRealCache(realCache);
      VFSCacheFactory.setInstance(cache);
      try
      {
         String rootText = StringPropertyReplacer.replaceProperties("${test.dir}");
         URL rootURL;
         if (useEditor)
         {
            URLEditor editor = new URLEditor();
            editor.setAsText(rootText);
            rootURL = (URL) editor.getValue();
         }
         else
         {
            rootURL = new URL("file://" + rootText);
         }
         cache.setPermanentRoots(Collections.<URL, ExceptionHandler>singletonMap(rootURL, null));
         cache.start();

         // setup VFS
         VFS vfs = VFS.getVFS(rootURL);
         VFSUtils.enableCopy(vfs);
         TrackingTempStore store = new TrackingTempStore(new MockTempStore(new Random().nextLong()));
         vfs.setTempStore(store);

         try
         {
            URL directRootURL = new URL("file://" + rootText);
            VirtualFile root = VFS.getRoot(directRootURL);
            // assertEquals(vfs, root.getVFS()); // this is actually the real cause
            VirtualFile file = root.getChild(testPath);
            assertNotNull(file);
            assertTrue(file.getSize() > 0);
            assertCopies(store);
            URL url = file.toURL();
            URLConnection conn = url.openConnection();
            assertCopies(store);
            assertEquals(file.getLastModified(), conn.getLastModified());

            directRootURL = new URL("vfszip://" + rootText + testPath);
            conn = directRootURL.openConnection();
            assertCopies(store);
            assertEquals(file.getLastModified(), conn.getLastModified());
         }
         finally
         {
            store.clear();
         }
      }
      finally
      {
         VFSCacheFactory.setInstance(null);
         cache.stop();
      }
   }
View Full Code Here

   @Override
   protected void configureCache(VFSCache cache) throws Exception
   {
      if (cache instanceof CombinedVFSCache)
      {
         CombinedVFSCache cvc = CombinedVFSCache.class.cast(cache);

         URL url = getResource("/vfs/test/nested");
         Map<URL, ExceptionHandler> map = Collections.singletonMap(url, null);
         cvc.setPermanentRoots(map);

         IterableTimedVFSCache realCache = new IterableTimedVFSCache(5);
         realCache.start();
         cvc.setRealCache(realCache);

         cvc.create();
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.virtual.plugins.cache.CombinedVFSCache

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.