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.runtime.DefaultTemplateBindings;
import org.junit.Test;

import java.io.StringWriter;
import java.util.Map;

import static org.junit.Assert.assertEquals;

/**
* User: erdinc
* 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);
      TemplateDocument doc = parser.parse();
      FragmentList fragmentList = doc.normalize();
      Map<String, Object> prop = new DefaultTemplateBindings();
      StringWriter out = new StringWriter();
      for (Fragment f : fragmentList) {
         f.eval(prop, 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.