Package com.granule.utils

Examples of com.granule.utils.OptionsHandler$Pair


* Date: 13.08.2010
* Time: 19:33:29
*/
public class OptionsHandlerTest extends TestCase {
    public void testOptions() {
        OptionsHandler oh = new OptionsHandler();
        String method = "closure-compiler";

        String s = "aaaaa";
        String expected= "closure-compiler.aaaaa\n";
        assertEquals(oh.handle(s, method), expected);

        s="--aa";
        expected = "closure-compiler.aa\n";
        assertEquals(oh.handle(s, method), expected);

        s = "--aa true";
        expected = "closure-compiler.aa=true\n";
        assertEquals(oh.handle(s, method), expected);

        s = "--aa true --bb 15 --ccc                          --compilation_level=SIMPLE_OPTIMIZATIONS";
        expected = "closure-compiler.aa=true \n"+
                "closure-compiler.bb=15 \n"+
                "closure-compiler.ccc=                         \n"+
                "closure-compiler.compilation_level=SIMPLE_OPTIMIZATIONS\n";
        assertEquals(oh.handle(s, method), expected);

        s = "--aa \"aa\"";
        expected = "closure-compiler.aa=\"aa\"\n";
        assertEquals(oh.handle(s, method), expected);

        s = "--aa \"aa aa bb --cc 1589 4477";
        expected = "closure-compiler.aa=\"aa aa bb --cc 1589 4477\n";
        assertEquals(oh.handle(s, method), expected);

        s = "--aa 'aa'";
        expected = "closure-compiler.aa='aa'\n";
        assertEquals(oh.handle(s, method), expected);

        s = "--aa 'aa--/asas/ssss' --c true";
        expected = "closure-compiler.aa='aa--/asas/ssss' \nclosure-compiler.c=true\n";
        assertEquals(oh.handle(s, method), expected);

        s = "--aa \"aa--/asas/ssss\" --c true";
        expected = "closure-compiler.aa=\"aa--/asas/ssss\" \nclosure-compiler.c=true\n";
        assertEquals(oh.handle(s, method), expected);
    }
View Full Code Here


  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);
    }
View Full Code Here

            // JavaScript processing
            String opts = null;
            if (method != null)
                opts = CompressorSettings.JS_COMPRESS_METHOD_KEY + "=" + method + "\n";
            if (options != null) {
                String s = (new OptionsHandler()).handle(options, method == null ? settings.getJsCompressMethod() :
                        method);
                if (opts != null)
                    opts += s;
                else opts = s;
            }
View Full Code Here

TOP

Related Classes of com.granule.utils.OptionsHandler$Pair

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.