Package com.granule

Examples of com.granule.CompressorSettings


import junit.framework.TestCase;

public class CompressSettingsTest extends TestCase {

  public void testAddPath() {
    CompressorSettings settings = getSettings(CompressorSettings.CLOSURE_ADD_PATH_KEY
        + " = js/My Samples=,\"js\\test=1,benchmarks\",\"js/test=2,benchmarks\"");
    List<String> list = settings.getClosurePathes();
    assertEquals(list.get(0), "js/My Samples=");
    assertEquals(list.get(1), "js\\test=1,benchmarks");
    assertEquals(list.get(2), "js/test=2,benchmarks");
  }
View Full Code Here


    assertEquals(list.get(1), "js\\test=1,benchmarks");
    assertEquals(list.get(2), "js/test=2,benchmarks");
  }

  public void testOptionsAdding() {
    CompressorSettings settings = getSettings("");
    settings.setJsCompressMethod(CompressorSettings.CLOSURE_COMPILER_VALUE);
    try {
      String tagOptions=CompressorSettings.CLOSURE_ADD_PATH_KEY.replace(CompressorSettings.CLOSURE_COMPILER_VALUE+".", "") + "=\"js/My Samples2=\"";
      String preparedOptions = (new OptionsHandler()).handle(tagOptions, settings.getJsCompressMethod());
      settings.setOptions(preparedOptions);
    } catch (JSCompileException e) {
      // shouldn't happen as it in the memory
      throw new RuntimeException(e);
    }
    List<String> list = settings.getClosurePathes();
    assertEquals(list.get(0), "js/My Samples2=");
  }
View Full Code Here

    assertEquals(list.get(0), "js/My Samples2=");
  }

  private CompressorSettings getSettings(String s) {
    try {
      CompressorSettings settings = new CompressorSettings(getInputStream(s));
      return settings;
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
View Full Code Here

    }

    private int processFile(String filename, String webAppRootPath) {
      filename=PathUtils.clean(filename);
      int errorCount = 0;
        CompressorSettings settings = null;
        try {
            settings = TagCacheFactory.getCompressorSettings(webAppRootPath);
        } catch (IOException e) {
            logger.error("Could not load settings", e);
            errorCount++;
            return errorCount;
        }
        String servletName = settings.getContextRoot();
        if (servletName!=null&&!servletName.startsWith("/"))
            servletName = "/" + servletName;
        IRequestProxy request = new SimpleRequestProxy(webAppRootPath, servletName);
    
        System.out.println("Processing file "+filename);
View Full Code Here

            logger.warn("Rebuilding from dublicate id");
            needRebuildCache = true;
          }
          CachedBundle cs = new CachedBundle();
          cs.loadFromJSON(obj, cacheFolder);
          CompressorSettings settings = TagCacheFactory
              .getCompressorSettings(context.getRealPath("/"));
          if (cs.getOptions() != null)
            settings.setOptions(cs.getOptions());
          String signature = generateSignature(settings, cs
              .getFragments(), cs.getOptions(), cs.isScript());
          signatureToId.put(signature, id);
          bundles.put(id, cs);
        } catch (Exception e) {
View Full Code Here

           throw new JSCompileException("Granule cache was loaded not on the server start-up. Recommended to add the parameter <load-on-startup>1<load-on-startup> into servlet configuration in web.xml.");
        return instance;
    }

    public static void init(ServletContext context) throws IOException {
        CompressorSettings settings = initInstance(context.getRealPath("/"));
        instance.initWeb(context, settings);
    }
View Full Code Here

        CompressorSettings settings = initInstance(context.getRealPath("/"));
        instance.initWeb(context, settings);
    }

    private static CompressorSettings initInstance(String rootPath) throws IOException {
        CompressorSettings settings = getCompressorSettings(rootPath);
        if (settings.getCache().equals(CompressorSettings.DISK_CACHE_VALUE))
            instance = FileCache.getInstance();
        else instance = MemoryCache.getInstance();
        return settings;
    }
View Full Code Here

        synchronized (settings) {
            if (!settingsLoaded) {
                loadSettings(rootPath, null, false);
            }
        }
        return new CompressorSettings(settings);
    }
View Full Code Here

        synchronized (settings) {
            if (!settingsLoaded) {
                loadSettings(rootPath, addition, true);
            }
        }
        return new CompressorSettings(settings);
    }
View Full Code Here

TOP

Related Classes of com.granule.CompressorSettings

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.