Exemplo n.º 1
0
 @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();
   }
 }
Exemplo n.º 2
0
 @Test
 public void emptyContext() throws Exception {
   RenderingContext ctx = RenderingContext.CtxBuilder.get();
   try (Closeable wrapped = ctx.wrap().open()) {
     assertNull(ctx.getParameter(PARAM));
   }
 }
Exemplo n.º 3
0
 @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);
   }
 }
Exemplo n.º 4
0
 @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();
   }
 }