
com.jfplugin.mail.mockhttp.MockHttpServletRequest Maven / Gradle / Ivy
package com.jfplugin.mail.mockhttp;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Created by farmer on 16/8/31.
*
* @author [email protected]
*/
public class MockHttpServletRequest implements InvocationHandler {
@SuppressWarnings("rawtypes")
private Map dataMap = new HashMap();
@SuppressWarnings("unchecked")
public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
if ("getAttributeNames".equals(method.getName())) {
return Collections.enumeration(dataMap.keySet());
}
else if ("setAttribute".equals(method.getName())) {
return dataMap.put(objects[0],objects[1]);
}
else if ("getAttribute".equals(method.getName())) {
return dataMap.get(objects[0]);
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy