View Javadoc

1   package org.apache.maven.surefire.report;
2   
3   import java.util.concurrent.Callable;
4   import java.util.concurrent.ExecutionException;
5   import java.util.concurrent.FutureTask;
6   
7   /*
8   * Licensed to the Apache Software Foundation (ASF) under one
9   * or more contributor license agreements.  See the NOTICE file
10  * distributed with this work for additional information
11  * regarding copyright ownership.  The ASF licenses this file
12  * to you under the Apache License, Version 2.0 (the
13  * "License"); you may not use this file except in compliance
14  * with the License.  You may obtain a copy of the License at
15  *
16  *     http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing,
19  * software distributed under the License is distributed on an
20  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21  * KIND, either express or implied.  See the License for the
22  * specific language governing permissions and limitations
23  * under the License.
24  */
25  class RunnableTestClass1
26      implements Callable<Object>
27  
28  {
29      public Object call()
30          throws Exception
31      {
32          doSomethingThatThrows();
33          return "yo";
34      }
35  
36      private void doSomethingThatThrows()
37          throws ExecutionException
38      {
39          RunnableTestClass2 rt2 = new RunnableTestClass2();
40          FutureTask<Object> futureTask = new FutureTask<Object>( rt2 );
41          new Thread( futureTask ).start();
42          try
43          {
44              futureTask.get();
45          }
46          catch ( InterruptedException e )
47          {
48              throw new RuntimeException();
49          }
50      }
51  
52  }