File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
src/test/java/org/embulk/output/sftp/utils Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 55import org .junit .Test ;
66
77import java .io .Closeable ;
8+ import java .util .concurrent .TimeoutException ;
89
910import static junit .framework .TestCase .fail ;
10- import static org .junit .Assert .assertTrue ;
11+ import static org .hamcrest .CoreMatchers .instanceOf ;
12+ import static org .hamcrest .MatcherAssert .assertThat ;
1113
1214public class TestTimeoutCloser
1315{
1416 @ Rule
1517 public EmbulkTestRuntime runtime = new EmbulkTestRuntime ();
1618
1719 @ Test
18- public void testTimeoutAndResume ()
20+ public void testTimeoutAndAbort ()
1921 {
2022 TimeoutCloser closer = new TimeoutCloser (new Closeable ()
2123 {
@@ -31,10 +33,13 @@ public void close()
3133 }
3234 });
3335 closer .timeout = 1 ;
34- long start = System .currentTimeMillis ();
35- closer .close ();
36- long duration = System .currentTimeMillis () - start ;
37- assertTrue ("longer than 1s" , duration > 1000 );
38- assertTrue ("shorter than 5s" , duration < 5000 );
36+ try {
37+ closer .close ();
38+ fail ("Should not finish" );
39+ }
40+ catch (Exception e ) {
41+ assertThat (e , instanceOf (RuntimeException .class ));
42+ assertThat (e .getCause (), instanceOf (TimeoutException .class ));
43+ }
3944 }
4045}
You can’t perform that action at this time.
0 commit comments