@Test
  public void testPrepare() throws Exception {
    Template template =
        new VelocityTemplate(
            new MockTemplateResource(_TEMPLATE_FILE_NAME),
            null,
            null,
            _velocityEngine,
            _templateContextHelper,
            60,
            false);

    template.put(_TEST_KEY, _TEST_VALUE);

    template.prepare(null);

    Object result = template.get(_TEST_VALUE);

    Assert.assertNotNull(result);

    Assert.assertTrue(result instanceof String);

    String stringResult = (String) result;

    Assert.assertEquals(_TEST_VALUE, stringResult);
  }
Exemplo n.º 2
0
  protected void mergeTemplate(Template template, UnsyncStringWriter unsyncStringWriter)
      throws Exception {

    VelocityTaglib velocityTaglib =
        (VelocityTaglib) template.get(PortletDisplayTemplateConstants.TAGLIB_LIFERAY);

    if (velocityTaglib != null) {
      velocityTaglib.setTemplate(template);
    }

    template.processTemplate(unsyncStringWriter);
  }