@@ -0,0 +1,1842 @@
+/*%0A * Copyright 2017 Yi-Kun Yang.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.allnix.core;%0A%0Aimport java.io.IOException;%0Aimport java.io.UncheckedIOException;%0Aimport java.util.concurrent.CompletableFuture;%0Aimport java.util.concurrent.CompletionException;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.BeforeClass;%0Aimport org.testng.annotations.Test;%0A%0A/**%0A *%0A * @author Yi-Kun Yang &lt;ykyang at gmail.com&gt;%0A */%0Apublic class TestThread %7B%0A%0A  private ExecutorService es;%0A%0A  @BeforeClass%0A  public void beforeClass() %7B%0A    es = Executors.newCachedThreadPool();%0A  %7D%0A%0A  /**%0A   * Test the wrapping of exception in thread%0A   */%0A  @Test%0A  public void testException() %7B%0A    Runnable task = () -%3E %7B%0A      try %7B%0A        throw new IOException();%0A      %7D catch (IOException e) %7B%0A        throw new UncheckedIOException(e);%0A      %7D%0A    %7D;%0A%0A    CompletableFuture%3CVoid%3E future = CompletableFuture.runAsync(task, es);%0A    try %7B%0A      future.join();%0A      Assert.fail();%0A    %7D catch (CompletionException e) %7B%0A      Throwable throwable = e.getCause();%0A      Assert.assertTrue(throwable instanceof UncheckedIOException);%0A      %0A      throwable = throwable.getCause();%0A      Assert.assertTrue(throwable instanceof IOException);%0A    %7D%0A  %7D%0A%0A%7D%0A

Test thread exception handling