Package cambridge

Source Code of cambridge.SetDirectiveTest

package cambridge;

import cambridge.model.Fragment;
import cambridge.model.FragmentList;
import cambridge.model.TemplateDocument;
import cambridge.parser.TemplateParser;
import cambridge.parser.TemplateTokenizer;
import cambridge.parser.expressions.MapExpressionContext;
import org.junit.Test;

import java.io.StringWriter;

import static org.junit.Assert.assertEquals;

/**
* @author Erdinc Yilmazel
* Date: May 18, 2010
* Time: 9:17:38 AM
*/
public class SetDirectiveTest {
   @Test
   public void testSetDirective() throws Exception {
      TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("set.html"));
      TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
      TemplateDocument doc = parser.parse();
      FragmentList fragmentList = doc.normalize();
      MapExpressionContext context = new MapExpressionContext();
      StringWriter out = new StringWriter();
      for (Fragment f : fragmentList) {
         f.eval(context, out);
      }

      assertEquals("Hello World", out.toString());
   }
}
TOP

Related Classes of cambridge.SetDirectiveTest

TOP
Copyright © 2018 www.massapi.com. 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.