Package net.jodah.concurrentunit
Class ConcurrentTestCase
- java.lang.Object
-
- net.jodah.concurrentunit.ConcurrentTestCase
-
public abstract class ConcurrentTestCase extends Object
Convenience support class, wrapping aWaiter.
Copyright 2010-2016 the original author or authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License- Author:
- Jonathan Halterman
-
-
Constructor Summary
Constructors Constructor Description ConcurrentTestCase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidawait()protected voidawait(long delay)protected voidawait(long delay, int expectedResumes)protected voidawait(long delay, TimeUnit timeUnit)protected voidawait(long delay, TimeUnit timeUnit, int expectedResumes)protected voidresume()voidrethrow(Throwable reason)voidthreadAssertEquals(Object expected, Object actual)voidthreadAssertFalse(boolean b)voidthreadAssertNotNull(Object object)voidthreadAssertNull(Object x)voidthreadAssertTrue(boolean b)voidthreadFail()voidthreadFail(String reason)voidthreadFail(Throwable reason)
-
-
-
Method Detail
-
threadAssertEquals
public void threadAssertEquals(Object expected, Object actual)
- Parameters:
expected- the expected valueactual- the actual value- Throws:
AssertionError- when the assertion fails- See Also:
Waiter.assertEquals(Object, Object)
-
threadAssertFalse
public void threadAssertFalse(boolean b)
- Parameters:
b- boolean to test to be false- Throws:
AssertionError- when the assertion fails- See Also:
Asserts that the is false.
-
threadAssertNotNull
public void threadAssertNotNull(Object object)
- Parameters:
object- the object to test- Throws:
AssertionError- when the assertion fails- See Also:
Waiter.assertNotNull(Object)
-
threadAssertNull
public void threadAssertNull(Object x)
- Parameters:
x- the object to test- Throws:
AssertionError- when the assertion fails- See Also:
Waiter.assertNull(Object)
-
threadAssertTrue
public void threadAssertTrue(boolean b)
- Parameters:
b- boolean to test to be true- Throws:
AssertionError- when the assertion fails- See Also:
Waiter.assertTrue(boolean)
-
threadFail
public void threadFail()
- See Also:
Waiter.fail()
-
threadFail
public void threadFail(String reason)
- Parameters:
reason- the reason for failure- Throws:
AssertionError- when the assertion fails- See Also:
Waiter.fail(String)
-
threadFail
public void threadFail(Throwable reason)
- Parameters:
reason- the reason for failure- Throws:
AssertionError- wrapping thereason- See Also:
Waiter.fail(Throwable)
-
rethrow
public void rethrow(Throwable reason)
- Parameters:
reason- the reason for failure throws Throwable thefailure- See Also:
Waiter.rethrow(Throwable)
-
await
protected void await() throws TimeoutException, InterruptedException- Throws:
TimeoutException- if the operation times out while waitingInterruptedException- if the operations is interrupted while waitingAssertionError- if any assertion fails while waiting- See Also:
Waiter.await()
-
await
protected void await(long delay) throws TimeoutException, InterruptedException- Parameters:
delay- Delay to wait for- Throws:
TimeoutException- if the operation times out while waitingInterruptedException- if the operations is interrupted while waitingAssertionError- if any assertion fails while waiting- See Also:
Waiter.await(long)
-
await
protected void await(long delay, int expectedResumes) throws TimeoutException, InterruptedException- Parameters:
delay- Delay to wait forexpectedResumes- Number of timesresume()is expected to be called before the awaiting thread is resumed- Throws:
TimeoutException- if the operation times out while waitingInterruptedException- if the operations is interrupted while waitingAssertionError- if any assertion fails while waiting- See Also:
Waiter.await(long, int)
-
await
protected void await(long delay, TimeUnit timeUnit) throws TimeoutException, InterruptedException- Parameters:
delay- Delay to wait fortimeUnit- TimeUnit to delay for- Throws:
TimeoutException- if the operation times out while waitingInterruptedException- if the operations is interrupted while waitingAssertionError- if any assertion fails while waiting- See Also:
Waiter.await(long, TimeUnit)
-
await
protected void await(long delay, TimeUnit timeUnit, int expectedResumes) throws TimeoutException, InterruptedException- Parameters:
delay- Delay to wait fortimeUnit- TimeUnit to delay forexpectedResumes- Number of timesresume()is expected to be called before the awaiting thread is resumed- Throws:
TimeoutException- if the operation times out while waitingInterruptedException- if the operations is interrupted while waitingAssertionError- if any assertion fails while waiting- See Also:
Waiter.await(long, TimeUnit, int)
-
resume
protected void resume()
- See Also:
Waiter.resume()
-
-