public void testCompleteOnTimeout_completed(){
  for (  Integer v1 : new Integer[]{1,null}) {
    CompletableFuture<Integer> f=new CompletableFuture<>();
    CompletableFuture<Integer> g=new CompletableFuture<>();
    long startTime=System.nanoTime();
    f.complete(v1);
    assertSame(f,f.completeOnTimeout(-1,LONG_DELAY_MS,MILLISECONDS));
    assertSame(g,g.completeOnTimeout(-1,LONG_DELAY_MS,MILLISECONDS));
    g.complete(v1);
    checkCompletedNormally(f,v1);
    checkCompletedNormally(g,v1);
    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS / 2);
  }
}

public void testCompleteOnTimeout_completed ( ) { for ( Integer v1 : new Integer [ ] { 1 , null } ) { CompletableFuture < Integer > f = new CompletableFuture < > ( ) ; CompletableFuture < Integer > g = new CompletableFuture < > ( ) ; long startTime = System . nanoTime ( ) ; f . complete ( v1 ) ; assertSame ( f , f . completeOnTimeout ( - 1 , LONG_DELAY_MS , MILLISECONDS ) ) ; assertSame ( g , g . completeOnTimeout ( - 1 , LONG_DELAY_MS , MILLISECONDS ) ) ; g . complete ( v1 ) ; checkCompletedNormally ( f , v1 ) ; checkCompletedNormally ( g , v1 ) ; assertTrue ( millisElapsedSince ( startTime ) < LONG_DELAY_MS / 2 ) ; } }
completeontimeout has no effect if completed within timeout
