@Test public void testExecuteV() { final String something = "Something"; Callable<String> myCallable = new Callable<String>() { public String call() throws Exception { return something; } }; try { assertEquals(RunnableQueue.execute(myCallable), something); } catch (InterruptedException e) { throw new AssertionError("Thread unexpectedly interrupted during enqueue"); } catch (ExecutionException e) { throw new AssertionError("Runnable unexpectedly threw an exception"); } }
@Test public void testExecute() { final String[] putSomethingHere = new String[] {null}; final String something = "Something"; Runnable myRunnable = new Runnable() { public void run() { putSomethingHere[0] = something; } }; try { RunnableQueue.execute(myRunnable); } catch (InterruptedException e) { throw new AssertionError("Thread unexpectedly interrupted during enqueue"); } catch (ExecutionException e) { throw new AssertionError("Runnable unexpectedly threw an exception"); } assertEquals(putSomethingHere[0], something); }