Package webit.script

Examples of webit.script.Template


*/
public class FunctionLoopOverflowTest {

    @Test
    public void test() throws ResourceNotFoundException, IOException {
        Template template;
        ParseException exception;
        //
        exception = null;
        template = EngineManager.getTemplate("/loopTests/loopOverflow1.wit");
        try {
            template.reload();
        } catch (ParseException e) {
            exception = e;
        }
        assertNotNull(exception);

        //
        exception = null;
        template = EngineManager.getTemplate("/loopTests/loopOverflow2.wit");
        try {
            template.reload();
        } catch (ParseException e) {
            exception = e;
        }
        assertNotNull(exception);

        //
        exception = null;
        template = EngineManager.getTemplate("/loopTests/loopOverflow3.wit");
        try {
            template.reload();
        } catch (ParseException e) {
            exception = e;
        }
        assertNotNull(exception);

View Full Code Here


    private final Set<String> labelCache = new HashSet<String>();
    private int pointCount = 0;
   
    @Test
    public void test() throws ResourceNotFoundException {
        Template template = EngineManager.getTemplate("/debug.wit");
       
        template.merge(new DiscardOut());
       
        labelCache.clear();
        pointCount = 0;
        template.debug(KeyValuesUtil.EMPTY_KEY_VALUES, new DiscardOut(), new BreakPointListener() {

            public void onBreak(String label, Context context, Statement statement, Object result) {
                labelCache.add(label);
                pointCount ++;
            }
View Full Code Here

        mergeTemplate(templatePath, new OutputStreamOut(out, EngineManager.getEngine()));
    }

    public void mergeTemplate(String templatePath, Out out) throws ResourceNotFoundException {
        System.out.println("AUTO RUN: " + templatePath);
        Template template = EngineManager.getEngine().getTemplate(templatePath);
        Context context = template.merge(out);
        System.out.println("\tassert count: " + context.getLocal(webit.script.tools.testunit.AssertGlobalRegister.ASSERT_COUNT_KEY));
    }
View Full Code Here

    public void test() throws ResourceNotFoundException {
        Engine engine = EngineManager.getEngine();
        DiscardOut out = new DiscardOut();

        engine.setTrimCodeBlockBlankLine(true);
        Template template = engine.getTemplate("/trimBlankLine.wit");

        Map<String, Object> param = new HashMap<String, Object>(4);
        param.put("trimBlankLine", true);
        template.merge(KeyValuesUtil.wrap(param), out);

        engine.setTrimCodeBlockBlankLine(false);
        template.reset();

        param.put("trimBlankLine", false);
        template.merge(KeyValuesUtil.wrap(param), out);

    }
View Full Code Here

    public void test() throws ResourceNotFoundException {
        Engine engine = EngineManager.getEngine();
        try {
            engine.setShareRootData(true);

            Template template = engine.getTemplate("/shareData.wit");
            template.reload();
            template.merge(KeyValuesUtil.wrap(new String[]{"v1", "v2"}, new Object[]{"V1", "V2"}), new DiscardOut());
        } finally {
            engine.setShareRootData(false);
        }
    }
View Full Code Here

public class ConetextTest {

    @Test
    public void test() throws ResourceNotFoundException {

        Template template = EngineManager.getTemplate("contextTest.wit");

        Context context = template.merge(new DiscardOut());

        Map map = new HashMap();

        assertEquals("a", context.get("a"));
View Full Code Here

    public void test() throws ResourceNotFoundException {
        Engine engine = EngineManager.getEngine();
        try {
            engine.setLooseVar(true);
           
            Template template = engine.getTemplate("/looseVar.wit");
            template.merge(new DiscardOut());
        } finally {
            engine.setLooseVar(false);
        }
    }
View Full Code Here

*/
public class HelloTest {

    @Test
    public void test() throws ResourceNotFoundException {
        Template template = EngineManager.getTemplate("/helloTest.wit");
        template.merge(new DiscardOut());
    }
View Full Code Here

                    throw new ScriptRuntimeException("Template param must be a Map.", paramsExpr);
                }
            } else {
                params = KeyValuesUtil.EMPTY_KEY_VALUES;
            }
            final Template preTemplate = context.template;
            final KeyValues preRootParams = context.rootParams;
            final Object[] preVars = context.vars;
            final VariantIndexer[] preIndexers = context.indexers;
            final int preIndexer = context.indexer;
            try {
                Template template = engine.getTemplate(myTemplateName, String.valueOf(templateName));
                context.template = template;
                context.rootParams = engine.isShareRootData() ? KeyValuesUtil.wrap(preRootParams, params) : params;
                template.merge(context, params);
                if (export) {
                    Map<String, Object> result = new HashMap<String, Object>();
                    context.exportTo(result);
                    return result;
                }
View Full Code Here

        mergeTemplate(templatePath, new OutputStreamOut(out, EngineManager.getEngine()));
    }
   
    public void mergeTemplate(String templatePath, Out out) throws ResourceNotFoundException {
        System.out.println("AUTO RUN: " + templatePath);
        Template template = EngineManager.getEngine().getTemplate(templatePath);
        try {
            Context context = template.merge(out);
            System.out.println("\tassert count: " + context.getLocal(AssertGlobalRegister.ASSERT_COUNT_KEY));
        } catch (ScriptRuntimeException e) {
            throw e;
        }
    }
View Full Code Here

TOP

Related Classes of webit.script.Template

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.