Add @Override annotations to test sources
Issue: SPR-10129
This commit is contained in:
@@ -51,12 +51,14 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanName(String beanName) {
|
||||
if (this.beanName == null || beanName == null) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
@@ -75,10 +77,12 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.destroyed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasDestroyed() {
|
||||
return destroyed;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class NestedTestBean implements INestedTestBean {
|
||||
this.company = (company != null ? company : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
@@ -145,6 +146,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
@@ -161,10 +163,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return postProcessed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -180,10 +184,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
@@ -196,14 +202,17 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.jedi = jedi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITestBean getSpouse() {
|
||||
return (spouses != null ? spouses[0] : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpouse(ITestBean spouse) {
|
||||
this.spouses = new ITestBean[] {spouse};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITestBean[] getSpouses() {
|
||||
return spouses;
|
||||
}
|
||||
@@ -230,10 +239,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getStringArray() {
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStringArray(String[] stringArray) {
|
||||
this.stringArray = stringArray;
|
||||
}
|
||||
@@ -302,6 +313,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.someProperties = someProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INestedTestBean getDoctor() {
|
||||
return doctor;
|
||||
}
|
||||
@@ -310,6 +322,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.doctor = doctor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INestedTestBean getLawyer() {
|
||||
return lawyer;
|
||||
}
|
||||
@@ -342,6 +355,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
this.someBoolean = someBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexedTestBean getNestedIndexedBean() {
|
||||
return nestedIndexedBean;
|
||||
}
|
||||
@@ -370,18 +384,21 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
/**
|
||||
* @see org.springframework.beans.ITestBean#exceptional(Throwable)
|
||||
*/
|
||||
@Override
|
||||
public void exceptional(Throwable t) throws Throwable {
|
||||
if (t != null) {
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unreliableFileOperation() throws IOException {
|
||||
throw new IOException();
|
||||
}
|
||||
/**
|
||||
* @see org.springframework.beans.ITestBean#returnsThis()
|
||||
*/
|
||||
@Override
|
||||
public Object returnsThis() {
|
||||
return this;
|
||||
}
|
||||
@@ -389,9 +406,11 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
/**
|
||||
* @see org.springframework.beans.IOther#absquatulate()
|
||||
*/
|
||||
@Override
|
||||
public void absquatulate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int haveBirthday() {
|
||||
return age++;
|
||||
}
|
||||
@@ -421,6 +440,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
|
||||
return this.age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object other) {
|
||||
if (this.name != null && other instanceof TestBean) {
|
||||
return this.name.compareTo(((TestBean) other).getName());
|
||||
|
||||
@@ -317,6 +317,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
|
||||
public static class TestBeanEditor extends PropertyEditorSupport {
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
TestBean tb = new TestBean();
|
||||
StringTokenizer st = new StringTokenizer(text, "_");
|
||||
|
||||
@@ -74,6 +74,7 @@ public class DummyFactory
|
||||
* Return if the bean managed by this factory is a singleton.
|
||||
* @see FactoryBean#isSingleton()
|
||||
*/
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return this.singleton;
|
||||
}
|
||||
@@ -85,6 +86,7 @@ public class DummyFactory
|
||||
this.singleton = singleton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
@@ -93,6 +95,7 @@ public class DummyFactory
|
||||
return beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = (AutowireCapableBeanFactory) beanFactory;
|
||||
this.beanFactory.applyBeanPostProcessorsBeforeInitialization(this.testBean, this.beanName);
|
||||
@@ -119,6 +122,7 @@ public class DummyFactory
|
||||
return otherTestBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (initialized) {
|
||||
throw new RuntimeException("Cannot call afterPropertiesSet twice on the one bean");
|
||||
@@ -144,6 +148,7 @@ public class DummyFactory
|
||||
* and prototype mode.
|
||||
* @see FactoryBean#getObject()
|
||||
*/
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
if (isSingleton()) {
|
||||
return this.testBean;
|
||||
@@ -158,11 +163,13 @@ public class DummyFactory
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getObjectType() {
|
||||
return TestBean.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (this.testBean != null) {
|
||||
this.testBean.setName(null);
|
||||
|
||||
@@ -53,6 +53,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
|
||||
return initMethodDeclared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
@@ -61,6 +62,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
|
||||
return beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.owningFactory = beanFactory;
|
||||
}
|
||||
@@ -75,6 +77,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
|
||||
this.postProcessedBeforeInit = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (this.owningFactory == null) {
|
||||
throw new RuntimeException("Factory didn't call setBeanFactory before afterPropertiesSet on lifecycle bean");
|
||||
@@ -126,6 +129,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (this.destroyed) {
|
||||
throw new IllegalStateException("Already destroyed");
|
||||
@@ -140,6 +144,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
|
||||
|
||||
public static class PostProcessor implements BeanPostProcessor {
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
|
||||
if (bean instanceof LifecycleBean) {
|
||||
((LifecycleBean) bean).postProcessBeforeInit();
|
||||
@@ -147,6 +152,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
|
||||
if (bean instanceof LifecycleBean) {
|
||||
((LifecycleBean) bean).postProcessAfterInit();
|
||||
|
||||
@@ -30,6 +30,7 @@ public class MustBeInitialized implements InitializingBean {
|
||||
/**
|
||||
* @see InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.inited = true;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class ACATester implements ApplicationContextAware {
|
||||
|
||||
private ApplicationContext ac;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext ctx) throws ApplicationContextException {
|
||||
// check reinitialization
|
||||
if (this.ac != null) {
|
||||
|
||||
@@ -39,10 +39,12 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
|
||||
|
||||
protected TestListener parentListener = new TestListener();
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.applicationContext = createContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BeanFactory getBeanFactory() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class BeanThatBroadcasts implements ApplicationContextAware {
|
||||
public int receivedCount;
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
if (applicationContext.getDisplayName().indexOf("listener") != -1) {
|
||||
|
||||
@@ -43,6 +43,7 @@ public class BeanThatListens implements ApplicationListener {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
eventCount++;
|
||||
if (beanThatBroadcasts != null) {
|
||||
|
||||
@@ -15,18 +15,21 @@ public class LifecycleContextBean extends LifecycleBean implements ApplicationCo
|
||||
|
||||
protected ApplicationContext owningContext;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
super.setBeanFactory(beanFactory);
|
||||
if (this.owningContext != null)
|
||||
throw new RuntimeException("Factory called setBeanFactory after setApplicationContext");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
super.afterPropertiesSet();
|
||||
if (this.owningContext == null)
|
||||
throw new RuntimeException("Factory didn't call setAppliationContext before afterPropertiesSet on lifecycle bean");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (this.owningFactory == null)
|
||||
throw new RuntimeException("Factory called setApplicationContext before setBeanFactory");
|
||||
|
||||
@@ -21,6 +21,7 @@ public class TestListener implements ApplicationListener {
|
||||
eventCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent e) {
|
||||
++eventCount;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -96,34 +96,42 @@ public class MockMultipartFile implements MultipartFile {
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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 new Vector<String>(this.attributes.keySet()).elements();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -124,10 +124,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(
|
||||
@@ -136,10 +138,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 {
|
||||
@@ -151,18 +155,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 null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRealPath(String path) {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
try {
|
||||
@@ -174,6 +182,7 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getResourcePaths(String path) {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
try {
|
||||
@@ -192,6 +201,7 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String path) throws MalformedURLException {
|
||||
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
|
||||
try {
|
||||
@@ -203,14 +213,17 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String name) {
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
if (value != null) {
|
||||
this.attributes.put(name, value);
|
||||
@@ -220,6 +233,7 @@ public class MockPortletContext implements PortletContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
this.attributes.remove(name);
|
||||
}
|
||||
@@ -229,19 +243,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);
|
||||
}
|
||||
@@ -250,6 +268,7 @@ public class MockPortletContext implements PortletContext {
|
||||
this.portletContextName = portletContextName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPortletContextName() {
|
||||
return this.portletContextName;
|
||||
}
|
||||
@@ -258,6 +277,7 @@ public class MockPortletContext implements PortletContext {
|
||||
this.containerRuntimeOptions.add(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getContainerRuntimeOptions() {
|
||||
return Collections.enumeration(this.containerRuntimeOptions);
|
||||
}
|
||||
|
||||
@@ -171,10 +171,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);
|
||||
}
|
||||
@@ -184,6 +186,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.portletMode = portletMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletMode getPortletMode() {
|
||||
return this.portletMode;
|
||||
}
|
||||
@@ -193,6 +196,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.windowState = windowState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowState getWindowState() {
|
||||
return this.windowState;
|
||||
}
|
||||
@@ -202,6 +206,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.portletPreferences = preferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletPreferences getPreferences() {
|
||||
return this.portletPreferences;
|
||||
}
|
||||
@@ -214,10 +219,12 @@ public class MockPortletRequest implements PortletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletSession getPortletSession() {
|
||||
return getPortletSession(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortletSession getPortletSession(boolean create) {
|
||||
checkActive();
|
||||
// Reset session if invalidated.
|
||||
@@ -261,21 +268,25 @@ public class MockPortletRequest implements PortletRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
Assert.notNull(key, "Property key must not be null");
|
||||
List list = this.properties.get(key);
|
||||
return (list != null && list.size() > 0 ? (String) 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;
|
||||
}
|
||||
@@ -284,6 +295,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.authType = authType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return this.authType;
|
||||
}
|
||||
@@ -292,6 +304,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContextPath() {
|
||||
return this.contextPath;
|
||||
}
|
||||
@@ -300,6 +313,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.remoteUser = remoteUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteUser() {
|
||||
return this.remoteUser;
|
||||
}
|
||||
@@ -308,6 +322,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.userPrincipal = userPrincipal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal() {
|
||||
return this.userPrincipal;
|
||||
}
|
||||
@@ -316,15 +331,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 Collections.enumeration(this.attributes.keySet());
|
||||
@@ -365,19 +383,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);
|
||||
}
|
||||
@@ -386,10 +408,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) {
|
||||
@@ -400,11 +424,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);
|
||||
@@ -414,6 +440,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.requestedSessionIdValid = requestedSessionIdValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequestedSessionIdValid() {
|
||||
return this.requestedSessionIdValid;
|
||||
}
|
||||
@@ -426,10 +453,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);
|
||||
}
|
||||
@@ -442,10 +471,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);
|
||||
}
|
||||
@@ -454,6 +485,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return this.scheme;
|
||||
}
|
||||
@@ -462,6 +494,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return this.serverName;
|
||||
}
|
||||
@@ -470,6 +503,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
return this.serverPort;
|
||||
}
|
||||
@@ -478,6 +512,7 @@ public class MockPortletRequest implements PortletRequest {
|
||||
this.windowID = windowID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWindowID() {
|
||||
return this.windowID;
|
||||
}
|
||||
@@ -486,10 +521,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[]>();
|
||||
@@ -505,6 +542,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 {
|
||||
|
||||
@@ -76,10 +76,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);
|
||||
@@ -90,10 +92,12 @@ public class MockPortletSession implements PortletSession {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return Collections.enumeration(this.portletAttributes.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames(int scope) {
|
||||
if (scope == PortletSession.PORTLET_SCOPE) {
|
||||
return Collections.enumeration(this.portletAttributes.keySet());
|
||||
@@ -104,10 +108,12 @@ public class MockPortletSession implements PortletSession {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCreationTime() {
|
||||
return this.creationTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
@@ -117,10 +123,12 @@ public class MockPortletSession implements PortletSession {
|
||||
setNew(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastAccessedTime() {
|
||||
return this.lastAccessedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInactiveInterval() {
|
||||
return this.maxInactiveInterval;
|
||||
}
|
||||
@@ -146,6 +154,7 @@ public class MockPortletSession implements PortletSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
this.invalid = true;
|
||||
clearAttributes();
|
||||
@@ -159,14 +168,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);
|
||||
@@ -176,6 +188,7 @@ public class MockPortletSession implements PortletSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value) {
|
||||
if (value != null) {
|
||||
this.portletAttributes.put(name, value);
|
||||
@@ -185,6 +198,7 @@ public class MockPortletSession implements PortletSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value, int scope) {
|
||||
if (scope == PortletSession.PORTLET_SCOPE) {
|
||||
if (value != null) {
|
||||
@@ -204,18 +218,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>());
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ import org.springframework.web.portlet.mvc.SimpleControllerHandlerAdapter;
|
||||
*/
|
||||
public class ComplexPortletApplicationContext extends StaticPortletApplicationContext {
|
||||
|
||||
@Override
|
||||
public void refresh() throws BeansException {
|
||||
registerSingleton("standardHandlerAdapter", SimpleControllerHandlerAdapter.class);
|
||||
registerSingleton("portletHandlerAdapter", SimplePortletHandlerAdapter.class);
|
||||
@@ -185,10 +186,12 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class TestController1 implements Controller {
|
||||
|
||||
@Override
|
||||
public void handleActionRequest(ActionRequest request, ActionResponse response) {
|
||||
response.setRenderParameter("result", "test1-action");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception {
|
||||
return null;
|
||||
}
|
||||
@@ -197,8 +200,10 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class TestController2 implements Controller {
|
||||
|
||||
@Override
|
||||
public void handleActionRequest(ActionRequest request, ActionResponse response) {}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception {
|
||||
response.setProperty("result", "test2-view");
|
||||
return null;
|
||||
@@ -208,8 +213,10 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class ViewController implements Controller {
|
||||
|
||||
@Override
|
||||
public void handleActionRequest(ActionRequest request, ActionResponse response) {}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception {
|
||||
return new ModelAndView("someViewName", "result", "view was here");
|
||||
}
|
||||
@@ -218,10 +225,12 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class EditController implements Controller {
|
||||
|
||||
@Override
|
||||
public void handleActionRequest(ActionRequest request, ActionResponse response) {
|
||||
response.setRenderParameter("param", "edit was here");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception {
|
||||
return new ModelAndView(request.getParameter("param"));
|
||||
}
|
||||
@@ -230,10 +239,12 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class HelpController1 implements Controller {
|
||||
|
||||
@Override
|
||||
public void handleActionRequest(ActionRequest request, ActionResponse response) {
|
||||
response.setRenderParameter("param", "help1 was here");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception {
|
||||
return new ModelAndView("help1-view");
|
||||
}
|
||||
@@ -242,10 +253,12 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class HelpController2 implements Controller {
|
||||
|
||||
@Override
|
||||
public void handleActionRequest(ActionRequest request, ActionResponse response) {
|
||||
response.setRenderParameter("param", "help2 was here");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception {
|
||||
return new ModelAndView("help2-view");
|
||||
}
|
||||
@@ -253,12 +266,14 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class RequestLocaleCheckingController implements Controller {
|
||||
|
||||
@Override
|
||||
public void handleActionRequest(ActionRequest request, ActionResponse response) throws PortletException {
|
||||
if (!Locale.CANADA.equals(request.getLocale())) {
|
||||
throw new PortletException("Incorrect Locale in ActionRequest");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response)
|
||||
throws PortletException, IOException {
|
||||
if (!Locale.CANADA.equals(request.getLocale())) {
|
||||
@@ -272,12 +287,14 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class LocaleContextCheckingController implements Controller {
|
||||
|
||||
@Override
|
||||
public void handleActionRequest(ActionRequest request, ActionResponse response) throws PortletException {
|
||||
if (!Locale.CANADA.equals(LocaleContextHolder.getLocale())) {
|
||||
throw new PortletException("Incorrect Locale in LocaleContextHolder");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response)
|
||||
throws PortletException, IOException {
|
||||
if (!Locale.CANADA.equals(LocaleContextHolder.getLocale())) {
|
||||
@@ -293,14 +310,17 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
private PortletConfig portletConfig;
|
||||
|
||||
@Override
|
||||
public void init(PortletConfig portletConfig) throws PortletException {
|
||||
this.portletConfig = portletConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processAction(ActionRequest request, ActionResponse response) throws PortletException {
|
||||
response.setRenderParameter("result", "myPortlet action called");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||
response.getWriter().write("myPortlet was here");
|
||||
}
|
||||
@@ -309,6 +329,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
return this.portletConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.portletConfig = null;
|
||||
}
|
||||
@@ -323,6 +344,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class ExceptionThrowingHandler implements MyHandler {
|
||||
|
||||
@Override
|
||||
public void doSomething(PortletRequest request) throws Exception {
|
||||
if (request.getParameter("fail") != null) {
|
||||
throw new ModelAndViewDefiningException(new ModelAndView("failed-modelandview"));
|
||||
@@ -346,28 +368,34 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class MyHandlerAdapter implements HandlerAdapter, Ordered {
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 99;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Object handler) {
|
||||
return handler != null && MyHandler.class.isAssignableFrom(handler.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleAction(ActionRequest request, ActionResponse response, Object delegate) throws Exception {
|
||||
((MyHandler) delegate).doSomething(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleRender(RenderRequest request, RenderResponse response, Object delegate) throws Exception {
|
||||
((MyHandler) delegate).doSomething(request);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView handleResource(ResourceRequest request, ResourceResponse response, Object handler)
|
||||
throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(EventRequest request, EventResponse response, Object handler) throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -375,6 +403,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class MyHandlerInterceptor1 extends HandlerInterceptorAdapter {
|
||||
|
||||
@Override
|
||||
public boolean preHandleRender(RenderRequest request, RenderResponse response, Object handler)
|
||||
throws PortletException {
|
||||
if (request.getAttribute("test2-remove-never") != null) {
|
||||
@@ -386,6 +415,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandleRender(
|
||||
RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView)
|
||||
throws PortletException {
|
||||
@@ -398,6 +428,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
request.removeAttribute("test1-remove-post");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterRenderCompletion(
|
||||
RenderRequest request, RenderResponse response, Object handler, Exception ex)
|
||||
throws PortletException {
|
||||
@@ -411,6 +442,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class MyHandlerInterceptor2 extends HandlerInterceptorAdapter {
|
||||
|
||||
@Override
|
||||
public boolean preHandleRender(RenderRequest request, RenderResponse response, Object handler)
|
||||
throws PortletException {
|
||||
if (request.getAttribute("test1-remove-post") == null) {
|
||||
@@ -425,6 +457,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandleRender(
|
||||
RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView)
|
||||
throws PortletException {
|
||||
@@ -440,6 +473,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
request.removeAttribute("test2-remove-post");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterRenderCompletion(
|
||||
RenderRequest request, RenderResponse response, Object handler, Exception ex)
|
||||
throws Exception {
|
||||
@@ -453,6 +487,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class MultipartCheckingHandler implements MyHandler {
|
||||
|
||||
@Override
|
||||
public void doSomething(PortletRequest request) throws PortletException, IllegalAccessException {
|
||||
if (!(request instanceof MultipartActionRequest)) {
|
||||
throw new PortletException("Not in a MultipartActionRequest");
|
||||
@@ -463,10 +498,12 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public static class MockMultipartResolver implements PortletMultipartResolver {
|
||||
|
||||
@Override
|
||||
public boolean isMultipart(ActionRequest request) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultipartActionRequest resolveMultipart(ActionRequest request) throws MultipartException {
|
||||
if (request.getAttribute("fail") != null) {
|
||||
throw new MaxUploadSizeExceededException(1000);
|
||||
@@ -485,6 +522,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
return new DefaultMultipartActionRequest(request, files, params, Collections.<String, String>emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupMultipart(MultipartActionRequest request) {
|
||||
if (request.getAttribute("cleanedUp") != null) {
|
||||
throw new IllegalStateException("Already cleaned up");
|
||||
@@ -498,6 +536,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
|
||||
|
||||
public int counter = 0;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (event instanceof PortletRequestHandledEvent) {
|
||||
this.counter++;
|
||||
|
||||
@@ -73,6 +73,7 @@ public class DispatcherPortletTests extends TestCase {
|
||||
private DispatcherPortlet complexDispatcherPortlet;
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws PortletException {
|
||||
simplePortletConfig = new MockPortletConfig(new MockPortletContext(), "simple");
|
||||
complexPortletConfig = new MockPortletConfig(simplePortletConfig.getPortletContext(), "complex");
|
||||
|
||||
@@ -44,6 +44,7 @@ public class SimplePortletApplicationContext extends StaticPortletApplicationCon
|
||||
private String renderCommandSessionAttributeName;
|
||||
private String formSessionAttributeName;
|
||||
|
||||
@Override
|
||||
public void refresh() throws BeansException {
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
registerSingleton("controller1", TestFormController.class, pvs);
|
||||
@@ -98,17 +99,20 @@ public class SimplePortletApplicationContext extends StaticPortletApplicationCon
|
||||
this.setFormView("form");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSubmitAction(Object command) {
|
||||
TestBean testBean = (TestBean) command;
|
||||
testBean.setAge(testBean.getAge() + 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView showForm(RenderRequest request, RenderResponse response, BindException errors) throws Exception {
|
||||
TestBean testBean = (TestBean) errors.getModel().get(getCommandName());
|
||||
this.writeResponse(response, testBean, false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAndView onSubmitRender(RenderRequest request, RenderResponse response, Object command, BindException errors)
|
||||
throws IOException {
|
||||
TestBean testBean = (TestBean) command;
|
||||
@@ -128,6 +132,7 @@ public class SimplePortletApplicationContext extends StaticPortletApplicationCon
|
||||
response.getWriter().write((finished ? "finished" : "") + (testBean.getAge() + 5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEventRequest(EventRequest request, EventResponse response) throws Exception {
|
||||
response.setRenderParameter("event", request.getEvent().getName());
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public class PortletRequestDataBinderTests extends TestCase {
|
||||
|
||||
PortletRequestDataBinder binder = new PortletRequestDataBinder(bean);
|
||||
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean(text));
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public abstract class AbstractXmlWebApplicationContextTests extends AbstractAppl
|
||||
* Overridden as we can't trust superclass method
|
||||
* @see org.springframework.context.AbstractApplicationContextTests#testEvents()
|
||||
*/
|
||||
@Override
|
||||
public void testEvents() throws Exception {
|
||||
TestListener listener = (TestListener) this.applicationContext.getBean("testListener");
|
||||
listener.zeroCounter();
|
||||
@@ -58,6 +59,7 @@ public abstract class AbstractXmlWebApplicationContextTests extends AbstractAppl
|
||||
assertTrue("1 parent events after publication", parentListener.getEventCount() == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCount() {
|
||||
assertTrue("should have 14 beans, not "+ this.applicationContext.getBeanDefinitionCount(),
|
||||
this.applicationContext.getBeanDefinitionCount() == 14);
|
||||
@@ -104,6 +106,7 @@ public abstract class AbstractXmlWebApplicationContextTests extends AbstractAppl
|
||||
constructed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (this.initMethodInvoked)
|
||||
fail();
|
||||
@@ -117,6 +120,7 @@ public abstract class AbstractXmlWebApplicationContextTests extends AbstractAppl
|
||||
this.initMethodInvoked = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (this.customDestroyed)
|
||||
fail();
|
||||
|
||||
@@ -25,6 +25,7 @@ public class PortletConfigAwareBean implements PortletConfigAware {
|
||||
|
||||
private PortletConfig portletConfig;
|
||||
|
||||
@Override
|
||||
public void setPortletConfig(PortletConfig portletConfig) {
|
||||
this.portletConfig = portletConfig;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class PortletContextAwareBean implements PortletContextAware {
|
||||
|
||||
private PortletContext portletContext;
|
||||
|
||||
@Override
|
||||
public void setPortletContext(PortletContext portletContext) {
|
||||
this.portletContext = portletContext;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class XmlPortletApplicationContextTests extends AbstractXmlWebApplication
|
||||
|
||||
private ConfigurablePortletApplicationContext root;
|
||||
|
||||
@Override
|
||||
protected ConfigurableApplicationContext createContext() throws Exception {
|
||||
root = new XmlPortletApplicationContext();
|
||||
PortletContext portletContext = new MockPortletContext();
|
||||
@@ -48,8 +49,10 @@ public class XmlPortletApplicationContextTests extends AbstractXmlWebApplication
|
||||
root.setPortletConfig(portletConfig);
|
||||
root.setConfigLocations(new String[] {"/org/springframework/web/portlet/context/WEB-INF/applicationContext.xml"});
|
||||
root.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if(bean instanceof TestBean) {
|
||||
((TestBean) bean).getFriends().add("myFriend");
|
||||
@@ -57,6 +60,7 @@ public class XmlPortletApplicationContextTests extends AbstractXmlWebApplication
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
@@ -101,6 +105,7 @@ public class XmlPortletApplicationContextTests extends AbstractXmlWebApplication
|
||||
* Overridden in order to access the root ApplicationContext
|
||||
* @see org.springframework.web.context.XmlWebApplicationContextTests#testContextNesting()
|
||||
*/
|
||||
@Override
|
||||
public void testContextNesting() {
|
||||
TestBean father = (TestBean) this.applicationContext.getBean("father");
|
||||
assertTrue("Bean from root context", father != null);
|
||||
@@ -116,6 +121,7 @@ public class XmlPortletApplicationContextTests extends AbstractXmlWebApplication
|
||||
assertTrue("Custom BeanPostProcessor applied", rod.getFriends().contains("myFriend"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCount() {
|
||||
assertTrue("should have 16 beans, not "+ this.applicationContext.getBeanDefinitionCount(),
|
||||
this.applicationContext.getBeanDefinitionCount() == 16);
|
||||
|
||||
@@ -33,6 +33,7 @@ public class ParameterHandlerMappingTests extends TestCase {
|
||||
|
||||
private ConfigurablePortletApplicationContext pac;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
MockPortletContext portletContext = new MockPortletContext();
|
||||
pac = new XmlPortletApplicationContext();
|
||||
|
||||
@@ -35,6 +35,7 @@ public class PortletModeHandlerMappingTests extends TestCase {
|
||||
|
||||
private ConfigurablePortletApplicationContext pac;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
MockPortletContext portletContext = new MockPortletContext();
|
||||
pac = new XmlPortletApplicationContext();
|
||||
|
||||
@@ -35,6 +35,7 @@ public class PortletModeParameterHandlerMappingTests extends TestCase {
|
||||
|
||||
private ConfigurablePortletApplicationContext pac;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
MockPortletContext portletContext = new MockPortletContext();
|
||||
pac = new XmlPortletApplicationContext();
|
||||
|
||||
@@ -43,6 +43,7 @@ public class SimpleMappingExceptionResolverTests extends TestCase {
|
||||
private Object handler2;
|
||||
private Exception genericException;
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
exceptionResolver = new SimpleMappingExceptionResolver();
|
||||
request = new MockRenderRequest();
|
||||
|
||||
@@ -212,6 +212,7 @@ public class CommandControllerTests extends TestCase {
|
||||
|
||||
public void testSuppressBinding() throws Exception {
|
||||
TestController tc = new TestController() {
|
||||
@Override
|
||||
protected boolean suppressBinding(PortletRequest request) {
|
||||
return true;
|
||||
}
|
||||
@@ -236,6 +237,7 @@ public class CommandControllerTests extends TestCase {
|
||||
public void testWithCustomDateEditor() throws Exception {
|
||||
final DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
|
||||
TestController tc = new TestController() {
|
||||
@Override
|
||||
protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) {
|
||||
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
|
||||
}
|
||||
@@ -261,6 +263,7 @@ public class CommandControllerTests extends TestCase {
|
||||
public void testWithCustomDateEditorEmptyNotAllowed() throws Exception {
|
||||
final DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
|
||||
TestController tc = new TestController() {
|
||||
@Override
|
||||
protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) {
|
||||
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
|
||||
}
|
||||
@@ -287,6 +290,7 @@ public class CommandControllerTests extends TestCase {
|
||||
public void testWithCustomDateEditorEmptyAllowed() throws Exception {
|
||||
final DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
|
||||
TestController tc = new TestController() {
|
||||
@Override
|
||||
protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) {
|
||||
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
||||
}
|
||||
@@ -310,8 +314,10 @@ public class CommandControllerTests extends TestCase {
|
||||
|
||||
public void testNestedBindingWithPropertyEditor() throws Exception {
|
||||
TestController tc = new TestController() {
|
||||
@Override
|
||||
protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) {
|
||||
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean(text));
|
||||
}
|
||||
@@ -341,9 +347,11 @@ public class CommandControllerTests extends TestCase {
|
||||
|
||||
public void testWithValidatorNotSupportingCommandClass() throws Exception {
|
||||
Validator v = new Validator() {
|
||||
@Override
|
||||
public boolean supports(Class c) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void validate(Object o, Errors e) {}
|
||||
};
|
||||
TestController tc = new TestController();
|
||||
@@ -364,9 +372,11 @@ public class CommandControllerTests extends TestCase {
|
||||
final String defaultMessage = "validation error!";
|
||||
TestController tc = new TestController();
|
||||
tc.setValidator(new Validator() {
|
||||
@Override
|
||||
public boolean supports(Class c) {
|
||||
return TestBean.class.isAssignableFrom(c);
|
||||
}
|
||||
@Override
|
||||
public void validate(Object o, Errors e) {
|
||||
e.reject(errorCode, defaultMessage);
|
||||
}
|
||||
@@ -386,9 +396,11 @@ public class CommandControllerTests extends TestCase {
|
||||
final String defaultMessage = "validation error!";
|
||||
TestController tc = new TestController();
|
||||
tc.setValidator(new Validator() {
|
||||
@Override
|
||||
public boolean supports(Class c) {
|
||||
return TestBean.class.isAssignableFrom(c);
|
||||
}
|
||||
@Override
|
||||
public void validate(Object o, Errors e) {
|
||||
ValidationUtils.rejectIfEmpty(e, "name", errorCode, defaultMessage);
|
||||
}
|
||||
@@ -413,9 +425,11 @@ public class CommandControllerTests extends TestCase {
|
||||
final String defaultMessage = "validation error!";
|
||||
TestController tc = new TestController();
|
||||
tc.setValidator(new Validator() {
|
||||
@Override
|
||||
public boolean supports(Class c) {
|
||||
return TestBean.class.isAssignableFrom(c);
|
||||
}
|
||||
@Override
|
||||
public void validate(Object o, Errors e) {
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(e, "name", errorCode, defaultMessage);
|
||||
}
|
||||
@@ -444,10 +458,12 @@ public class CommandControllerTests extends TestCase {
|
||||
super(TestBean.class, "testBean");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleAction(ActionRequest request, ActionResponse response, Object command, BindException errors) {
|
||||
((TestBean)command).setJedi(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelAndView handleRender(RenderRequest request, RenderResponse response, Object command, BindException errors) {
|
||||
assertNotNull(command);
|
||||
assertNotNull(errors);
|
||||
|
||||
@@ -34,6 +34,7 @@ public class PortletModeNameViewControllerTests extends TestCase {
|
||||
|
||||
private PortletModeNameViewController controller;
|
||||
|
||||
@Override
|
||||
public void setUp() {
|
||||
controller = new PortletModeNameViewController();
|
||||
}
|
||||
|
||||
@@ -155,10 +155,12 @@ public final class PortletWrappingControllerTests {
|
||||
private PortletConfig portletConfig;
|
||||
|
||||
|
||||
@Override
|
||||
public void init(PortletConfig portletConfig) {
|
||||
this.portletConfig = portletConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processAction(ActionRequest request, ActionResponse response) throws PortletException {
|
||||
if (request.getParameter("test") != null) {
|
||||
response.setRenderParameter(RESULT_RENDER_PARAMETER_NAME, "myPortlet-action");
|
||||
@@ -169,6 +171,7 @@ public final class PortletWrappingControllerTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderRequest request, RenderResponse response) throws IOException {
|
||||
response.getWriter().write(RENDERED_RESPONSE_CONTENT);
|
||||
}
|
||||
@@ -177,6 +180,7 @@ public final class PortletWrappingControllerTests {
|
||||
return this.portletConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
throw new IllegalStateException("Being destroyed...");
|
||||
}
|
||||
@@ -185,6 +189,7 @@ public final class PortletWrappingControllerTests {
|
||||
|
||||
private static final class MyApplicationContext extends StaticPortletApplicationContext {
|
||||
|
||||
@Override
|
||||
public void refresh() throws BeansException {
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.add("portletClass", MyPortlet.class);
|
||||
|
||||
@@ -104,6 +104,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void standardHandleMethod() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyController.class));
|
||||
@@ -122,6 +123,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void standardHandleMethodWithResources() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
wac.setPortletConfig(getPortletConfig());
|
||||
@@ -173,6 +175,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
|
||||
private void doTestAdaptedHandleMethods(final Class controllerClass) throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
|
||||
@@ -217,12 +220,14 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void formController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyFormController.class));
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -240,12 +245,14 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void modelFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyModelFormController.class));
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -263,6 +270,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void commandProvidingFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyCommandProvidingFormController.class));
|
||||
@@ -272,6 +280,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -290,6 +299,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void typedCommandProvidingFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyTypedCommandProvidingFormController.class));
|
||||
@@ -301,6 +311,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -338,12 +349,14 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void binderInitializingCommandProvidingFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyBinderInitializingCommandProvidingFormController.class));
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -362,12 +375,14 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void specificBinderInitializingCommandProvidingFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MySpecificBinderInitializingCommandProvidingFormController.class));
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -386,6 +401,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void parameterDispatchingController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
wac.setPortletContext(new MockPortletContext());
|
||||
@@ -427,6 +443,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void typeLevelParameterDispatchingController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
wac.setPortletContext(new MockPortletContext());
|
||||
@@ -513,6 +530,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void portlet20DispatchingController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
wac.setPortletContext(new MockPortletContext());
|
||||
@@ -613,6 +631,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void eventDispatchingController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
wac.setPortletContext(new MockPortletContext());
|
||||
@@ -697,6 +716,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@Test
|
||||
public void testPredicatePriorityComparisonAcrossControllers() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
// The order of handler registration is important to get
|
||||
@@ -762,6 +782,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
@RequestMapping("VIEW")
|
||||
private static class MyController extends AbstractController {
|
||||
|
||||
@Override
|
||||
protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception {
|
||||
response.getWriter().write("test");
|
||||
return null;
|
||||
@@ -950,6 +971,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
return new TestBean(defaultName.getClass().getSimpleName() + ":" + defaultName.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequestMapping("VIEW")
|
||||
@RenderMapping
|
||||
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
|
||||
@@ -996,6 +1018,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
private static class MyOtherTypedCommandProvidingFormController
|
||||
extends MyCommandProvidingFormController<Integer, TestBean, ITestBean> {
|
||||
|
||||
@Override
|
||||
@RequestMapping("VIEW")
|
||||
@RenderMapping
|
||||
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
|
||||
@@ -1034,6 +1057,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
|
||||
private static class MyWebBindingInitializer implements WebBindingInitializer {
|
||||
|
||||
@Override
|
||||
public void initBinder(WebDataBinder binder, WebRequest request) {
|
||||
assertNotNull(request.getLocale());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
@@ -1045,6 +1069,7 @@ public class Portlet20AnnotationControllerTests {
|
||||
|
||||
private static class MySpecialArgumentResolver implements WebArgumentResolver {
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) {
|
||||
if (methodParameter.getParameterType().equals(MySpecialArg.class)) {
|
||||
return new MySpecialArg("myValue");
|
||||
|
||||
@@ -86,6 +86,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void testStandardHandleMethod() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyController.class));
|
||||
@@ -115,6 +116,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void doTestAdaptedHandleMethods(final Class controllerClass) throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
|
||||
@@ -153,12 +155,14 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void testFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyFormController.class));
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -175,12 +179,14 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void testModelFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyModelFormController.class));
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -197,6 +203,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void testCommandProvidingFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyCommandProvidingFormController.class));
|
||||
@@ -206,6 +213,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -223,6 +231,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void testTypedCommandProvidingFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyTypedCommandProvidingFormController.class));
|
||||
@@ -234,6 +243,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -270,12 +280,14 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void testBinderInitializingCommandProvidingFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MyBinderInitializingCommandProvidingFormController.class));
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -293,12 +305,14 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void testSpecificBinderInitializingCommandProvidingFormController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
wac.registerBeanDefinition("controller", new RootBeanDefinition(MySpecificBinderInitializingCommandProvidingFormController.class));
|
||||
wac.refresh();
|
||||
return wac;
|
||||
}
|
||||
@Override
|
||||
protected void render(ModelAndView mv, PortletRequest request, MimeResponse response) throws Exception {
|
||||
new TestView().render(mv.getViewName(), mv.getModel(), request, response);
|
||||
}
|
||||
@@ -316,6 +330,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void testParameterDispatchingController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
wac.setPortletContext(new MockPortletContext());
|
||||
@@ -356,6 +371,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public void testTypeLevelParameterDispatchingController() throws Exception {
|
||||
DispatcherPortlet portlet = new DispatcherPortlet() {
|
||||
@Override
|
||||
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
|
||||
StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
|
||||
wac.setPortletContext(new MockPortletContext());
|
||||
@@ -465,6 +481,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
@RequestMapping("VIEW")
|
||||
private static class MyController extends AbstractController {
|
||||
|
||||
@Override
|
||||
protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception {
|
||||
response.getWriter().write("test");
|
||||
return null;
|
||||
@@ -600,6 +617,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
return new TestBean(defaultName.getClass().getSimpleName() + ":" + defaultName.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequestMapping("VIEW")
|
||||
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
|
||||
if (!model.containsKey("myKey")) {
|
||||
@@ -644,6 +662,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
private static class MyOtherTypedCommandProvidingFormController
|
||||
extends MyCommandProvidingFormController<Integer, TestBean, ITestBean> {
|
||||
|
||||
@Override
|
||||
@RequestMapping("VIEW")
|
||||
public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) {
|
||||
if (!model.containsKey("myKey")) {
|
||||
@@ -681,6 +700,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
private static class MyWebBindingInitializer implements WebBindingInitializer {
|
||||
|
||||
@Override
|
||||
public void initBinder(WebDataBinder binder, WebRequest request) {
|
||||
assertNotNull(request.getLocale());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
@@ -692,6 +712,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
private static class MySpecialArgumentResolver implements WebArgumentResolver {
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) {
|
||||
if (methodParameter.getParameterType().equals(MySpecialArg.class)) {
|
||||
return new MySpecialArg("myValue");
|
||||
@@ -807,6 +828,7 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
|
||||
public static class MyModelAndViewResolver implements ModelAndViewResolver {
|
||||
|
||||
@Override
|
||||
public org.springframework.web.servlet.ModelAndView resolveModelAndView(Method handlerMethod,
|
||||
Class handlerType,
|
||||
Object returnValue,
|
||||
@@ -814,10 +836,12 @@ public class PortletAnnotationControllerTests extends TestCase {
|
||||
NativeWebRequest webRequest) {
|
||||
if (returnValue instanceof MySpecialArg) {
|
||||
return new org.springframework.web.servlet.ModelAndView(new View() {
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return "text/html";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)
|
||||
throws Exception {
|
||||
response.getWriter().write("myValue");
|
||||
|
||||
@@ -83,6 +83,7 @@ public final class PortletUtilsTests {
|
||||
@Test(expected=FileNotFoundException.class)
|
||||
public void testGetRealPathWithPathThatCannotBeResolvedToFile() throws Exception {
|
||||
PortletUtils.getRealPath(new MockPortletContext() {
|
||||
@Override
|
||||
public String getRealPath(String path) {
|
||||
return null;
|
||||
}
|
||||
@@ -221,6 +222,7 @@ public final class PortletUtilsTests {
|
||||
request.setParameter("William", "Baskerville");
|
||||
request.setParameter("Adso", "Melk");
|
||||
MockActionResponse response = new MockActionResponse() {
|
||||
@Override
|
||||
public void setRenderParameter(String key, String[] values) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@@ -243,6 +245,7 @@ public final class PortletUtilsTests {
|
||||
@Test
|
||||
public void testClearAllRenderParametersDoesNotPropagateExceptionIfRedirectAlreadySentAtTimeOfCall() throws Exception {
|
||||
MockActionResponse response = new MockActionResponse() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setRenderParameters(Map parameters) {
|
||||
throw new IllegalStateException();
|
||||
|
||||
Reference in New Issue
Block a user