use of cn.bran.japid.template.RenderResult in project Japid by branaway.
the class RenderResultCacheTest method testExpirationSoon.
@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();
}
}
});
t.start();
waitfor(100);
assertTrue(b.get());
// the second time in refreshing zone should get the item
try {
rrr = RenderResultCache.get(KEY1);
assertNotNull(rrr);
} catch (ShouldRefreshException e) {
fail("should not get this");
}
}
use of cn.bran.japid.template.RenderResult in project Japid by branaway.
the class ControllerUtilsTest method testRender.
@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);
assertNotNull(render);
render = (RenderResult) RenderInvokerUtils.render(new Foo(null), "hi", null);
assertNotNull(render);
try {
render = (RenderResult) RenderInvokerUtils.render(new Foo2(null), 12);
} catch (Exception e) {
System.out.println(e);
}
render = (RenderResult) RenderInvokerUtils.render(new Foo2(null), new ArrayList<String>());
assertNotNull(render);
testSingleNull();
testEmptyArgs();
}
use of cn.bran.japid.template.RenderResult in project Japid by branaway.
the class ControllerUtilsTest method testSingleNull.
/**
* @throws InvocationTargetException
* @throws IllegalAccessException
* @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);
}
Aggregations