@@ -0,0 +1,2335 @@
+package com.iluwatar.composite;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.PrintStream;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0A%0A/**%0A * Date: 12/11/15 - 8:12 PM%0A *%0A * @author Jeroen Meulemeester%0A */%0Apublic class MessengerTest %7B%0A%0A  /**%0A   * The buffer used to capture every write to %7B@link System#out%7D%0A   */%0A  private ByteArrayOutputStream stdOutBuffer = new ByteArrayOutputStream();%0A%0A  /**%0A   * Keep the original std-out so it can be restored after the test%0A   */%0A  private final PrintStream realStdOut = System.out;%0A%0A  /**%0A   * Inject the mocked std-out %7B@link PrintStream%7D into the %7B@link System%7D class before each test%0A   */%0A  @Before%0A  public void setUp() %7B%0A    this.stdOutBuffer = new ByteArrayOutputStream();%0A    System.setOut(new PrintStream(stdOutBuffer));%0A  %7D%0A%0A  /**%0A   * Removed the mocked std-out %7B@link PrintStream%7D again from the %7B@link System%7D class%0A   */%0A  @After%0A  public void tearDown() %7B%0A    System.setOut(realStdOut);%0A  %7D%0A%0A  /**%0A   * Test the message from the orcs%0A   */%0A  @Test%0A  public void testMessageFromOrcs() %7B%0A    final Messenger messenger = new Messenger();%0A    testMessage(%0A        messenger.messageFromOrcs(),%0A        %22Where there is a whip there is a way.%22%0A    );%0A  %7D%0A%0A  /**%0A   * Test the message from the elves%0A   */%0A  @Test%0A  public void testMessageFromElves() %7B%0A    final Messenger messenger = new Messenger();%0A    testMessage(%0A        messenger.messageFromElves(),%0A        %22Much wind pours from your mouth.%22%0A    );%0A  %7D%0A%0A  /**%0A   * Test if the given composed message matches the expected message%0A   *%0A   * @param composedMessage The composed message, received from the messenger%0A   * @param message         The expected message%0A   */%0A  private void testMessage(final LetterComposite composedMessage, final String message) %7B%0A    // Test is the composed message has the correct number of words%0A    final String%5B%5D words = message.split(%22 %22);%0A    assertNotNull(composedMessage);%0A    assertEquals(words.length, composedMessage.count());%0A%0A    // Print the message to the mocked stdOut ...%0A    composedMessage.print();%0A%0A    // ... and verify if the message matches with the expected one%0A    assertEquals(message, new String(this.stdOutBuffer.toByteArray()).trim());%0A  %7D%0A%0A%7D%0A

Add proper unit tests for composite pattern