Package cn.bran.japid.template

Examples of cn.bran.japid.template.RenderResult


    try {
      // String methodName = "render";
      Constructor<T> ctor = c.getConstructor(StringBuilder.class);
      StringBuilder sb = new StringBuilder(8000);
      T t = ctor.newInstance(sb);
      RenderResult rr = (RenderResult) render(t, args);
      JapidFlags.logTimeLogs(t);
      return rr;
    } catch (NoSuchMethodException e) {
      throw new RuntimeException("Could not match the arguments with the template args.");
    } catch (InstantiationException e) {
View Full Code Here


    try {
      // String methodName = "render";
      Constructor<T> ctor = c.getConstructor(StringBuilder.class);
      StringBuilder sb = new StringBuilder(8000);
      JapidTemplateBaseWithoutPlay t = ctor.newInstance(sb);
      RenderResult rr = (RenderResult) renderWithNamedArgs(t, args);
      JapidFlags.logTimeLogs(t);
      return rr;
    } catch (NoSuchMethodException e) {
      throw new RuntimeException("Could not match the arguments with the template args.");
    } catch (InstantiationException e) {
View Full Code Here

  private static final String KEY1 = "key1";

  @Test
  public void testSimpleExpiration() throws ShouldRefreshException {
    RenderResultCache.setAltCache(new AltCacheSimpleImpl());
    RenderResult rr = new RenderResult(null, null, 0);
    RenderResultCache.set(KEY1, rr, "2s");
    RenderResult rrr;
    rrr = RenderResultCache.get(KEY1);
    assertNotNull(rrr);
    waitfor(3000);
    rrr = RenderResultCache.get(KEY1);
    assertNull(rrr);
View Full Code Here

  @Test
  public void testReadThruWithThread() throws ShouldRefreshException {
    assertFalse(RenderResultCache.shouldIgnoreCache());
    RenderResultCache.setAltCache(new AltCacheSimpleImpl());
    RenderResult rr = new RenderResult(null, null, 0);
    RenderResultCache.set(KEY1, rr, "4s");
    RenderResultCache.setIgnoreCache(true);
    RenderResult rrr = RenderResultCache.get(KEY1);
    assertNull(rrr);

    final AtomicBoolean b = new AtomicBoolean(false);

    Thread t = new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          RenderResult rrr = RenderResultCache.get(KEY1);
          b.set(rrr != null);
        } catch (ShouldRefreshException e) {
          fail();
        }
       
View Full Code Here

  }

  @Test
  public void testExpirationSoon() {
    RenderResultCache.setAltCache(new AltCacheSimpleImpl());
    RenderResult rr = new RenderResult(null, null, 0);
    RenderResultCache.set(KEY1, rr, "2s");
    RenderResult rrr;
    try {
      rrr = RenderResultCache.get(KEY1);
      assertNotNull(rrr);
    } catch (ShouldRefreshException e1) {
      throw new RuntimeException(e1);
    }

    waitfor(1500);
    try {
      rrr = RenderResultCache.get(KEY1);
    } catch (ShouldRefreshException e) {
      assertNotNull(e.renderResult);
    }

    final AtomicBoolean b = new AtomicBoolean(false);
    Thread t = new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          RenderResult rrr = RenderResultCache.get(KEY1);
          b.set(rrr != null);
        } catch (ShouldRefreshException e) {
          fail();
        }
       
View Full Code Here

  }

  @Test
  public void test11sconds() {
    RenderResultCache.setAltCache(new AltCacheSimpleImpl());
    RenderResult rr = new RenderResult(null, null, 0);
    RenderResultCache.set(KEY1, rr, "11s");
    RenderResult rrr;
    try {
      rrr = RenderResultCache.get(KEY1);
      assertNotNull(rrr);
    } catch (ShouldRefreshException e1) {
      throw new RuntimeException(e1);
View Full Code Here

public class ControllerUtilsTest {

  @Test
  public void testRender() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    RenderResult render;
   
    render = (RenderResult) RenderInvokerUtils.render(new Foo(null), "hi", new Integer(12));
    assertNotNull(render);

    render = (RenderResult) RenderInvokerUtils.render(new Foo(null), "hi", 12);
View Full Code Here

   * @throws IllegalArgumentException
   *
   */
  @Test
  public void testSingleNull() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    RenderResult render;
    // if cast to Object, the null is treated as an argument.
    // Otherwise the varargs is set to null.
    render = (RenderResult) RenderInvokerUtils.render(new Foo2(null), (Object)null);
    assertNotNull(render);
  }
View Full Code Here

   * @throws IllegalArgumentException
   *
   */
  @Test
  public void testEmptyArgs() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    RenderResult render;
    render = (RenderResult) RenderInvokerUtils.render(new Bar(null));
    assertNotNull(render);
  }
View Full Code Here

    @Override
    protected void doLayout() {
    }
   
    public RenderResult render(String str, Integer i) {
      return new RenderResult();
    }
View Full Code Here

TOP

Related Classes of cn.bran.japid.template.RenderResult

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.