Java class for stateful-timeoutType complex type.
The following schema fragment specifies the expected content contained within this class.
<complexType name="stateful-timeoutType"> <complexContent> <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> <sequence> <element name="timeout" type="{http://java.sun.com/xml/ns/javaee}xsdIntegerType"/> <element name="unit" type="{http://java.sun.com/xml/ns/javaee}time-unit-typeType"/> </sequence> <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" /> </restriction> </complexContent> </complexType>
The nested class Task should be extended by users of this class to obtain call back notification of expires.
public static class HasGlobalLongTimeout { @Rule public Timeout globalTimeout= new Timeout(20); @Test public void run1() throws InterruptedException { Thread.sleep(100); } @Test public void infiniteLoop() { while (true) {} } }
Each test is run in a new thread. If the specified timeout elapses before the test completes, its execution is interrupted via {@link Thread#interrupt()}. This happens in interruptable I/O and locks, and methods in {@link Object}and {@link Thread} throwing {@link InterruptedException}.
A specified timeout of 0 will be interpreted as not set, however tests will still launch from separate threads. This can be useful for disabling timeouts in environments where they are dynamically set based on some property. @since 4.7
Typically, you won't use this class explicitly. Instead use timeout() method on Mockito class. See javadoc for {@link VerificationWithTimeout}
The nested class Task should be extended by users of this class to obtain call back notification of expiries. @author gregw
Timeout timeout = new Timeout("TestTimer"); Timestamp timeoutHandle = timeout.addTimeoutListener(new I_Timeout() { public void timeout(Object userData) { System.out.println("Timeout happened"); System.exit(0); } }, 2000L, null);JDK 1.2 or higher only. @author xmlBlaster@marcelruff.info @see org.xmlBlaster.test.classtest.TimeoutTest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|