/** * Causes this thread to call the named method, and asserts that the call returns the expected int * value. */ public void callAndAssertReturns(int expected, String methodName, Object... arguments) throws Exception { checkNotNull(methodName); checkNotNull(arguments); sendRequest(methodName, arguments); assertEquals(expected, getResponse(methodName).getResult()); }
/** * Causes this thread to call the named method, and asserts that the call throws the expected type * of throwable. */ public void callAndAssertThrows( Class<? extends Throwable> expected, String methodName, Object... arguments) throws Exception { checkNotNull(expected); checkNotNull(methodName); checkNotNull(arguments); sendRequest(methodName, arguments); assertEquals(expected, getResponse(methodName).getThrowable().getClass()); }
/** * Causes this thread to call the named method, and asserts that the call returns the expected * boolean value. */ public void callAndAssertReturns(boolean expected, String methodName, Object... arguments) throws Exception { checkNotNull(methodName); checkNotNull(arguments); sendRequest(methodName, arguments); assertEquals(expected, getResponse(methodName).getResult()); }
/** * Causes this thread to call the named method, and asserts that this thread thereby waits on the * given condition-like object. The lock-like object must have a method equivalent to {@link * java.util.concurrent.locks.ReentrantLock#hasWaiters(java.util.concurrent.locks.Condition)}, * except that the method parameter must accept whatever condition-like object is passed into this * method. */ public void callAndAssertWaits(String methodName, Object conditionLikeObject) throws Exception { checkNotNull(methodName); checkNotNull(conditionLikeObject); // TODO: Restore the following line when Monitor.hasWaiters() no longer acquires the lock. // assertEquals(false, invokeMethod("hasWaiters", conditionLikeObject)); sendRequest(methodName, conditionLikeObject); Thread.sleep(DUE_DILIGENCE_MILLIS); assertEquals(true, invokeMethod("hasWaiters", conditionLikeObject)); assertNull(responseQueue.poll()); }
/** * Causes this thread to call the named method, and asserts that this thread becomes blocked on * the lock-like object. The lock-like object must have a method equivalent to {@link * java.util.concurrent.locks.ReentrantLock#hasQueuedThread(Thread)}. */ public void callAndAssertBlocks(String methodName, Object... arguments) throws Exception { checkNotNull(methodName); checkNotNull(arguments); assertEquals(false, invokeMethod("hasQueuedThread", this)); sendRequest(methodName, arguments); Thread.sleep(DUE_DILIGENCE_MILLIS); assertEquals(true, invokeMethod("hasQueuedThread", this)); assertNull(responseQueue.poll()); }
/** * Causes this thread to call the named void method, and asserts that the call returns normally. */ public void callAndAssertReturns(String methodName, Object... arguments) throws Exception { checkNotNull(methodName); checkNotNull(arguments); sendRequest(methodName, arguments); assertSame(null, getResponse(methodName).getResult()); }
/** * Causes this thread to call the named method, and asserts that the call throws the expected * type of throwable. */ public void callAndAssertThrows(Class<? extends Throwable> expected, String methodName, Object... arguments) throws Exception { checkNotNull(expected); checkNotNull(methodName); checkNotNull(arguments); sendRequest(methodName, arguments); assertEquals(expected, getResponse(methodName).getThrowable().getClass()); }
/** * Causes this thread to call the named method, and asserts that the call returns the expected * boolean value. */ public void callAndAssertReturns(boolean expected, String methodName, Object... arguments) throws Exception { checkNotNull(methodName); checkNotNull(arguments); sendRequest(methodName, arguments); assertEquals(expected, getResponse(methodName).getResult()); }
/** * Causes this thread to call the named method, and asserts that the call returns the expected * int value. */ public void callAndAssertReturns(int expected, String methodName, Object... arguments) throws Exception { checkNotNull(methodName); checkNotNull(arguments); sendRequest(methodName, arguments); assertEquals(expected, getResponse(methodName).getResult()); }
/** * Causes this thread to call the named method, and asserts that this thread becomes blocked on * the lock-like object. The lock-like object must have a method equivalent to {@link * java.util.concurrent.locks.ReentrantLock#hasQueuedThread(Thread)}. */ public void callAndAssertBlocks(String methodName, Object... arguments) throws Exception { checkNotNull(methodName); checkNotNull(arguments); assertEquals(false, invokeMethod("hasQueuedThread", this)); sendRequest(methodName, arguments); Thread.sleep(DUE_DILIGENCE_MILLIS); assertEquals(true, invokeMethod("hasQueuedThread", this)); assertNull(responseQueue.poll()); }
/** * Causes this thread to call the named method, and asserts that this thread thereby waits on * the given condition-like object. The lock-like object must have a method equivalent to {@link * java.util.concurrent.locks.ReentrantLock#hasWaiters(java.util.concurrent.locks.Condition)}, * except that the method parameter must accept whatever condition-like object is passed into * this method. */ public void callAndAssertWaits(String methodName, Object conditionLikeObject) throws Exception { checkNotNull(methodName); checkNotNull(conditionLikeObject); // TODO: Restore the following line when Monitor.hasWaiters() no longer acquires the lock. // assertEquals(false, invokeMethod("hasWaiters", conditionLikeObject)); sendRequest(methodName, conditionLikeObject); Thread.sleep(DUE_DILIGENCE_MILLIS); assertEquals(true, invokeMethod("hasWaiters", conditionLikeObject)); assertNull(responseQueue.poll()); }
/** * Causes this thread to call the named void method, and asserts that the call returns normally. */ public void callAndAssertReturns(String methodName, Object... arguments) throws Exception { checkNotNull(methodName); checkNotNull(arguments); sendRequest(methodName, arguments); assertSame(null, getResponse(methodName).getResult()); }