### Question:
DecorateAllHandler extends TagHandler { public void apply(FaceletContext ctx, UIComponent parent) throws IOException { String templatePath = this.template.getValue(ctx); for (Object child : this.children) { try { if (child instanceof DecoratedChild) { ((DecoratedChild) child).apply(ctx, parent, templatePath); } else { ((FaceletHandler) child).apply(ctx, parent); } } catch (IOException e) { throw new TagAttributeException(this.tag, this.template, "Invalid path : " + templatePath); } } } DecorateAllHandler(TagConfig config); void apply(FaceletContext ctx, UIComponent parent);  }### Answer:
@Test public void shouldDecoreateSingleComponent() throws Exception { given(this.tagConfig.getNextHandler()).willReturn(this.component1); createDecorateAllHandlerAndApply(); verify(this.decoratedComponent1).apply(this.ctx, this.parent, TEMPLATE); }
@Test public void shouldDecorateMultipleComponent() throws Exception { CompositeFaceletHandler nextHandler = new CompositeFaceletHandler(new FaceletHandler[] { this.component1, this.component2 }); given(this.tagConfig.getNextHandler()).willReturn(nextHandler); createDecorateAllHandlerAndApply(); verify(this.decoratedComponent1).apply(this.ctx, this.parent, TEMPLATE); verify(this.decoratedComponent2).apply(this.ctx, this.parent, TEMPLATE); }
@Test public void shouldPreserveUnknown() throws Exception { FaceletHandler unknown1 = mockFaceletHandler("unknown1", Type.OTHER); FaceletHandler unknown2 = mockFaceletHandler("unknown2", Type.OTHER); CompositeFaceletHandler nextHandler = new CompositeFaceletHandler(new FaceletHandler[] { unknown1, this.component1, unknown2 }); given(this.tagConfig.getNextHandler()).willReturn(nextHandler); createDecorateAllHandlerAndApply(); InOrder inOrder = inOrder(unknown1, this.decoratedComponent1, unknown2); inOrder.verify(unknown1).apply(this.ctx, this.parent); inOrder.verify(this.decoratedComponent1).apply(this.ctx, this.parent, TEMPLATE); inOrder.verify(unknown2).apply(this.ctx, this.parent); }
@Test public void shouldWrapIOException() throws Exception { willThrow(new IOException()).given(this.decoratedComponent1).apply(this.ctx, this.parent, TEMPLATE); given(this.tagConfig.getNextHandler()).willReturn(this.component1); this.thrown.expect(TagAttributeException.class); this.thrown.expectMessage("Invalid path : template.xhtml"); createDecorateAllHandlerAndApply(); }