All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sghd.common.utils.test.AbstractMock Maven / Gradle / Ivy

The newest version!
package com.sghd.common.utils.test;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * 测试用的假对象抽象
 * 
 * @author frank
 */
public abstract class AbstractMock {

	protected Queue queue = new ConcurrentLinkedQueue(); 

	/**
	 * 获取设置的返回值
	 * @return
	 */
	public Object getRetValue() {
		Object e = queue.poll();
		if(e instanceof RuntimeException) {
			throw (RuntimeException)e;
		}
		return e;
	}

	// Getter and Setter ...

	public void addException(RuntimeException exception) {
		this.queue.add(exception);
	}

	public void addRetValue(Object retValue) {
		this.queue.add(retValue);
	}

}