Package freemarker.template

Examples of freemarker.template.TemplateHashModel


     * @throws TemplateModelException If something goes wrong.
     */
    @Test
    public void testCreateServletFreemarkerRequest() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        PrintWriter writer = new PrintWriter(new StringWriter());
        HttpServletRequest httpRequest = createMock(HttpServletRequest.class);
        HttpServletResponse httpResponse = createMock(HttpServletResponse.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());

        replay(httpRequest, httpResponse, objectWrapper);
        HttpRequestHashModel requestHashModel = new HttpRequestHashModel(httpRequest, httpResponse, objectWrapper);
        expect(model.get("Request")).andReturn(requestHashModel);

        replay(template, model, applicationContext);
        Environment env = new Environment(template, model, writer);
        Locale locale = Locale.ITALY;
        env.setLocale(locale);
View Full Code Here


     * Tests {@link FreemarkerRequest#getPrintWriter()}.
     */
    @Test
    public void testGetPrintWriterPrintWriter() {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        PrintWriter writer = new PrintWriter(new StringWriter());
        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        replay(template, model);
        Environment env = new Environment(template, model, writer);
        Locale locale = Locale.ITALY;
View Full Code Here

     * @throws TemplateModelException If something goes wrong.
     */
    @Test
    public void testRemoveValue() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateModel valueModel = createMock(TemplateModel.class);
        Configuration configuration = createMock(Configuration.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(model.get("key")).andReturn(null);
        expect(template.getConfiguration()).andReturn(configuration);
        expect(configuration.getSharedVariable("key")).andReturn(null);

        replay(template, model, valueModel, configuration);
        Environment env = new Environment(template, model, writer);
View Full Code Here

     * Test method for {@link EnvironmentScopeExtractor#getKeys()}.
     */
    @Test
    public void testGetKeys() {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateModel valueModel = createMock(TemplateModel.class);
        Configuration configuration = createMock(Configuration.class);
        Set<String> names = new HashSet<String>();
        names.add("testGetKeys");
       
View Full Code Here

     * @throws TemplateModelException If something goes wrong.
     */
    @Test
    public void testGetValue() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateScalarModel valueModel = createMock(TemplateScalarModel.class);
        Configuration configuration = createMock(Configuration.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

View Full Code Here

     * @throws TemplateModelException If something goes wrong.
     */
    @Test
    public void testGetValueNull() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateScalarModel valueModel = createMock(TemplateScalarModel.class);
        Configuration configuration = createMock(Configuration.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(model.get("key")).andReturn(null);
        expect(template.getConfiguration()).andReturn(configuration);
        expect(configuration.getSharedVariable("key")).andReturn(null);

        replay(template, model, valueModel, configuration, objectWrapper);
        Environment env = new Environment(template, model, writer);
View Full Code Here

     * @throws TemplateModelException If something goes wrong.
     */
    @Test(expected = FreemarkerRequestException.class)
    public void testGetValueException() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateScalarModel valueModel = createMock(TemplateScalarModel.class);
        Configuration configuration = createMock(Configuration.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(model.get("key")).andThrow(new TemplateModelException());

        replay(template, model, valueModel, configuration, objectWrapper);
        try {
            Environment env = new Environment(template, model, writer);
            EnvironmentScopeExtractor extractor = new EnvironmentScopeExtractor(env);
View Full Code Here

     * @throws TemplateModelException If something goes wrong.
     */
    @Test
    public void testSetValue() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateModel valueModel = createMock(TemplateModel.class);
        Configuration configuration = createMock(Configuration.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

View Full Code Here

     * @throws TemplateModelException If something goes wrong.
     */
    @Test(expected = FreemarkerRequestException.class)
    public void testSetValueException() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateModel valueModel = createMock(TemplateModel.class);
        Configuration configuration = createMock(Configuration.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

View Full Code Here

     */
    @SuppressWarnings("unchecked")
    @Test
    public void testKeySet() {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        Configuration configuration = createMock(Configuration.class);
        Set<String> names = createMock(Set.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
View Full Code Here

TOP

Related Classes of freemarker.template.TemplateHashModel

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.