@Test public void testControlDepthDefaultIsRoot() throws IOException { RenderingContext ctx = RenderingContext.CtxBuilder.get(); try (Closeable wrappedRoot = ctx.wrap().controlDepth().open()) { try (Closeable wrappedChild = ctx.wrap().controlDepth().open()) { fail(); } catch (MaxDepthReachedException mdre) { // ok } } catch (MaxDepthReachedException mdre) { fail(); } }
@Test public void emptyContext() throws Exception { RenderingContext ctx = RenderingContext.CtxBuilder.get(); try (Closeable wrapped = ctx.wrap().open()) { assertNull(ctx.getParameter(PARAM)); } }
@Test public void subContext() throws Exception { RenderingContext ctx = RenderingContext.CtxBuilder.get(); try (Closeable wrapped = ctx.wrap().with(PARAM, VALUE1).open()) { Object value = ctx.getParameter(PARAM); assertNotNull(value); assertEquals(VALUE1, value); try (Closeable wrapped2 = ctx.wrap().with(PARAM, VALUE2).open()) { value = ctx.getParameter(PARAM); assertNotNull(value); assertEquals(VALUE2, value); } value = ctx.getParameter(PARAM); assertNotNull(value); assertEquals(VALUE1, value); } }
@Test public void testMaxControlDepth() throws IOException { RenderingContext ctx = RenderingContext.CtxBuilder.depth(DepthValues.max).get(); try (Closeable wrappedRoot = ctx.wrap().controlDepth().open()) { try (Closeable wrappedChild = ctx.wrap().controlDepth().open()) { try (Closeable wrappedMax = ctx.wrap().controlDepth().open()) { try (Closeable wrappedOver = ctx.wrap().controlDepth().open()) { fail(); } catch (MaxDepthReachedException mdre) { // ok } } catch (MaxDepthReachedException mdre) { fail(); } } catch (MaxDepthReachedException mdre) { fail(); } } catch (MaxDepthReachedException mdre) { fail(); } }