Add @Override annotations to main sources
Issue: SPR-10130
This commit is contained in:
@@ -45,10 +45,12 @@ public class MockHttpInputMessage implements HttpInputMessage {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return this.headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBody() throws IOException {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class MockHttpOutputMessage implements HttpOutputMessage {
|
||||
/**
|
||||
* Return the headers.
|
||||
*/
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return this.headers;
|
||||
}
|
||||
@@ -49,6 +50,7 @@ public class MockHttpOutputMessage implements HttpOutputMessage {
|
||||
/**
|
||||
* Return the body content.
|
||||
*/
|
||||
@Override
|
||||
public OutputStream getBody() throws IOException {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return this.uri;
|
||||
}
|
||||
@@ -64,6 +65,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return this.httpMethod;
|
||||
}
|
||||
@@ -85,6 +87,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie
|
||||
* configured {@link #setResponse(ClientHttpResponse) response}.
|
||||
* @see #executeInternal()
|
||||
*/
|
||||
@Override
|
||||
public final ClientHttpResponse execute() throws IOException {
|
||||
this.executed = true;
|
||||
return executeInternal();
|
||||
|
||||
@@ -52,18 +52,22 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie
|
||||
this.status = statusCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpStatus getStatusCode() throws IOException {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRawStatusCode() throws IOException {
|
||||
return this.status.value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatusText() throws IOException {
|
||||
return this.status.getReasonPhrase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public class ExpectedLookupTemplate extends JndiTemplate {
|
||||
* object provided in the constructor. If the name is unexpected, a
|
||||
* respective NamingException gets thrown.
|
||||
*/
|
||||
@Override
|
||||
public Object lookup(String name) throws NamingException {
|
||||
Object object = this.jndiObjects.get(name);
|
||||
if (object == null) {
|
||||
|
||||
@@ -91,6 +91,7 @@ public class SimpleNamingContext implements Context {
|
||||
|
||||
// Actual implementations of Context methods follow
|
||||
|
||||
@Override
|
||||
public NamingEnumeration<NameClassPair> list(String root) throws NamingException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Listing name/class pairs under [" + root + "]");
|
||||
@@ -98,6 +99,7 @@ public class SimpleNamingContext implements Context {
|
||||
return new NameClassPairEnumeration(this, root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingEnumeration<Binding> listBindings(String root) throws NamingException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Listing bindings under [" + root + "]");
|
||||
@@ -111,6 +113,7 @@ public class SimpleNamingContext implements Context {
|
||||
* Will be used by any standard InitialContext JNDI lookups.
|
||||
* @throws javax.naming.NameNotFoundException if the object could not be found
|
||||
*/
|
||||
@Override
|
||||
public Object lookup(String lookupName) throws NameNotFoundException {
|
||||
String name = this.root + lookupName;
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -136,6 +139,7 @@ public class SimpleNamingContext implements Context {
|
||||
return found;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object lookupLink(String name) throws NameNotFoundException {
|
||||
return lookup(name);
|
||||
}
|
||||
@@ -147,6 +151,7 @@ public class SimpleNamingContext implements Context {
|
||||
* Use SimpleNamingContextBuilder to set up JNDI bindings then.
|
||||
* @see org.springframework.mock.jndi.SimpleNamingContextBuilder#bind
|
||||
*/
|
||||
@Override
|
||||
public void bind(String name, Object obj) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Static JNDI binding: [" + this.root + name + "] = [" + obj + "]");
|
||||
@@ -154,6 +159,7 @@ public class SimpleNamingContext implements Context {
|
||||
this.boundObjects.put(this.root + name, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unbind(String name) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Static JNDI remove: [" + this.root + name + "]");
|
||||
@@ -161,16 +167,19 @@ public class SimpleNamingContext implements Context {
|
||||
this.boundObjects.remove(this.root + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebind(String name, Object obj) {
|
||||
bind(name, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(String oldName, String newName) throws NameNotFoundException {
|
||||
Object obj = lookup(oldName);
|
||||
unbind(oldName);
|
||||
bind(newName, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context createSubcontext(String name) {
|
||||
String subcontextName = this.root + name;
|
||||
if (!subcontextName.endsWith("/")) {
|
||||
@@ -181,84 +190,104 @@ public class SimpleNamingContext implements Context {
|
||||
return subcontext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroySubcontext(String name) {
|
||||
unbind(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String composeName(String name, String prefix) {
|
||||
return prefix + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hashtable<String, Object> getEnvironment() {
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object addToEnvironment(String propName, Object propVal) {
|
||||
return this.environment.put(propName, propVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object removeFromEnvironment(String propName) {
|
||||
return this.environment.remove(propName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
|
||||
// Unsupported methods follow: no support for javax.naming.Name
|
||||
|
||||
@Override
|
||||
public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object lookup(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object lookupLink(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(Name name, Object obj) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unbind(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebind(Name name, Object obj) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(Name oldName, Name newName) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context createSubcontext(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroySubcontext(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameInNamespace() throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NameParser getNameParser(Name name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NameParser getNameParser(String name) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Name composeName(Name name, Name prefix) throws NamingException {
|
||||
throw new OperationNotSupportedException("SimpleNamingContext does not support [javax.naming.Name]");
|
||||
}
|
||||
@@ -298,22 +327,27 @@ public class SimpleNamingContext implements Context {
|
||||
|
||||
protected abstract T createObject(String strippedName, Object obj);
|
||||
|
||||
@Override
|
||||
public boolean hasMore() {
|
||||
return this.iterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
return this.iterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreElements() {
|
||||
return this.iterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T nextElement() {
|
||||
return this.iterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
@@ -325,6 +359,7 @@ public class SimpleNamingContext implements Context {
|
||||
super(context, root);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NameClassPair createObject(String strippedName, Object obj) {
|
||||
return new NameClassPair(strippedName, obj.getClass().getName());
|
||||
}
|
||||
@@ -337,6 +372,7 @@ public class SimpleNamingContext implements Context {
|
||||
super(context, root);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Binding createObject(String strippedName, Object obj) {
|
||||
return new Binding(strippedName, obj);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder
|
||||
* creating a new SimpleNamingContext instance.
|
||||
* @see SimpleNamingContext
|
||||
*/
|
||||
@Override
|
||||
public InitialContextFactory createInitialContextFactory(Hashtable<?,?> environment) {
|
||||
if (activated == null && environment != null) {
|
||||
Object icf = environment.get(Context.INITIAL_CONTEXT_FACTORY);
|
||||
@@ -225,6 +226,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder
|
||||
|
||||
// Default case...
|
||||
return new InitialContextFactory() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Context getInitialContext(Hashtable<?,?> environment) {
|
||||
return new SimpleNamingContext("", boundObjects, (Hashtable<String, Object>) environment);
|
||||
|
||||
@@ -54,10 +54,12 @@ public class DelegatingServletInputStream extends ServletInputStream {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return this.sourceStream.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
super.close();
|
||||
this.sourceStream.close();
|
||||
|
||||
@@ -54,15 +54,18 @@ public class DelegatingServletOutputStream extends ServletOutputStream {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
this.targetStream.write(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
super.flush();
|
||||
this.targetStream.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
super.close();
|
||||
this.targetStream.close();
|
||||
|
||||
@@ -77,14 +77,17 @@ public class MockBodyContent extends BodyContent {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Reader getReader() {
|
||||
return new StringReader(this.content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeOut(Writer writer) throws IOException {
|
||||
writer.write(this.content);
|
||||
}
|
||||
@@ -94,102 +97,127 @@ public class MockBodyContent extends BodyContent {
|
||||
// Delegating implementations of JspWriter's abstract methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void clear() throws IOException {
|
||||
getEnclosingWriter().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBuffer() throws IOException {
|
||||
getEnclosingWriter().clearBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
getEnclosingWriter().close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemaining() {
|
||||
return getEnclosingWriter().getRemaining();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newLine() throws IOException {
|
||||
getEnclosingWriter().println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char value[], int offset, int length) throws IOException {
|
||||
getEnclosingWriter().write(value, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(boolean value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(char value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(char[] value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(double value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(float value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(int value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(long value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Object value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String value) throws IOException {
|
||||
getEnclosingWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println() throws IOException {
|
||||
getEnclosingWriter().println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(boolean value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(char value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(char[] value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(double value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(float value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(int value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(long value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(Object value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(String value) throws IOException {
|
||||
getEnclosingWriter().println(value);
|
||||
}
|
||||
|
||||
@@ -56,18 +56,21 @@ public class MockExpressionEvaluator extends ExpressionEvaluator {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Expression parseExpression(final String expression, final Class expectedType,
|
||||
final FunctionMapper functionMapper) throws ELException {
|
||||
|
||||
return new Expression() {
|
||||
|
||||
@Override
|
||||
public Object evaluate(VariableResolver variableResolver) throws ELException {
|
||||
return doEvaluate(expression, expectedType, functionMapper);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object evaluate(String expression, Class expectedType, VariableResolver variableResolver,
|
||||
FunctionMapper functionMapper) throws ELException {
|
||||
|
||||
@@ -119,6 +119,7 @@ public class MockFilterChain implements FilterChain {
|
||||
* Invoke registered {@link Filter}s and/or {@link Servlet} also saving the
|
||||
* request and response.
|
||||
*/
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
Assert.notNull(request, "Request must not be null");
|
||||
Assert.notNull(response, "Response must not be null");
|
||||
@@ -162,15 +163,18 @@ public class MockFilterChain implements FilterChain {
|
||||
this.delegateServlet = servlet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
|
||||
this.delegateServlet.service(request, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
@@ -79,10 +79,12 @@ public class MockFilterConfig implements FilterConfig {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getFilterName() {
|
||||
return filterName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return servletContext;
|
||||
}
|
||||
@@ -92,11 +94,13 @@ public class MockFilterConfig implements FilterConfig {
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
|
||||
@@ -283,20 +283,24 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
// ServletRequest interface
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
checkActive();
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
checkActive();
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.characterEncoding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterEncoding(String characterEncoding) {
|
||||
this.characterEncoding = characterEncoding;
|
||||
updateContentTypeHeader();
|
||||
@@ -316,6 +320,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentLength() {
|
||||
return (this.content != null ? this.content.length : -1);
|
||||
}
|
||||
@@ -332,10 +337,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() {
|
||||
if (this.content != null) {
|
||||
return new DelegatingServletInputStream(new ByteArrayInputStream(this.content));
|
||||
@@ -455,21 +462,25 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.parameters.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
String[] arr = this.parameters.get(name);
|
||||
return (arr != null && arr.length > 0 ? arr[0] : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getParameterNames() {
|
||||
return Collections.enumeration(this.parameters.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.parameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
return Collections.unmodifiableMap(this.parameters);
|
||||
}
|
||||
@@ -478,6 +489,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return this.protocol;
|
||||
}
|
||||
@@ -486,6 +498,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return this.scheme;
|
||||
}
|
||||
@@ -494,6 +507,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return this.serverName;
|
||||
}
|
||||
@@ -502,10 +516,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return this.serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() throws UnsupportedEncodingException {
|
||||
if (this.content != null) {
|
||||
InputStream sourceStream = new ByteArrayInputStream(this.content);
|
||||
@@ -522,6 +538,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.remoteAddr = remoteAddr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteAddr() {
|
||||
return this.remoteAddr;
|
||||
}
|
||||
@@ -530,10 +547,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.remoteHost = remoteHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteHost() {
|
||||
return this.remoteHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
checkActive();
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
@@ -545,6 +564,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
checkActive();
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
@@ -579,10 +599,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.locales.addAll(locales);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return this.locales.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<Locale> getLocales() {
|
||||
return Collections.enumeration(this.locales);
|
||||
}
|
||||
@@ -591,14 +613,17 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.secure = secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return this.secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestDispatcher getRequestDispatcher(String path) {
|
||||
return new MockRequestDispatcher(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealPath(String path) {
|
||||
return this.servletContext.getRealPath(path);
|
||||
}
|
||||
@@ -607,6 +632,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.remotePort = remotePort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemotePort() {
|
||||
return this.remotePort;
|
||||
}
|
||||
@@ -615,6 +641,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.localName = localName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalName() {
|
||||
return this.localName;
|
||||
}
|
||||
@@ -623,6 +650,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.localAddr = localAddr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalAddr() {
|
||||
return this.localAddr;
|
||||
}
|
||||
@@ -631,6 +659,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.localPort = localPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLocalPort() {
|
||||
return this.localPort;
|
||||
}
|
||||
@@ -643,6 +672,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.authType = authType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return this.authType;
|
||||
}
|
||||
@@ -651,6 +681,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.cookies = cookies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cookie[] getCookies() {
|
||||
return this.cookies;
|
||||
}
|
||||
@@ -699,6 +730,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDateHeader(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
Object value = (header != null ? header.getValue() : null);
|
||||
@@ -717,20 +749,24 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
return (header != null ? header.getStringValue() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaders(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
return Collections.enumeration(header != null ? header.getStringValues() : new LinkedList<String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaderNames() {
|
||||
return Collections.enumeration(this.headers.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntHeader(String name) {
|
||||
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
|
||||
Object value = (header != null ? header.getValue() : null);
|
||||
@@ -752,6 +788,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
@@ -760,10 +797,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.pathInfo = pathInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPathInfo() {
|
||||
return this.pathInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPathTranslated() {
|
||||
return (this.pathInfo != null ? getRealPath(this.pathInfo) : null);
|
||||
}
|
||||
@@ -772,6 +811,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContextPath() {
|
||||
return this.contextPath;
|
||||
}
|
||||
@@ -780,6 +820,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.queryString = queryString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryString() {
|
||||
return this.queryString;
|
||||
}
|
||||
@@ -788,6 +829,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.remoteUser = remoteUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteUser() {
|
||||
return this.remoteUser;
|
||||
}
|
||||
@@ -796,6 +838,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.userRoles.add(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserInRole(String role) {
|
||||
return (this.userRoles.contains(role) || (this.servletContext instanceof MockServletContext && ((MockServletContext) this.servletContext).getDeclaredRoles().contains(
|
||||
role)));
|
||||
@@ -805,6 +848,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.userPrincipal = userPrincipal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
return this.userPrincipal;
|
||||
}
|
||||
@@ -813,6 +857,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestedSessionId = requestedSessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestedSessionId() {
|
||||
return this.requestedSessionId;
|
||||
}
|
||||
@@ -821,10 +866,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestURI = requestURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestURI() {
|
||||
return this.requestURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuffer getRequestURL() {
|
||||
StringBuffer url = new StringBuffer(this.scheme);
|
||||
url.append("://").append(this.serverName).append(':').append(this.serverPort);
|
||||
@@ -836,6 +883,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.servletPath = servletPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletPath() {
|
||||
return this.servletPath;
|
||||
}
|
||||
@@ -848,6 +896,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession(boolean create) {
|
||||
checkActive();
|
||||
// Reset session if invalidated.
|
||||
@@ -861,6 +910,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
return this.session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession() {
|
||||
return getSession(true);
|
||||
}
|
||||
@@ -869,6 +919,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestedSessionIdValid = requestedSessionIdValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdValid() {
|
||||
return this.requestedSessionIdValid;
|
||||
}
|
||||
@@ -877,6 +928,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestedSessionIdFromCookie = requestedSessionIdFromCookie;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdFromCookie() {
|
||||
return this.requestedSessionIdFromCookie;
|
||||
}
|
||||
@@ -885,10 +937,12 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
this.requestedSessionIdFromURL = requestedSessionIdFromURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdFromURL() {
|
||||
return this.requestedSessionIdFromURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdFromUrl() {
|
||||
return isRequestedSessionIdFromURL();
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return this.writerAccessAllowed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterEncoding(String characterEncoding) {
|
||||
this.characterEncoding = characterEncoding;
|
||||
this.charset = true;
|
||||
@@ -152,10 +153,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.characterEncoding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletOutputStream getOutputStream() {
|
||||
if (!this.outputStreamAccessAllowed) {
|
||||
throw new IllegalStateException("OutputStream access not allowed");
|
||||
@@ -163,6 +166,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return this.outputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintWriter getWriter() throws UnsupportedEncodingException {
|
||||
if (!this.writerAccessAllowed) {
|
||||
throw new IllegalStateException("Writer access not allowed");
|
||||
@@ -186,6 +190,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
this.content.toString(this.characterEncoding) : this.content.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentLength(int contentLength) {
|
||||
this.contentLength = contentLength;
|
||||
doAddHeaderValue(CONTENT_LENGTH_HEADER, contentLength, true);
|
||||
@@ -195,6 +200,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return this.contentLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
if (contentType != null) {
|
||||
@@ -208,22 +214,27 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferSize(int bufferSize) {
|
||||
this.bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferSize() {
|
||||
return this.bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushBuffer() {
|
||||
setCommitted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuffer() {
|
||||
if (isCommitted()) {
|
||||
throw new IllegalStateException("Cannot reset buffer - response is already committed");
|
||||
@@ -242,10 +253,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
this.committed = committed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommitted() {
|
||||
return this.committed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
resetBuffer();
|
||||
this.characterEncoding = null;
|
||||
@@ -258,10 +271,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
this.errorMessage = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
@@ -271,6 +286,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
// HttpServletResponse interface
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void addCookie(Cookie cookie) {
|
||||
Assert.notNull(cookie, "Cookie must not be null");
|
||||
this.cookies.add(cookie);
|
||||
@@ -290,6 +306,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsHeader(String name) {
|
||||
return (HeaderValueHolder.getByName(this.headers, name) != null);
|
||||
}
|
||||
@@ -365,6 +382,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
* The default implementation returns the given URL String as-is.
|
||||
* <p>Can be overridden in subclasses, appending a session id or the like.
|
||||
*/
|
||||
@Override
|
||||
public String encodeURL(String url) {
|
||||
return url;
|
||||
}
|
||||
@@ -377,18 +395,22 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
* override the common {@link #encodeURL} method instead, applying
|
||||
* to redirect URLs as well as to general URLs.
|
||||
*/
|
||||
@Override
|
||||
public String encodeRedirectURL(String url) {
|
||||
return encodeURL(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeUrl(String url) {
|
||||
return encodeURL(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeRedirectUrl(String url) {
|
||||
return encodeRedirectURL(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int status, String errorMessage) throws IOException {
|
||||
if (isCommitted()) {
|
||||
throw new IllegalStateException("Cannot set error status - response is already committed");
|
||||
@@ -398,6 +420,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
setCommitted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int status) throws IOException {
|
||||
if (isCommitted()) {
|
||||
throw new IllegalStateException("Cannot set error status - response is already committed");
|
||||
@@ -406,6 +429,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
setCommitted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRedirect(String url) throws IOException {
|
||||
if (isCommitted()) {
|
||||
throw new IllegalStateException("Cannot send redirect - response is already committed");
|
||||
@@ -420,26 +444,32 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
return getHeader(LOCATION_HEADER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDateHeader(String name, long value) {
|
||||
setHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDateHeader(String name, long value) {
|
||||
addHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(String name, String value) {
|
||||
setHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHeader(String name, String value) {
|
||||
addHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntHeader(String name, int value) {
|
||||
setHeaderValue(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIntHeader(String name, int value) {
|
||||
addHeaderValue(name, value);
|
||||
}
|
||||
@@ -487,10 +517,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(int status, String errorMessage) {
|
||||
this.status = status;
|
||||
this.errorMessage = errorMessage;
|
||||
@@ -553,12 +585,14 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
super(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
super.write(b);
|
||||
super.flush();
|
||||
setCommittedIfBufferSizeExceeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
super.flush();
|
||||
setCommitted(true);
|
||||
@@ -576,24 +610,28 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
super(out, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char buf[], int off, int len) {
|
||||
super.write(buf, off, len);
|
||||
super.flush();
|
||||
setCommittedIfBufferSizeExceeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(String s, int off, int len) {
|
||||
super.write(s, off, len);
|
||||
super.flush();
|
||||
setCommittedIfBufferSizeExceeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int c) {
|
||||
super.write(c);
|
||||
super.flush();
|
||||
setCommittedIfBufferSizeExceeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
super.flush();
|
||||
setCommitted(true);
|
||||
|
||||
@@ -98,10 +98,12 @@ public class MockHttpSession implements HttpSession {
|
||||
this.id = (id != null ? id : Integer.toString(nextId++));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTime() {
|
||||
return this.creationTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
@@ -111,43 +113,53 @@ public class MockHttpSession implements HttpSession {
|
||||
this.isNew = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastAccessedTime() {
|
||||
return this.lastAccessedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return this.servletContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxInactiveInterval(int interval) {
|
||||
this.maxInactiveInterval = interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInactiveInterval() {
|
||||
return this.maxInactiveInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSessionContext getSessionContext() {
|
||||
throw new UnsupportedOperationException("getSessionContext");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(String name) {
|
||||
return getAttribute(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getValueNames() {
|
||||
return this.attributes.keySet().toArray(new String[this.attributes.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
if (value != null) {
|
||||
@@ -161,10 +173,12 @@ public class MockHttpSession implements HttpSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putValue(String name, Object value) {
|
||||
setAttribute(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
Object value = this.attributes.remove(name);
|
||||
@@ -173,6 +187,7 @@ public class MockHttpSession implements HttpSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeValue(String name) {
|
||||
removeAttribute(name);
|
||||
}
|
||||
@@ -197,6 +212,7 @@ public class MockHttpSession implements HttpSession {
|
||||
*
|
||||
* @throws IllegalStateException if this method is called on an already invalidated session
|
||||
*/
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (this.invalid) {
|
||||
throw new IllegalStateException("The session has already been invalidated");
|
||||
@@ -215,6 +231,7 @@ public class MockHttpSession implements HttpSession {
|
||||
this.isNew = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return this.isNew;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ public class MockJspWriter extends JspWriter {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clear() throws IOException {
|
||||
if (this.response.isCommitted()) {
|
||||
throw new IOException("Response already committed");
|
||||
@@ -89,101 +90,126 @@ public class MockJspWriter extends JspWriter {
|
||||
this.response.resetBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBuffer() throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
this.response.flushBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemaining() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newLine() throws IOException {
|
||||
getTargetWriter().println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char value[], int offset, int length) throws IOException {
|
||||
getTargetWriter().write(value, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(boolean value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(char value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(char[] value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(double value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(float value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(int value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(long value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Object value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println() throws IOException {
|
||||
getTargetWriter().println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(boolean value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(char value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(char[] value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(double value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(float value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(int value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(long value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(Object value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void println(String value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
@@ -96,34 +96,42 @@ public class MockMultipartFile implements MultipartFile {
|
||||
this(name, originalFilename, contentType, FileCopyUtils.copyToByteArray(contentStream));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
return this.originalFilename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (this.content.length == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() {
|
||||
return this.content.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(this.content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||
FileCopyUtils.copy(this.content, dest);
|
||||
}
|
||||
|
||||
@@ -66,14 +66,17 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
this.multipartFiles.add(file.getName(), file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<String> getFileNames() {
|
||||
return this.multipartFiles.keySet().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultipartFile getFile(String name) {
|
||||
return this.multipartFiles.getFirst(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MultipartFile> getFiles(String name) {
|
||||
List<MultipartFile> multipartFiles = this.multipartFiles.get(name);
|
||||
if (multipartFiles != null) {
|
||||
@@ -84,14 +87,17 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, MultipartFile> getFileMap() {
|
||||
return this.multipartFiles.toSingleValueMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiValueMap<String, MultipartFile> getMultiFileMap() {
|
||||
return new LinkedMultiValueMap<String, MultipartFile>(this.multipartFiles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultipartContentType(String paramOrFileName) {
|
||||
MultipartFile file = getFile(paramOrFileName);
|
||||
if (file != null) {
|
||||
@@ -102,10 +108,12 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getRequestMethod() {
|
||||
return HttpMethod.valueOf(getMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getRequestHeaders() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
Enumeration<String> headerNames = getHeaderNames();
|
||||
@@ -116,6 +124,7 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getMultipartHeaders(String paramOrFileName) {
|
||||
String contentType = getMultipartContentType(paramOrFileName);
|
||||
if (contentType != null) {
|
||||
|
||||
@@ -126,6 +126,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(
|
||||
Servlet servlet, ServletRequest request, ServletResponse response,
|
||||
String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) {
|
||||
@@ -133,9 +134,11 @@ public class MockPageContext extends PageContext {
|
||||
throw new UnsupportedOperationException("Use appropriate constructor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
if (value != null) {
|
||||
@@ -146,6 +149,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
@@ -166,11 +170,13 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
@@ -188,6 +194,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object findAttribute(String name) {
|
||||
Object value = getAttribute(name);
|
||||
if (value == null) {
|
||||
@@ -202,6 +209,7 @@ public class MockPageContext extends PageContext {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
this.removeAttribute(name, PageContext.PAGE_SCOPE);
|
||||
@@ -210,6 +218,7 @@ public class MockPageContext extends PageContext {
|
||||
this.removeAttribute(name, PageContext.APPLICATION_SCOPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
@@ -230,6 +239,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAttributesScope(String name) {
|
||||
if (getAttribute(name) != null) {
|
||||
return PAGE_SCOPE;
|
||||
@@ -252,6 +262,7 @@ public class MockPageContext extends PageContext {
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration<String> getAttributeNamesInScope(int scope) {
|
||||
switch (scope) {
|
||||
@@ -269,6 +280,7 @@ public class MockPageContext extends PageContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JspWriter getOut() {
|
||||
if (this.out == null) {
|
||||
this.out = new MockJspWriter(this.response);
|
||||
@@ -276,54 +288,67 @@ public class MockPageContext extends PageContext {
|
||||
return this.out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionEvaluator getExpressionEvaluator() {
|
||||
return new MockExpressionEvaluator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ELContext getELContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableResolver getVariableResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpSession getSession() {
|
||||
return this.request.getSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPage() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletRequest getRequest() {
|
||||
return this.request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletResponse getResponse() {
|
||||
return this.response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Exception getException() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletConfig getServletConfig() {
|
||||
return this.servletConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return this.servletContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forward(String path) throws ServletException, IOException {
|
||||
this.request.getRequestDispatcher(path).forward(this.request, this.response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void include(String path) throws ServletException, IOException {
|
||||
this.request.getRequestDispatcher(path).include(this.request, this.response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void include(String path, boolean flush) throws ServletException, IOException {
|
||||
this.request.getRequestDispatcher(path).include(this.request, this.response);
|
||||
if (flush) {
|
||||
@@ -341,10 +366,12 @@ public class MockPageContext extends PageContext {
|
||||
return ((MockHttpServletResponse) this.response).getContentAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePageException(Exception ex) throws ServletException, IOException {
|
||||
throw new ServletException("Page exception", ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePageException(Throwable ex) throws ServletException, IOException {
|
||||
throw new ServletException("Page exception", ex);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public class MockRequestDispatcher implements RequestDispatcher {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void forward(ServletRequest request, ServletResponse response) {
|
||||
Assert.notNull(request, "Request must not be null");
|
||||
Assert.notNull(response, "Response must not be null");
|
||||
@@ -67,6 +68,7 @@ public class MockRequestDispatcher implements RequestDispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void include(ServletRequest request, ServletResponse response) {
|
||||
Assert.notNull(request, "Request must not be null");
|
||||
Assert.notNull(response, "Response must not be null");
|
||||
|
||||
@@ -78,10 +78,12 @@ public class MockServletConfig implements ServletConfig {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getServletName() {
|
||||
return this.servletName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return this.servletContext;
|
||||
}
|
||||
@@ -91,11 +93,13 @@ public class MockServletConfig implements ServletConfig {
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
|
||||
@@ -195,6 +195,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
|
||||
/* This is a Servlet API 2.5 method. */
|
||||
@Override
|
||||
public String getContextPath() {
|
||||
return this.contextPath;
|
||||
}
|
||||
@@ -203,6 +204,7 @@ public class MockServletContext implements ServletContext {
|
||||
this.contexts.put(contextPath, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getContext(String contextPath) {
|
||||
if (this.contextPath.equals(contextPath)) {
|
||||
return this;
|
||||
@@ -214,6 +216,7 @@ public class MockServletContext implements ServletContext {
|
||||
this.majorVersion = majorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMajorVersion() {
|
||||
return this.majorVersion;
|
||||
}
|
||||
@@ -222,6 +225,7 @@ public class MockServletContext implements ServletContext {
|
||||
this.minorVersion = minorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinorVersion() {
|
||||
return this.minorVersion;
|
||||
}
|
||||
@@ -242,10 +246,12 @@ public class MockServletContext implements ServletContext {
|
||||
return this.effectiveMinorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMimeType(String filePath) {
|
||||
return MimeTypeResolver.getMimeType(filePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getResourcePaths(String path) {
|
||||
String actualPath = (path.endsWith("/") ? path : path + "/");
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(actualPath));
|
||||
@@ -271,6 +277,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String path) throws MalformedURLException {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
if (!resource.exists()) {
|
||||
@@ -288,6 +295,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String path) {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
if (!resource.exists()) {
|
||||
@@ -302,6 +310,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestDispatcher getRequestDispatcher(String path) {
|
||||
if (!path.startsWith("/")) {
|
||||
throw new IllegalArgumentException("RequestDispatcher path at ServletContext level must start with '/'");
|
||||
@@ -309,6 +318,7 @@ public class MockServletContext implements ServletContext {
|
||||
return new MockRequestDispatcher(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestDispatcher getNamedDispatcher(String path) {
|
||||
return this.namedRequestDispatchers.get(path);
|
||||
}
|
||||
@@ -366,30 +376,37 @@ public class MockServletContext implements ServletContext {
|
||||
registerNamedDispatcher(this.defaultServletName, new MockRequestDispatcher(this.defaultServletName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Servlet getServlet(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<Servlet> getServlets() {
|
||||
return Collections.enumeration(new HashSet<Servlet>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getServletNames() {
|
||||
return Collections.enumeration(new HashSet<String>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Exception ex, String message) {
|
||||
logger.info(message, ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message, Throwable ex) {
|
||||
logger.info(message, ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealPath(String path) {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
try {
|
||||
@@ -401,15 +418,18 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerInfo() {
|
||||
return "MockServletContext";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
@@ -428,15 +448,18 @@ public class MockServletContext implements ServletContext {
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
if (value != null) {
|
||||
@@ -447,6 +470,7 @@ public class MockServletContext implements ServletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
this.attributes.remove(name);
|
||||
@@ -456,6 +480,7 @@ public class MockServletContext implements ServletContext {
|
||||
this.servletContextName = servletContextName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletContextName() {
|
||||
return this.servletContextName;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public class PassThroughFilterChain implements FilterChain {
|
||||
/**
|
||||
* Pass the call on to the Filter/Servlet.
|
||||
*/
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException {
|
||||
if (this.filter != null) {
|
||||
this.filter.doFilter(request, response, this.nextFilterChain);
|
||||
|
||||
@@ -59,6 +59,7 @@ public class MockActionResponse extends MockStateAwareResponse implements Action
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setWindowState(WindowState windowState) throws WindowStateException {
|
||||
if (this.redirectedUrl != null) {
|
||||
throw new IllegalStateException("Cannot set WindowState after sendRedirect has been called");
|
||||
@@ -67,6 +68,7 @@ public class MockActionResponse extends MockStateAwareResponse implements Action
|
||||
this.redirectAllowed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPortletMode(PortletMode portletMode) throws PortletModeException {
|
||||
if (this.redirectedUrl != null) {
|
||||
throw new IllegalStateException("Cannot set PortletMode after sendRedirect has been called");
|
||||
@@ -75,6 +77,7 @@ public class MockActionResponse extends MockStateAwareResponse implements Action
|
||||
this.redirectAllowed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderParameters(Map<String, String[]> parameters) {
|
||||
if (this.redirectedUrl != null) {
|
||||
throw new IllegalStateException("Cannot set render parameters after sendRedirect has been called");
|
||||
@@ -83,6 +86,7 @@ public class MockActionResponse extends MockStateAwareResponse implements Action
|
||||
this.redirectAllowed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderParameter(String key, String value) {
|
||||
if (this.redirectedUrl != null) {
|
||||
throw new IllegalStateException("Cannot set render parameters after sendRedirect has been called");
|
||||
@@ -91,6 +95,7 @@ public class MockActionResponse extends MockStateAwareResponse implements Action
|
||||
this.redirectAllowed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderParameter(String key, String[] values) {
|
||||
if (this.redirectedUrl != null) {
|
||||
throw new IllegalStateException("Cannot set render parameters after sendRedirect has been called");
|
||||
@@ -99,6 +104,7 @@ public class MockActionResponse extends MockStateAwareResponse implements Action
|
||||
this.redirectAllowed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRedirect(String location) throws IOException {
|
||||
if (!this.redirectAllowed) {
|
||||
throw new IllegalStateException(
|
||||
@@ -108,6 +114,7 @@ public class MockActionResponse extends MockStateAwareResponse implements Action
|
||||
this.redirectedUrl = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRedirect(String location, String renderUrlParamName) throws IOException {
|
||||
sendRedirect(location);
|
||||
if (renderUrlParamName != null) {
|
||||
|
||||
@@ -56,18 +56,21 @@ public abstract class MockBaseURL implements BaseURL {
|
||||
// BaseURL methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void setParameter(String key, String value) {
|
||||
Assert.notNull(key, "Parameter key must be null");
|
||||
Assert.notNull(value, "Parameter value must not be null");
|
||||
this.parameters.put(key, new String[] {value});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(String key, String[] values) {
|
||||
Assert.notNull(key, "Parameter key must be null");
|
||||
Assert.notNull(values, "Parameter values must not be null");
|
||||
this.parameters.put(key, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameters(Map<String, String[]> parameters) {
|
||||
Assert.notNull(parameters, "Parameters Map must not be null");
|
||||
this.parameters.clear();
|
||||
@@ -87,10 +90,12 @@ public abstract class MockBaseURL implements BaseURL {
|
||||
return this.parameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
return Collections.unmodifiableMap(this.parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecure(boolean secure) throws PortletSecurityException {
|
||||
this.secure = secure;
|
||||
}
|
||||
@@ -99,14 +104,17 @@ public abstract class MockBaseURL implements BaseURL {
|
||||
return this.secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writer out) throws IOException {
|
||||
out.write(toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writer out, boolean escapeXML) throws IOException {
|
||||
out.write(toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProperty(String key, String value) {
|
||||
String[] values = this.properties.get(key);
|
||||
if (values != null) {
|
||||
@@ -117,6 +125,7 @@ public abstract class MockBaseURL implements BaseURL {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String key, String value) {
|
||||
this.properties.put(key, new String[] {value});
|
||||
}
|
||||
|
||||
@@ -35,34 +35,42 @@ public class MockCacheControl implements CacheControl {
|
||||
private boolean useCachedContent = false;
|
||||
|
||||
|
||||
@Override
|
||||
public int getExpirationTime() {
|
||||
return this.expirationTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpirationTime(int time) {
|
||||
this.expirationTime = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPublicScope() {
|
||||
return this.publicScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPublicScope(boolean publicScope) {
|
||||
this.publicScope = publicScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getETag() {
|
||||
return this.etag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setETag(String token) {
|
||||
this.etag = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useCachedContent() {
|
||||
return this.useCachedContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseCachedContent(boolean useCachedContent) {
|
||||
this.useCachedContent = useCachedContent;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ public class MockClientDataRequest extends MockPortletRequest implements ClientD
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getPortletInputStream() throws IOException {
|
||||
if (this.content != null) {
|
||||
return new ByteArrayInputStream(this.content);
|
||||
@@ -85,10 +86,12 @@ public class MockClientDataRequest extends MockPortletRequest implements ClientD
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharacterEncoding(String characterEncoding) {
|
||||
this.characterEncoding = characterEncoding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() throws UnsupportedEncodingException {
|
||||
if (this.content != null) {
|
||||
InputStream sourceStream = new ByteArrayInputStream(this.content);
|
||||
@@ -101,6 +104,7 @@ public class MockClientDataRequest extends MockPortletRequest implements ClientD
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.characterEncoding;
|
||||
}
|
||||
@@ -109,10 +113,12 @@ public class MockClientDataRequest extends MockPortletRequest implements ClientD
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentLength() {
|
||||
return (this.content != null ? content.length : -1);
|
||||
}
|
||||
@@ -121,6 +127,7 @@ public class MockClientDataRequest extends MockPortletRequest implements ClientD
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@@ -73,14 +73,17 @@ public class MockEvent implements Event {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public QName getQName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name.getLocalPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public class MockEventRequest extends MockPortletRequest implements EventRequest
|
||||
return EVENT_PHASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Event getEvent() {
|
||||
return this.event;
|
||||
}
|
||||
@@ -81,6 +82,7 @@ public class MockEventRequest extends MockPortletRequest implements EventRequest
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import javax.portlet.EventResponse;
|
||||
*/
|
||||
public class MockEventResponse extends MockStateAwareResponse implements EventResponse {
|
||||
|
||||
@Override
|
||||
public void setRenderParameters(EventRequest request) {
|
||||
setRenderParameters(request.getParameterMap());
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ public class MockMimeResponse extends MockPortletResponse implements MimeRespons
|
||||
// RenderResponse methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void setContentType(String contentType) {
|
||||
if (this.request != null) {
|
||||
Enumeration<String> supportedTypes = this.request.getResponseContentTypes();
|
||||
@@ -112,6 +113,7 @@ public class MockMimeResponse extends MockPortletResponse implements MimeRespons
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return this.contentType;
|
||||
}
|
||||
@@ -120,10 +122,12 @@ public class MockMimeResponse extends MockPortletResponse implements MimeRespons
|
||||
this.characterEncoding = characterEncoding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCharacterEncoding() {
|
||||
return this.characterEncoding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintWriter getWriter() throws UnsupportedEncodingException {
|
||||
if (this.writer == null) {
|
||||
Writer targetWriter = (this.characterEncoding != null
|
||||
@@ -150,18 +154,22 @@ public class MockMimeResponse extends MockPortletResponse implements MimeRespons
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBufferSize(int bufferSize) {
|
||||
this.bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferSize() {
|
||||
return this.bufferSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushBuffer() {
|
||||
if (this.writer != null) {
|
||||
this.writer.flush();
|
||||
@@ -177,6 +185,7 @@ public class MockMimeResponse extends MockPortletResponse implements MimeRespons
|
||||
this.committed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetBuffer() {
|
||||
if (this.committed) {
|
||||
throw new IllegalStateException("Cannot reset buffer - response is already committed");
|
||||
@@ -188,10 +197,12 @@ public class MockMimeResponse extends MockPortletResponse implements MimeRespons
|
||||
this.committed = committed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommitted() {
|
||||
return this.committed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
resetBuffer();
|
||||
this.characterEncoding = null;
|
||||
@@ -199,22 +210,27 @@ public class MockMimeResponse extends MockPortletResponse implements MimeRespons
|
||||
this.locale = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getPortletOutputStream() throws IOException {
|
||||
return this.outputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletURL createRenderURL() {
|
||||
return new MockPortletURL(getPortalContext(), MockPortletURL.URL_TYPE_RENDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletURL createActionURL() {
|
||||
return new MockPortletURL(getPortalContext(), MockPortletURL.URL_TYPE_ACTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceURL createResourceURL() {
|
||||
return new MockResourceURL();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CacheControl getCacheControl() {
|
||||
return this.cacheControl;
|
||||
}
|
||||
|
||||
@@ -56,14 +56,17 @@ public class MockMultipartActionRequest extends MockActionRequest implements Mul
|
||||
this.multipartFiles.add(file.getName(), file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<String> getFileNames() {
|
||||
return this.multipartFiles.keySet().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultipartFile getFile(String name) {
|
||||
return this.multipartFiles.getFirst(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MultipartFile> getFiles(String name) {
|
||||
List<MultipartFile> multipartFiles = this.multipartFiles.get(name);
|
||||
if (multipartFiles != null) {
|
||||
@@ -74,14 +77,17 @@ public class MockMultipartActionRequest extends MockActionRequest implements Mul
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, MultipartFile> getFileMap() {
|
||||
return this.multipartFiles.toSingleValueMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiValueMap<String, MultipartFile> getMultiFileMap() {
|
||||
return new LinkedMultiValueMap<String, MultipartFile>(this.multipartFiles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultipartContentType(String paramOrFileName) {
|
||||
MultipartFile file = getFile(paramOrFileName);
|
||||
if (file != null) {
|
||||
|
||||
@@ -74,6 +74,7 @@ public class MockPortalContext implements PortalContext {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPortalInfo() {
|
||||
return "MockPortal/1.0";
|
||||
}
|
||||
@@ -82,18 +83,22 @@ public class MockPortalContext implements PortalContext {
|
||||
this.properties.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String name) {
|
||||
return this.properties.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getPropertyNames() {
|
||||
return Collections.enumeration(this.properties.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<PortletMode> getSupportedPortletModes() {
|
||||
return Collections.enumeration(this.portletModes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<WindowState> getSupportedWindowStates() {
|
||||
return Collections.enumeration(this.windowStates);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,12 @@ public class MockPortletConfig implements PortletConfig {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPortletName() {
|
||||
return this.portletName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletContext getPortletContext() {
|
||||
return this.portletContext;
|
||||
}
|
||||
@@ -109,6 +111,7 @@ public class MockPortletConfig implements PortletConfig {
|
||||
this.resourceBundles.put(locale, resourceBundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceBundle getResourceBundle(Locale locale) {
|
||||
Assert.notNull(locale, "Locale must not be null");
|
||||
return this.resourceBundles.get(locale);
|
||||
@@ -119,11 +122,13 @@ public class MockPortletConfig implements PortletConfig {
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
@@ -132,6 +137,7 @@ public class MockPortletConfig implements PortletConfig {
|
||||
this.publicRenderParameterNames.add(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getPublicRenderParameterNames() {
|
||||
return Collections.enumeration(this.publicRenderParameterNames);
|
||||
}
|
||||
@@ -140,6 +146,7 @@ public class MockPortletConfig implements PortletConfig {
|
||||
this.defaultNamespace = defaultNamespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultNamespace() {
|
||||
return this.defaultNamespace;
|
||||
}
|
||||
@@ -148,6 +155,7 @@ public class MockPortletConfig implements PortletConfig {
|
||||
this.publishingEventQNames.add(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<QName> getPublishingEventQNames() {
|
||||
return Collections.enumeration(this.publishingEventQNames);
|
||||
}
|
||||
@@ -156,6 +164,7 @@ public class MockPortletConfig implements PortletConfig {
|
||||
this.processingEventQNames.add(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<QName> getProcessingEventQNames() {
|
||||
return Collections.enumeration(this.processingEventQNames);
|
||||
}
|
||||
@@ -164,6 +173,7 @@ public class MockPortletConfig implements PortletConfig {
|
||||
this.supportedLocales.add(locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<Locale> getSupportedLocales() {
|
||||
return Collections.enumeration(this.supportedLocales);
|
||||
}
|
||||
@@ -176,6 +186,7 @@ public class MockPortletConfig implements PortletConfig {
|
||||
this.containerRuntimeOptions.put(key, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getContainerRuntimeOptions() {
|
||||
return Collections.unmodifiableMap(this.containerRuntimeOptions);
|
||||
}
|
||||
|
||||
@@ -126,10 +126,12 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getServerInfo() {
|
||||
return "MockPortal/1.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletRequestDispatcher getRequestDispatcher(String path) {
|
||||
if (!path.startsWith("/")) {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -138,10 +140,12 @@ public class MockPortletContext implements PortletContext {
|
||||
return new MockPortletRequestDispatcher(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletRequestDispatcher getNamedDispatcher(String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String path) {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
try {
|
||||
@@ -153,18 +157,22 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMajorVersion() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinorVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMimeType(String filePath) {
|
||||
return MimeTypeResolver.getMimeType(filePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealPath(String path) {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
try {
|
||||
@@ -176,6 +184,7 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getResourcePaths(String path) {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
try {
|
||||
@@ -194,6 +203,7 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String path) throws MalformedURLException {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
try {
|
||||
@@ -205,14 +215,17 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return new Vector<String>(this.attributes.keySet()).elements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
if (value != null) {
|
||||
this.attributes.put(name, value);
|
||||
@@ -222,6 +235,7 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
this.attributes.remove(name);
|
||||
}
|
||||
@@ -231,19 +245,23 @@ public class MockPortletContext implements PortletContext {
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message, Throwable t) {
|
||||
logger.info(message, t);
|
||||
}
|
||||
@@ -252,6 +270,7 @@ public class MockPortletContext implements PortletContext {
|
||||
this.portletContextName = portletContextName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPortletContextName() {
|
||||
return this.portletContextName;
|
||||
}
|
||||
@@ -260,6 +279,7 @@ public class MockPortletContext implements PortletContext {
|
||||
this.containerRuntimeOptions.add(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getContainerRuntimeOptions() {
|
||||
return Collections.enumeration(this.containerRuntimeOptions);
|
||||
}
|
||||
|
||||
@@ -56,27 +56,32 @@ public class MockPortletPreferences implements PortletPreferences {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(String key) {
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
return this.readOnly.contains(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(String key, String def) {
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
String[] values = this.preferences.get(key);
|
||||
return (values != null && values.length > 0 ? values[0] : def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getValues(String key, String[] def) {
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
String[] values = this.preferences.get(key);
|
||||
return (values != null && values.length > 0 ? values : def);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String key, String value) throws ReadOnlyException {
|
||||
setValues(key, new String[] {value});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValues(String key, String[] values) throws ReadOnlyException {
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
if (isReadOnly(key)) {
|
||||
@@ -85,14 +90,17 @@ public class MockPortletPreferences implements PortletPreferences {
|
||||
this.preferences.put(key, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getNames() {
|
||||
return Collections.enumeration(this.preferences.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getMap() {
|
||||
return Collections.unmodifiableMap(this.preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(String key) throws ReadOnlyException {
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
if (isReadOnly(key)) {
|
||||
@@ -105,6 +113,7 @@ public class MockPortletPreferences implements PortletPreferences {
|
||||
this.preferencesValidator = preferencesValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void store() throws IOException, ValidatorException {
|
||||
if (this.preferencesValidator != null) {
|
||||
this.preferencesValidator.validate(this);
|
||||
|
||||
@@ -174,10 +174,12 @@ public class MockPortletRequest implements PortletRequest {
|
||||
// PortletRequest methods
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean isWindowStateAllowed(WindowState windowState) {
|
||||
return CollectionUtils.contains(this.portalContext.getSupportedWindowStates(), windowState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPortletModeAllowed(PortletMode portletMode) {
|
||||
return CollectionUtils.contains(this.portalContext.getSupportedPortletModes(), portletMode);
|
||||
}
|
||||
@@ -187,6 +189,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.portletMode = portletMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletMode getPortletMode() {
|
||||
return this.portletMode;
|
||||
}
|
||||
@@ -196,6 +199,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.windowState = windowState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowState getWindowState() {
|
||||
return this.windowState;
|
||||
}
|
||||
@@ -205,6 +209,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.portletPreferences = preferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletPreferences getPreferences() {
|
||||
return this.portletPreferences;
|
||||
}
|
||||
@@ -217,10 +222,12 @@ public class MockPortletRequest implements PortletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletSession getPortletSession() {
|
||||
return getPortletSession(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletSession getPortletSession(boolean create) {
|
||||
checkActive();
|
||||
// Reset session if invalidated.
|
||||
@@ -266,21 +273,25 @@ public class MockPortletRequest implements PortletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
Assert.notNull(key, "Property key must not be null");
|
||||
List<String> list = this.properties.get(key);
|
||||
return (list != null && list.size() > 0 ? list.get(0) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getProperties(String key) {
|
||||
Assert.notNull(key, "property key must not be null");
|
||||
return Collections.enumeration(this.properties.get(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getPropertyNames() {
|
||||
return Collections.enumeration(this.properties.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortalContext getPortalContext() {
|
||||
return this.portalContext;
|
||||
}
|
||||
@@ -289,6 +300,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.authType = authType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return this.authType;
|
||||
}
|
||||
@@ -297,6 +309,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContextPath() {
|
||||
return this.contextPath;
|
||||
}
|
||||
@@ -305,6 +318,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.remoteUser = remoteUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteUser() {
|
||||
return this.remoteUser;
|
||||
}
|
||||
@@ -313,6 +327,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.userPrincipal = userPrincipal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
return this.userPrincipal;
|
||||
}
|
||||
@@ -321,15 +336,18 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.userRoles.add(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserInRole(String role) {
|
||||
return this.userRoles.contains(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
checkActive();
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
checkActive();
|
||||
return new Vector<String>(this.attributes.keySet()).elements();
|
||||
@@ -370,19 +388,23 @@ public class MockPortletRequest implements PortletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
String[] arr = this.parameters.get(name);
|
||||
return (arr != null && arr.length > 0 ? arr[0] : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getParameterNames() {
|
||||
return Collections.enumeration(this.parameters.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
return this.parameters.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
return Collections.unmodifiableMap(this.parameters);
|
||||
}
|
||||
@@ -391,10 +413,12 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.secure = secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return this.secure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
checkActive();
|
||||
if (value != null) {
|
||||
@@ -405,11 +429,13 @@ public class MockPortletRequest implements PortletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
checkActive();
|
||||
this.attributes.remove(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestedSessionId() {
|
||||
PortletSession session = this.getPortletSession();
|
||||
return (session != null ? session.getId() : null);
|
||||
@@ -419,6 +445,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.requestedSessionIdValid = requestedSessionIdValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdValid() {
|
||||
return this.requestedSessionIdValid;
|
||||
}
|
||||
@@ -431,10 +458,12 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.responseContentTypes.add(0, responseContentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResponseContentType() {
|
||||
return this.responseContentTypes.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getResponseContentTypes() {
|
||||
return Collections.enumeration(this.responseContentTypes);
|
||||
}
|
||||
@@ -447,10 +476,12 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.locales.add(0, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return this.locales.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<Locale> getLocales() {
|
||||
return Collections.enumeration(this.locales);
|
||||
}
|
||||
@@ -459,6 +490,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return this.scheme;
|
||||
}
|
||||
@@ -467,6 +499,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return this.serverName;
|
||||
}
|
||||
@@ -475,6 +508,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return this.serverPort;
|
||||
}
|
||||
@@ -483,6 +517,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.windowID = windowID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWindowID() {
|
||||
return this.windowID;
|
||||
}
|
||||
@@ -491,10 +526,12 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.cookies = cookies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cookie[] getCookies() {
|
||||
return this.cookies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getPrivateParameterMap() {
|
||||
if (!this.publicParameterNames.isEmpty()) {
|
||||
Map<String, String[]> filtered = new LinkedHashMap<String, String[]>();
|
||||
@@ -510,6 +547,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getPublicParameterMap() {
|
||||
if (!this.publicParameterNames.isEmpty()) {
|
||||
Map<String, String[]> filtered = new LinkedHashMap<String, String[]>();
|
||||
|
||||
@@ -53,10 +53,12 @@ public class MockPortletRequestDispatcher implements PortletRequestDispatcher {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void include(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||
include((PortletRequest) request, (PortletResponse) response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void include(PortletRequest request, PortletResponse response) throws PortletException, IOException {
|
||||
Assert.notNull(request, "Request must not be null");
|
||||
Assert.notNull(response, "Response must not be null");
|
||||
@@ -69,6 +71,7 @@ public class MockPortletRequestDispatcher implements PortletRequestDispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forward(PortletRequest request, PortletResponse response) throws PortletException, IOException {
|
||||
Assert.notNull(request, "Request must not be null");
|
||||
Assert.notNull(response, "Response must not be null");
|
||||
|
||||
@@ -85,6 +85,7 @@ public class MockPortletResponse implements PortletResponse {
|
||||
// PortletResponse methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void addProperty(String key, String value) {
|
||||
Assert.notNull(key, "Property key must not be null");
|
||||
String[] oldArr = this.properties.get(key);
|
||||
@@ -99,6 +100,7 @@ public class MockPortletResponse implements PortletResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String key, String value) {
|
||||
Assert.notNull(key, "Property key must not be null");
|
||||
this.properties.put(key, new String[] {value});
|
||||
@@ -119,6 +121,7 @@ public class MockPortletResponse implements PortletResponse {
|
||||
return this.properties.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeURL(String path) {
|
||||
return path;
|
||||
}
|
||||
@@ -127,10 +130,12 @@ public class MockPortletResponse implements PortletResponse {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return this.namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProperty(Cookie cookie) {
|
||||
Assert.notNull(cookie, "Cookie must not be null");
|
||||
this.cookies.add(cookie);
|
||||
@@ -150,6 +155,7 @@ public class MockPortletResponse implements PortletResponse {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProperty(String key, Element value) {
|
||||
Assert.notNull(key, "Property key must not be null");
|
||||
Element[] oldArr = this.xmlProperties.get(key);
|
||||
@@ -180,6 +186,7 @@ public class MockPortletResponse implements PortletResponse {
|
||||
return this.xmlProperties.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element createElement(String tagName) throws DOMException {
|
||||
if (this.xmlDocument == null) {
|
||||
try {
|
||||
|
||||
@@ -77,10 +77,12 @@ public class MockPortletSession implements PortletSession {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
return this.portletAttributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name, int scope) {
|
||||
if (scope == PortletSession.PORTLET_SCOPE) {
|
||||
return this.portletAttributes.get(name);
|
||||
@@ -91,10 +93,12 @@ public class MockPortletSession implements PortletSession {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return new Vector<String>(this.portletAttributes.keySet()).elements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames(int scope) {
|
||||
if (scope == PortletSession.PORTLET_SCOPE) {
|
||||
return new Vector<String>(this.portletAttributes.keySet()).elements();
|
||||
@@ -105,10 +109,12 @@ public class MockPortletSession implements PortletSession {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTime() {
|
||||
return this.creationTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
@@ -118,10 +124,12 @@ public class MockPortletSession implements PortletSession {
|
||||
setNew(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastAccessedTime() {
|
||||
return this.lastAccessedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInactiveInterval() {
|
||||
return this.maxInactiveInterval;
|
||||
}
|
||||
@@ -147,6 +155,7 @@ public class MockPortletSession implements PortletSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
this.invalid = true;
|
||||
clearAttributes();
|
||||
@@ -160,14 +169,17 @@ public class MockPortletSession implements PortletSession {
|
||||
this.isNew = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return this.isNew;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
this.portletAttributes.remove(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name, int scope) {
|
||||
if (scope == PortletSession.PORTLET_SCOPE) {
|
||||
this.portletAttributes.remove(name);
|
||||
@@ -177,6 +189,7 @@ public class MockPortletSession implements PortletSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
if (value != null) {
|
||||
this.portletAttributes.put(name, value);
|
||||
@@ -186,6 +199,7 @@ public class MockPortletSession implements PortletSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value, int scope) {
|
||||
if (scope == PortletSession.PORTLET_SCOPE) {
|
||||
if (value != null) {
|
||||
@@ -205,18 +219,22 @@ public class MockPortletSession implements PortletSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxInactiveInterval(int interval) {
|
||||
this.maxInactiveInterval = interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletContext getPortletContext() {
|
||||
return this.portletContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAttributeMap() {
|
||||
return Collections.unmodifiableMap(this.portletAttributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAttributeMap(int scope) {
|
||||
if (scope == PortletSession.PORTLET_SCOPE) {
|
||||
return Collections.unmodifiableMap(this.portletAttributes);
|
||||
|
||||
@@ -69,6 +69,7 @@ public class MockPortletURL extends MockBaseURL implements PortletURL {
|
||||
// PortletURL methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void setWindowState(WindowState windowState) throws WindowStateException {
|
||||
if (!CollectionUtils.contains(this.portalContext.getSupportedWindowStates(), windowState)) {
|
||||
throw new WindowStateException("WindowState not supported", windowState);
|
||||
@@ -76,10 +77,12 @@ public class MockPortletURL extends MockBaseURL implements PortletURL {
|
||||
this.windowState = windowState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowState getWindowState() {
|
||||
return this.windowState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPortletMode(PortletMode portletMode) throws PortletModeException {
|
||||
if (!CollectionUtils.contains(this.portalContext.getSupportedPortletModes(), portletMode)) {
|
||||
throw new PortletModeException("PortletMode not supported", portletMode);
|
||||
@@ -87,10 +90,12 @@ public class MockPortletURL extends MockBaseURL implements PortletURL {
|
||||
this.portletMode = portletMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletMode getPortletMode() {
|
||||
return this.portletMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePublicRenderParameter(String name) {
|
||||
this.parameters.remove(name);
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ public class MockRenderRequest extends MockPortletRequest implements RenderReque
|
||||
return RENDER_PHASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getETag() {
|
||||
return getProperty(RenderRequest.ETAG);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class MockRenderResponse extends MockMimeResponse implements RenderRespon
|
||||
// RenderResponse methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
@@ -77,6 +78,7 @@ public class MockRenderResponse extends MockMimeResponse implements RenderRespon
|
||||
return this.title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNextPossiblePortletModes(Collection<PortletMode> portletModes) {
|
||||
this.nextPossiblePortletModes = portletModes;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public class MockResourceRequest extends MockClientDataRequest implements Resour
|
||||
this.resourceID = resourceID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourceID() {
|
||||
return this.resourceID;
|
||||
}
|
||||
@@ -105,10 +106,12 @@ public class MockResourceRequest extends MockClientDataRequest implements Resour
|
||||
this.cacheability = cacheLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheability() {
|
||||
return this.cacheability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getETag() {
|
||||
return getProperty(RenderRequest.ETAG);
|
||||
}
|
||||
@@ -121,6 +124,7 @@ public class MockResourceRequest extends MockClientDataRequest implements Resour
|
||||
this.privateRenderParameterMap.put(key, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getPrivateRenderParameterMap() {
|
||||
return Collections.unmodifiableMap(this.privateRenderParameterMap);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class MockResourceResponse extends MockMimeResponse implements ResourceRe
|
||||
private int contentLength = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void setContentLength(int len) {
|
||||
this.contentLength = len;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public class MockResourceURL extends MockBaseURL implements ResourceURL {
|
||||
// ResourceURL methods
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void setResourceID(String resourceID) {
|
||||
this.resourceID = resourceID;
|
||||
}
|
||||
@@ -44,10 +45,12 @@ public class MockResourceURL extends MockBaseURL implements ResourceURL {
|
||||
return this.resourceID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCacheability(String cacheLevel) {
|
||||
this.cacheability = cacheLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCacheability() {
|
||||
return this.cacheability;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ public class MockStateAwareResponse extends MockPortletResponse implements State
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setWindowState(WindowState windowState) throws WindowStateException {
|
||||
if (!CollectionUtils.contains(getPortalContext().getSupportedWindowStates(), windowState)) {
|
||||
throw new WindowStateException("WindowState not supported", windowState);
|
||||
@@ -75,10 +76,12 @@ public class MockStateAwareResponse extends MockPortletResponse implements State
|
||||
this.windowState = windowState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowState getWindowState() {
|
||||
return this.windowState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPortletMode(PortletMode portletMode) throws PortletModeException {
|
||||
if (!CollectionUtils.contains(getPortalContext().getSupportedPortletModes(), portletMode)) {
|
||||
throw new PortletModeException("PortletMode not supported", portletMode);
|
||||
@@ -86,22 +89,26 @@ public class MockStateAwareResponse extends MockPortletResponse implements State
|
||||
this.portletMode = portletMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletMode getPortletMode() {
|
||||
return this.portletMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderParameters(Map<String, String[]> parameters) {
|
||||
Assert.notNull(parameters, "Parameters Map must not be null");
|
||||
this.renderParameters.clear();
|
||||
this.renderParameters.putAll(parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderParameter(String key, String value) {
|
||||
Assert.notNull(key, "Parameter key must not be null");
|
||||
Assert.notNull(value, "Parameter value must not be null");
|
||||
this.renderParameters.put(key, new String[] {value});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderParameter(String key, String[] values) {
|
||||
Assert.notNull(key, "Parameter key must not be null");
|
||||
Assert.notNull(values, "Parameter values must not be null");
|
||||
@@ -123,18 +130,22 @@ public class MockStateAwareResponse extends MockPortletResponse implements State
|
||||
return this.renderParameters.keySet().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getRenderParameterMap() {
|
||||
return Collections.unmodifiableMap(this.renderParameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePublicRenderParameter(String name) {
|
||||
this.renderParameters.remove(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEvent(QName name, Serializable value) {
|
||||
this.events.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEvent(String name, Serializable value) {
|
||||
this.events.put(new QName(name), value);
|
||||
}
|
||||
|
||||
@@ -59,85 +59,105 @@ public class ServletWrappingPortletContext implements PortletContext {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getServerInfo() {
|
||||
return this.servletContext.getServerInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletRequestDispatcher getRequestDispatcher(String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletRequestDispatcher getNamedDispatcher(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String path) {
|
||||
return this.servletContext.getResourceAsStream(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMajorVersion() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinorVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMimeType(String file) {
|
||||
return this.servletContext.getMimeType(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealPath(String path) {
|
||||
return this.servletContext.getRealPath(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<String> getResourcePaths(String path) {
|
||||
return this.servletContext.getResourcePaths(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String path) throws MalformedURLException {
|
||||
return this.servletContext.getResource(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
return this.servletContext.getAttribute(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return this.servletContext.getAttributeNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitParameter(String name) {
|
||||
return this.servletContext.getInitParameter(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return this.servletContext.getInitParameterNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String msg) {
|
||||
this.servletContext.log(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message, Throwable throwable) {
|
||||
this.servletContext.log(message, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
this.servletContext.removeAttribute(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object object) {
|
||||
this.servletContext.setAttribute(name, object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPortletContextName() {
|
||||
return this.servletContext.getServletContextName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getContainerRuntimeOptions() {
|
||||
return Collections.enumeration(new HashSet<String>());
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ public abstract class AbstractDependencyInjectionSpringContextTests extends Abst
|
||||
* message will be written to the log.
|
||||
* @see #injectDependencies()
|
||||
*/
|
||||
@Override
|
||||
protected void prepareTestInstance() throws Exception {
|
||||
if (getApplicationContext() == null) {
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
|
||||
@@ -95,6 +95,7 @@ public abstract class AbstractSingleSpringContextTests extends AbstractSpringCon
|
||||
* This implementation is final. Override {@code onSetUp} for custom behavior.
|
||||
* @see #onSetUp()
|
||||
*/
|
||||
@Override
|
||||
protected final void setUp() throws Exception {
|
||||
// lazy load, in case getApplicationContext() has not yet been called.
|
||||
if (this.applicationContext == null) {
|
||||
@@ -136,6 +137,7 @@ public abstract class AbstractSingleSpringContextTests extends AbstractSpringCon
|
||||
* custom behavior.
|
||||
* @see #onTearDown()
|
||||
*/
|
||||
@Override
|
||||
protected final void tearDown() throws Exception {
|
||||
onTearDown();
|
||||
}
|
||||
@@ -168,6 +170,7 @@ public abstract class AbstractSingleSpringContextTests extends AbstractSpringCon
|
||||
* {@code contextKey()} returns.
|
||||
* @see #getConfigLocations()
|
||||
*/
|
||||
@Override
|
||||
protected ConfigurableApplicationContext loadContext(Object key) throws Exception {
|
||||
return loadContextLocations((String[]) key);
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ public abstract class AbstractTransactionalDataSourceSpringContextTests
|
||||
* cleared, as a defensive measure against accidental <i>permanent</i> wiping of a database.
|
||||
* @see org.springframework.test.AbstractTransactionalSpringContextTests#setComplete()
|
||||
*/
|
||||
@Override
|
||||
protected final void setComplete() {
|
||||
if (this.zappedTables) {
|
||||
throw new IllegalStateException("Cannot set complete after deleting tables");
|
||||
|
||||
@@ -187,6 +187,7 @@ public abstract class AbstractTransactionalSpringContextTests extends AbstractDe
|
||||
* @throws Exception simply let any exception propagate
|
||||
* @see #onTearDown()
|
||||
*/
|
||||
@Override
|
||||
protected void onSetUp() throws Exception {
|
||||
this.complete = !this.isRollback();
|
||||
|
||||
@@ -250,6 +251,7 @@ public abstract class AbstractTransactionalSpringContextTests extends AbstractDe
|
||||
* @throws Exception simply let any exception propagate
|
||||
* @see #onSetUp()
|
||||
*/
|
||||
@Override
|
||||
protected void onTearDown() throws Exception {
|
||||
// Call onTearDownInTransaction and end transaction if the transaction
|
||||
// is still active.
|
||||
|
||||
@@ -66,6 +66,7 @@ public abstract class ConditionalTestCase extends TestCase {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runBare() throws Throwable {
|
||||
// getName will return the name of the method being run
|
||||
if (isDisabledInThisEnvironment(getName())) {
|
||||
|
||||
@@ -174,6 +174,7 @@ public abstract class AbstractAnnotationAwareTransactionalTests extends
|
||||
|
||||
// Let JUnit handle execution. We're just changing the state of the test class first.
|
||||
runTestTimed(new TestExecutionCallback() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
try {
|
||||
AbstractAnnotationAwareTransactionalTests.super.runBare();
|
||||
|
||||
@@ -50,6 +50,7 @@ public class SystemProfileValueSource implements ProfileValueSource {
|
||||
* system properties.
|
||||
* @see System#getProperty(String)
|
||||
*/
|
||||
@Override
|
||||
public String get(String key) {
|
||||
Assert.hasText(key, "'key' must not be empty");
|
||||
return System.getProperty(key);
|
||||
|
||||
@@ -177,6 +177,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
|
||||
* Sets the {@link ApplicationContext} to be used by this test instance,
|
||||
* provided via {@link ApplicationContextAware} semantics.
|
||||
*/
|
||||
@Override
|
||||
public final void setApplicationContext(final ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
@@ -215,6 +216,7 @@ public abstract class AbstractJUnit38SpringContextTests extends TestCase impleme
|
||||
|
||||
runTestTimed(new TestExecutionCallback() {
|
||||
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
runManaged(testMethod);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ public abstract class AbstractJUnit4SpringContextTests implements ApplicationCon
|
||||
* Set the {@link ApplicationContext} to be used by this test instance,
|
||||
* provided via {@link ApplicationContextAware} semantics.
|
||||
*/
|
||||
@Override
|
||||
public final void setApplicationContext(final ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ public abstract class AbstractContextLoader implements SmartContextLoader {
|
||||
* @since 3.1
|
||||
* @see #processLocations(Class, String...)
|
||||
*/
|
||||
@Override
|
||||
public void processContextConfiguration(ContextConfigurationAttributes configAttributes) {
|
||||
String[] processedLocations = processLocations(configAttributes.getDeclaringClass(),
|
||||
configAttributes.getLocations());
|
||||
@@ -174,6 +175,7 @@ public abstract class AbstractContextLoader implements SmartContextLoader {
|
||||
* @see org.springframework.test.context.ContextLoader#processLocations(Class, String...)
|
||||
* @see #processContextConfiguration(ContextConfigurationAttributes)
|
||||
*/
|
||||
@Override
|
||||
public final String[] processLocations(Class<?> clazz, String... locations) {
|
||||
return (ObjectUtils.isEmpty(locations) && isGenerateDefaultLocations()) ? generateDefaultLocations(clazz)
|
||||
: modifyLocations(clazz, locations);
|
||||
|
||||
@@ -142,6 +142,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
* context configuration; or if both candidate loaders detect defaults for the
|
||||
* supplied context configuration
|
||||
*/
|
||||
@Override
|
||||
public void processContextConfiguration(final ContextConfigurationAttributes configAttributes) {
|
||||
|
||||
Assert.notNull(configAttributes, "configAttributes must not be null");
|
||||
@@ -236,6 +237,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
* @throws IllegalStateException if neither candidate loader is capable of loading an
|
||||
* {@code ApplicationContext} from the supplied merged context configuration
|
||||
*/
|
||||
@Override
|
||||
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
|
||||
Assert.notNull(mergedConfig, "mergedConfig must not be null");
|
||||
|
||||
@@ -268,6 +270,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
* {@link #processContextConfiguration(ContextConfigurationAttributes)} instead.
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
@Override
|
||||
public final String[] processLocations(Class<?> clazz, String... locations) {
|
||||
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. "
|
||||
+ "Call processContextConfiguration(ContextConfigurationAttributes) instead.");
|
||||
@@ -279,6 +282,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
* {@link #loadContext(MergedContextConfiguration)} instead.
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
@Override
|
||||
public final ApplicationContext loadContext(String... locations) throws Exception {
|
||||
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. "
|
||||
+ "Call loadContext(MergedContextConfiguration) instead.");
|
||||
|
||||
@@ -90,6 +90,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
|
||||
* @see GenericApplicationContext
|
||||
* @since 3.1
|
||||
*/
|
||||
@Override
|
||||
public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("Loading ApplicationContext for merged context configuration [%s].",
|
||||
@@ -142,6 +143,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
|
||||
* @see #loadContext(MergedContextConfiguration)
|
||||
* @since 2.5
|
||||
*/
|
||||
@Override
|
||||
public final ConfigurableApplicationContext loadContext(String... locations) throws Exception {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("Loading ApplicationContext for locations [%s].",
|
||||
|
||||
@@ -34,6 +34,7 @@ public abstract class AbstractTestExecutionListener implements TestExecutionList
|
||||
* The default implementation is <em>empty</em>. Can be overridden by
|
||||
* subclasses as necessary.
|
||||
*/
|
||||
@Override
|
||||
public void beforeTestClass(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
@@ -42,6 +43,7 @@ public abstract class AbstractTestExecutionListener implements TestExecutionList
|
||||
* The default implementation is <em>empty</em>. Can be overridden by
|
||||
* subclasses as necessary.
|
||||
*/
|
||||
@Override
|
||||
public void prepareTestInstance(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
@@ -50,6 +52,7 @@ public abstract class AbstractTestExecutionListener implements TestExecutionList
|
||||
* The default implementation is <em>empty</em>. Can be overridden by
|
||||
* subclasses as necessary.
|
||||
*/
|
||||
@Override
|
||||
public void beforeTestMethod(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
@@ -58,6 +61,7 @@ public abstract class AbstractTestExecutionListener implements TestExecutionList
|
||||
* The default implementation is <em>empty</em>. Can be overridden by
|
||||
* subclasses as necessary.
|
||||
*/
|
||||
@Override
|
||||
public void afterTestMethod(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
@@ -66,6 +70,7 @@ public abstract class AbstractTestExecutionListener implements TestExecutionList
|
||||
* The default implementation is <em>empty</em>. Can be overridden by
|
||||
* subclasses as necessary.
|
||||
*/
|
||||
@Override
|
||||
public void afterTestClass(TestContext testContext) throws Exception {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader
|
||||
* @see #isGenerateDefaultLocations()
|
||||
* @see #detectDefaultConfigurationClasses(Class)
|
||||
*/
|
||||
@Override
|
||||
public void processContextConfiguration(ContextConfigurationAttributes configAttributes) {
|
||||
if (ObjectUtils.isEmpty(configAttributes.getClasses()) && isGenerateDefaultLocations()) {
|
||||
Class<?>[] defaultConfigClasses = detectDefaultConfigurationClasses(configAttributes.getDeclaringClass());
|
||||
|
||||
@@ -36,10 +36,12 @@ public class DelegatingSmartContextLoader extends AbstractDelegatingSmartContext
|
||||
private final SmartContextLoader annotationConfigLoader = new AnnotationConfigContextLoader();
|
||||
|
||||
|
||||
@Override
|
||||
protected SmartContextLoader getXmlLoader() {
|
||||
return this.xmlLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SmartContextLoader getAnnotationConfigLoader() {
|
||||
return this.annotationConfigLoader;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
||||
*
|
||||
* @param applicationContext the applicationContext to set
|
||||
*/
|
||||
@Override
|
||||
public final void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
@@ -151,6 +152,7 @@ public abstract class AbstractTestNGSpringContextTests implements IHookable, App
|
||||
* @see org.testng.IHookable#run(org.testng.IHookCallBack,
|
||||
* org.testng.ITestResult)
|
||||
*/
|
||||
@Override
|
||||
public void run(IHookCallBack callBack, ITestResult testResult) {
|
||||
callBack.runTestMethod(testResult);
|
||||
|
||||
|
||||
@@ -153,6 +153,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
|
||||
if (transactionAttribute != null) {
|
||||
transactionAttribute = new DelegatingTransactionAttribute(transactionAttribute) {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return testMethod.getName();
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
|
||||
* @see org.springframework.test.context.SmartContextLoader#loadContext(MergedContextConfiguration)
|
||||
* @see GenericWebApplicationContext
|
||||
*/
|
||||
@Override
|
||||
public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
|
||||
|
||||
if (!(mergedConfig instanceof WebMergedContextConfiguration)) {
|
||||
@@ -216,6 +217,7 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
|
||||
* @see org.springframework.test.context.ContextLoader#loadContext(java.lang.String[])
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
@Override
|
||||
public final ApplicationContext loadContext(String... locations) throws Exception {
|
||||
throw new UnsupportedOperationException(
|
||||
"AbstractGenericWebContextLoader does not support the loadContext(String... locations) method");
|
||||
|
||||
@@ -75,6 +75,7 @@ public class AnnotationConfigWebContextLoader extends AbstractGenericWebContextL
|
||||
* @see #isGenerateDefaultLocations()
|
||||
* @see #detectDefaultConfigurationClasses(Class)
|
||||
*/
|
||||
@Override
|
||||
public void processContextConfiguration(ContextConfigurationAttributes configAttributes) {
|
||||
if (ObjectUtils.isEmpty(configAttributes.getClasses()) && isGenerateDefaultLocations()) {
|
||||
Class<?>[] defaultConfigClasses = detectDefaultConfigurationClasses(configAttributes.getDeclaringClass());
|
||||
|
||||
@@ -41,6 +41,7 @@ public class GenericXmlWebContextLoader extends AbstractGenericWebContextLoader
|
||||
/**
|
||||
* Returns "{@code -context.xml}".
|
||||
*/
|
||||
@Override
|
||||
protected String getResourceSuffix() {
|
||||
return "-context.xml";
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener
|
||||
* @see TestExecutionListener#prepareTestInstance(TestContext)
|
||||
* @see #setUpRequestContextIfNecessary(TestContext)
|
||||
*/
|
||||
@Override
|
||||
public void prepareTestInstance(TestContext testContext) throws Exception {
|
||||
setUpRequestContextIfNecessary(testContext);
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener
|
||||
* @see TestExecutionListener#beforeTestMethod(TestContext)
|
||||
* @see #setUpRequestContextIfNecessary(TestContext)
|
||||
*/
|
||||
@Override
|
||||
public void beforeTestMethod(TestContext testContext) throws Exception {
|
||||
setUpRequestContextIfNecessary(testContext);
|
||||
}
|
||||
@@ -91,6 +93,7 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener
|
||||
*
|
||||
* @see TestExecutionListener#afterTestMethod(TestContext)
|
||||
*/
|
||||
@Override
|
||||
public void afterTestMethod(TestContext testContext) throws Exception {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("Resetting RequestContextHolder for test context %s.", testContext));
|
||||
|
||||
@@ -37,10 +37,12 @@ public class WebDelegatingSmartContextLoader extends AbstractDelegatingSmartCont
|
||||
private final SmartContextLoader annotationConfigLoader = new AnnotationConfigWebContextLoader();
|
||||
|
||||
|
||||
@Override
|
||||
protected SmartContextLoader getXmlLoader() {
|
||||
return this.xmlLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SmartContextLoader getAnnotationConfigLoader() {
|
||||
return this.annotationConfigLoader;
|
||||
}
|
||||
|
||||
@@ -330,6 +330,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
this.ltw = ltw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof LocalContainerEntityManagerFactoryBean) {
|
||||
((LocalContainerEntityManagerFactoryBean) bean).setLoadTimeWeaver(this.ltw);
|
||||
@@ -350,6 +351,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
this.shadowingClassLoader = shadowingClassLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTransformer(ClassFileTransformer transformer) {
|
||||
try {
|
||||
Method addClassFileTransformer =
|
||||
@@ -362,10 +364,12 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getInstrumentableClassLoader() {
|
||||
return this.shadowingClassLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getThrowawayClassLoader() {
|
||||
// Be sure to copy the same resource overrides and same class file transformers:
|
||||
// We want the throwaway class loader to behave like the instrumentable class loader.
|
||||
|
||||
Reference in New Issue
Block a user