Merge pull request #522 from marschall/spring-webmvc-portlet-warnings

* spring-webmvc-portlet-warnings:
  Clean up spring-webmvc-portlet tests warnings
This commit is contained in:
Stephane Nicoll 2014-04-22 07:29:56 +02:00
commit 54db2fba48
10 changed files with 79 additions and 64 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@ import java.util.Map;
* @author Thomas Risberg * @author Thomas Risberg
* @author Juergen Hoeller * @author Juergen Hoeller
*/ */
public class BeanThatListens implements ApplicationListener { public class BeanThatListens implements ApplicationListener<ApplicationEvent> {
private BeanThatBroadcasts beanThatBroadcasts; private BeanThatBroadcasts beanThatBroadcasts;
@ -36,7 +36,7 @@ public class BeanThatListens implements ApplicationListener {
public BeanThatListens(BeanThatBroadcasts beanThatBroadcasts) { public BeanThatListens(BeanThatBroadcasts beanThatBroadcasts) {
this.beanThatBroadcasts = beanThatBroadcasts; this.beanThatBroadcasts = beanThatBroadcasts;
Map beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class); Map<String, BeanThatListens> beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class);
if (!beans.isEmpty()) { if (!beans.isEmpty()) {
throw new IllegalStateException("Shouldn't have found any BeanThatListens instances"); throw new IllegalStateException("Shouldn't have found any BeanThatListens instances");
} }

View File

@ -1,3 +1,19 @@
/*
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context; package org.springframework.context;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
@ -9,7 +25,7 @@ import org.springframework.context.ApplicationListener;
* @author Rod Johnson * @author Rod Johnson
* @since January 21, 2001 * @since January 21, 2001
*/ */
public class TestListener implements ApplicationListener { public class TestListener implements ApplicationListener<ApplicationEvent> {
private int eventCount; private int eventCount;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -271,8 +271,8 @@ public class MockPortletRequest implements PortletRequest {
@Override @Override
public String getProperty(String key) { public String getProperty(String key) {
Assert.notNull(key, "Property key must not be null"); Assert.notNull(key, "Property key must not be null");
List list = this.properties.get(key); List<String> list = this.properties.get(key);
return (list != null && list.size() > 0 ? (String) list.get(0) : null); return (list != null && list.size() > 0 ? list.get(0) : null);
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,6 +39,7 @@ import javax.portlet.ResourceResponse;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanReference;
import org.springframework.beans.factory.config.ConstructorArgumentValues; import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.ManagedList; import org.springframework.beans.factory.support.ManagedList;
@ -118,14 +119,14 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
ParameterMappingInterceptor parameterMappingInterceptor = new ParameterMappingInterceptor(); ParameterMappingInterceptor parameterMappingInterceptor = new ParameterMappingInterceptor();
parameterMappingInterceptor.setParameterName("interceptingParam"); parameterMappingInterceptor.setParameterName("interceptingParam");
List interceptors = new ArrayList(); List<HandlerInterceptor> interceptors = new ArrayList<HandlerInterceptor>(4);
interceptors.add(parameterMappingInterceptor); interceptors.add(parameterMappingInterceptor);
interceptors.add(userRoleInterceptor); interceptors.add(userRoleInterceptor);
interceptors.add(new MyHandlerInterceptor1()); interceptors.add(new MyHandlerInterceptor1());
interceptors.add(new MyHandlerInterceptor2()); interceptors.add(new MyHandlerInterceptor2());
MutablePropertyValues pvs = new MutablePropertyValues(); MutablePropertyValues pvs = new MutablePropertyValues();
Map portletModeMap = new ManagedMap(); Map<String, BeanReference> portletModeMap = new ManagedMap<String, BeanReference>();
portletModeMap.put("view", new RuntimeBeanReference("viewController")); portletModeMap.put("view", new RuntimeBeanReference("viewController"));
portletModeMap.put("edit", new RuntimeBeanReference("editController")); portletModeMap.put("edit", new RuntimeBeanReference("editController"));
pvs.add("portletModeMap", portletModeMap); pvs.add("portletModeMap", portletModeMap);
@ -133,7 +134,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
registerSingleton("handlerMapping3", PortletModeHandlerMapping.class, pvs); registerSingleton("handlerMapping3", PortletModeHandlerMapping.class, pvs);
pvs = new MutablePropertyValues(); pvs = new MutablePropertyValues();
Map parameterMap = new ManagedMap(); Map<String, BeanReference> parameterMap = new ManagedMap<String, BeanReference>();
parameterMap.put("test1", new RuntimeBeanReference("testController1")); parameterMap.put("test1", new RuntimeBeanReference("testController1"));
parameterMap.put("test2", new RuntimeBeanReference("testController2")); parameterMap.put("test2", new RuntimeBeanReference("testController2"));
parameterMap.put("requestLocaleChecker", new RuntimeBeanReference("requestLocaleCheckingController")); parameterMap.put("requestLocaleChecker", new RuntimeBeanReference("requestLocaleCheckingController"));
@ -148,10 +149,10 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
registerSingleton("handlerMapping2", ParameterHandlerMapping.class, pvs); registerSingleton("handlerMapping2", ParameterHandlerMapping.class, pvs);
pvs = new MutablePropertyValues(); pvs = new MutablePropertyValues();
Map innerMap = new ManagedMap(); Map<String, Object> innerMap = new ManagedMap<String, Object>();
innerMap.put("help1", new RuntimeBeanReference("helpController1")); innerMap.put("help1", new RuntimeBeanReference("helpController1"));
innerMap.put("help2", new RuntimeBeanReference("helpController2")); innerMap.put("help2", new RuntimeBeanReference("helpController2"));
Map outerMap = new ManagedMap(); Map<String, Object> outerMap = new ManagedMap<String, Object>();
outerMap.put("help", innerMap); outerMap.put("help", innerMap);
pvs.add("portletModeParameterMap", outerMap); pvs.add("portletModeParameterMap", outerMap);
pvs.add("order", "1"); pvs.add("order", "1");
@ -171,7 +172,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
pvs.add("exceptionMappings", pvs.add("exceptionMappings",
"java.lang.Exception=failed-exception\n" + "java.lang.Exception=failed-exception\n" +
"java.lang.RuntimeException=failed-runtime"); "java.lang.RuntimeException=failed-runtime");
List mappedHandlers = new ManagedList(); List<BeanReference> mappedHandlers = new ManagedList<BeanReference>();
mappedHandlers.add(new RuntimeBeanReference("exceptionThrowingHandler1")); mappedHandlers.add(new RuntimeBeanReference("exceptionThrowingHandler1"));
pvs.add("mappedHandlers", mappedHandlers); pvs.add("mappedHandlers", mappedHandlers);
pvs.add("defaultErrorView", "failed-default-0"); pvs.add("defaultErrorView", "failed-default-0");
@ -533,7 +534,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
} }
public static class TestApplicationListener implements ApplicationListener { public static class TestApplicationListener implements ApplicationListener<ApplicationEvent> {
public int counter = 0; public int counter = 0;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -125,7 +125,7 @@ public class DispatcherPortletTests extends TestCase {
request.setPortletMode(PortletMode.HELP); request.setPortletMode(PortletMode.HELP);
request.setParameter("action", "help3"); request.setParameter("action", "help3");
complexDispatcherPortlet.doDispatch(request, response); complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
assertTrue(model.get("exception").getClass().equals(NoHandlerFoundException.class)); assertTrue(model.get("exception").getClass().equals(NoHandlerFoundException.class));
InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
assertEquals("failed-unavailable", view.getBeanName()); assertEquals("failed-unavailable", view.getBeanName());
@ -164,7 +164,7 @@ public class DispatcherPortletTests extends TestCase {
request.setParameter("action", "not mapped"); request.setParameter("action", "not mapped");
request.setParameter("myParam", "not mapped"); request.setParameter("myParam", "not mapped");
complexDispatcherPortlet.doDispatch(request, response); complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
assertEquals("view was here", model.get("result")); assertEquals("view was here", model.get("result"));
InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
assertEquals("someViewName", view.getBeanName()); assertEquals("someViewName", view.getBeanName());
@ -178,7 +178,7 @@ public class DispatcherPortletTests extends TestCase {
request.setParameter("action", "not mapped"); request.setParameter("action", "not mapped");
request.setParameter("myParam", "not mapped"); request.setParameter("myParam", "not mapped");
complexDispatcherPortlet.doDispatch(request, response); complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
Exception exception = (Exception) model.get("exception"); Exception exception = (Exception) model.get("exception");
assertNotNull(exception); assertNotNull(exception);
assertTrue(exception.getClass().equals(PortletSecurityException.class)); assertTrue(exception.getClass().equals(PortletSecurityException.class));
@ -222,7 +222,7 @@ public class DispatcherPortletTests extends TestCase {
MockRenderResponse response = new MockRenderResponse(); MockRenderResponse response = new MockRenderResponse();
request.setParameter("myParam", "unknown"); request.setParameter("myParam", "unknown");
complexDispatcherPortlet.doDispatch(request, response); complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
Exception exception = (Exception)model.get("exception"); Exception exception = (Exception)model.get("exception");
assertTrue(exception.getClass().equals(PortletException.class)); assertTrue(exception.getClass().equals(PortletException.class));
assertTrue(exception.getMessage().indexOf("No adapter for handler") != -1); assertTrue(exception.getMessage().indexOf("No adapter for handler") != -1);
@ -255,7 +255,7 @@ public class DispatcherPortletTests extends TestCase {
MockRenderResponse response = new MockRenderResponse(); MockRenderResponse response = new MockRenderResponse();
request.setParameter("myParam", "test1"); request.setParameter("myParam", "test1");
complexDispatcherPortlet.doDispatch(request, response); complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
Exception exception = (Exception) model.get("exception"); Exception exception = (Exception) model.get("exception");
assertTrue(exception.getClass().equals(NoHandlerFoundException.class)); assertTrue(exception.getClass().equals(NoHandlerFoundException.class));
InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
@ -333,7 +333,7 @@ public class DispatcherPortletTests extends TestCase {
request.setParameter("myParam", "requestLocaleChecker"); request.setParameter("myParam", "requestLocaleChecker");
request.addPreferredLocale(Locale.ENGLISH); request.addPreferredLocale(Locale.ENGLISH);
complexDispatcherPortlet.doDispatch(request, response); complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
Exception exception = (Exception) model.get("exception"); Exception exception = (Exception) model.get("exception");
assertTrue(exception.getClass().equals(PortletException.class)); assertTrue(exception.getClass().equals(PortletException.class));
assertEquals("Incorrect Locale in RenderRequest", exception.getMessage()); assertEquals("Incorrect Locale in RenderRequest", exception.getMessage());
@ -356,7 +356,7 @@ public class DispatcherPortletTests extends TestCase {
request.setParameter("myParam", "contextLocaleChecker"); request.setParameter("myParam", "contextLocaleChecker");
request.addPreferredLocale(Locale.ENGLISH); request.addPreferredLocale(Locale.ENGLISH);
complexDispatcherPortlet.doDispatch(request, response); complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
Exception exception = (Exception) model.get("exception"); Exception exception = (Exception) model.get("exception");
assertTrue(exception.getClass().equals(PortletException.class)); assertTrue(exception.getClass().equals(PortletException.class));
assertEquals("Incorrect Locale in LocaleContextHolder", exception.getMessage()); assertEquals("Incorrect Locale in LocaleContextHolder", exception.getMessage());
@ -401,7 +401,7 @@ public class DispatcherPortletTests extends TestCase {
request.addUserRole("role1"); request.addUserRole("role1");
request.addParameter("noView", "false"); request.addParameter("noView", "false");
complexDispatcherPortlet.doDispatch(request, response); complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
assertEquals("view was here", model.get("result")); assertEquals("view was here", model.get("result"));
InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
assertEquals("someViewName", view.getBeanName()); assertEquals("someViewName", view.getBeanName());
@ -414,7 +414,7 @@ public class DispatcherPortletTests extends TestCase {
request.addUserRole("role1"); request.addUserRole("role1");
request.addParameter("noView", "true"); request.addParameter("noView", "true");
complexDispatcherPortlet.doDispatch(request, response); complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE); Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
assertNull(model); assertNull(model);
InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE); InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
assertNull(view); assertNull(view);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -166,7 +166,7 @@ public class PortletRequestDataBinderTests extends TestCase {
public void testBindingSet() { public void testBindingSet() {
TestBean bean = new TestBean(); TestBean bean = new TestBean();
Set set = new LinkedHashSet<>(2); Set<TestBean> set = new LinkedHashSet<TestBean>(2);
set.add(new TestBean("test1")); set.add(new TestBean("test1"));
set.add(new TestBean("test2")); set.add(new TestBean("test2"));
bean.setSomeSet(set); bean.setSomeSet(set);
@ -181,7 +181,7 @@ public class PortletRequestDataBinderTests extends TestCase {
assertNotNull(bean.getSomeSet()); assertNotNull(bean.getSomeSet());
assertEquals(2, bean.getSomeSet().size()); assertEquals(2, bean.getSomeSet().size());
Iterator iter = bean.getSomeSet().iterator(); Iterator<?> iter = bean.getSomeSet().iterator();
TestBean bean1 = (TestBean) iter.next(); TestBean bean1 = (TestBean) iter.next();
assertEquals("test1", bean1.getName()); assertEquals("test1", bean1.getName());

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -56,13 +56,13 @@ public class PortletWebRequestTests {
assertEquals("value2", request.getParameterValues("param2")[0]); assertEquals("value2", request.getParameterValues("param2")[0]);
assertEquals("value2a", request.getParameterValues("param2")[1]); assertEquals("value2a", request.getParameterValues("param2")[1]);
Map paramMap = request.getParameterMap(); Map<String, String[]> paramMap = request.getParameterMap();
assertEquals(2, paramMap.size()); assertEquals(2, paramMap.size());
assertEquals(1, ((String[]) paramMap.get("param1")).length); assertEquals(1, paramMap.get("param1").length);
assertEquals("value1", ((String[]) paramMap.get("param1"))[0]); assertEquals("value1", paramMap.get("param1")[0]);
assertEquals(2, ((String[]) paramMap.get("param2")).length); assertEquals(2, paramMap.get("param2").length);
assertEquals("value2", ((String[]) paramMap.get("param2"))[0]); assertEquals("value2", paramMap.get("param2")[0]);
assertEquals("value2a", ((String[]) paramMap.get("param2"))[1]); assertEquals("value2a", paramMap.get("param2")[1]);
} }
@Test @Test

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,6 +23,7 @@ import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.portlet.ActionRequest; import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse; import javax.portlet.ActionResponse;
import javax.portlet.EventResponse; import javax.portlet.EventResponse;
@ -173,7 +174,7 @@ public class Portlet20AnnotationControllerTests {
doTestAdaptedHandleMethods(MyAdaptedController4.class); doTestAdaptedHandleMethods(MyAdaptedController4.class);
} }
private void doTestAdaptedHandleMethods(final Class controllerClass) throws Exception { private void doTestAdaptedHandleMethods(final Class<?> controllerClass) throws Exception {
DispatcherPortlet portlet = new DispatcherPortlet() { DispatcherPortlet portlet = new DispatcherPortlet() {
@Override @Override
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException { protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
@ -1233,7 +1234,7 @@ public class Portlet20AnnotationControllerTests {
private static class TestView { private static class TestView {
public void render(String viewName, Map model, PortletRequest request, MimeResponse response) throws Exception { public void render(String viewName, Map<String, Object> model, PortletRequest request, MimeResponse response) throws Exception {
TestBean tb = (TestBean) model.get("testBean"); TestBean tb = (TestBean) model.get("testBean");
if (tb == null) { if (tb == null) {
tb = (TestBean) model.get("myCommand"); tb = (TestBean) model.get("myCommand");
@ -1248,9 +1249,9 @@ public class Portlet20AnnotationControllerTests {
if (errors.hasFieldErrors("date")) { if (errors.hasFieldErrors("date")) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
List<TestBean> testBeans = (List<TestBean>) model.get("testBeanList"); List<?> testBeans = (List<?>) model.get("testBeanList");
response.getWriter().write(viewName + "-" + tb.getName() + "-" + errors.getFieldError("age").getCode() + response.getWriter().write(viewName + "-" + tb.getName() + "-" + errors.getFieldError("age").getCode() +
"-" + testBeans.get(0).getName() + "-" + model.get("myKey")); "-" + ((TestBean) testBeans.get(0)).getName() + "-" + model.get("myKey"));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -114,7 +114,7 @@ public class PortletAnnotationControllerTests extends TestCase {
doTestAdaptedHandleMethods(MyAdaptedController3.class); doTestAdaptedHandleMethods(MyAdaptedController3.class);
} }
public void doTestAdaptedHandleMethods(final Class controllerClass) throws Exception { public void doTestAdaptedHandleMethods(final Class<?> controllerClass) throws Exception {
DispatcherPortlet portlet = new DispatcherPortlet() { DispatcherPortlet portlet = new DispatcherPortlet() {
@Override @Override
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException { protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
@ -796,7 +796,7 @@ public class PortletAnnotationControllerTests extends TestCase {
private static class TestView { private static class TestView {
public void render(String viewName, Map model, PortletRequest request, MimeResponse response) throws Exception { public void render(String viewName, Map<String, Object> model, PortletRequest request, MimeResponse response) throws Exception {
TestBean tb = (TestBean) model.get("testBean"); TestBean tb = (TestBean) model.get("testBean");
if (tb == null) { if (tb == null) {
tb = (TestBean) model.get("myCommand"); tb = (TestBean) model.get("myCommand");
@ -811,9 +811,9 @@ public class PortletAnnotationControllerTests extends TestCase {
if (errors.hasFieldErrors("date")) { if (errors.hasFieldErrors("date")) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
List<TestBean> testBeans = (List<TestBean>) model.get("testBeanList"); List<?> testBeans = (List<?>) model.get("testBeanList");
response.getWriter().write(viewName + "-" + tb.getName() + "-" + errors.getFieldError("age").getCode() + response.getWriter().write(viewName + "-" + tb.getName() + "-" + errors.getFieldError("age").getCode() +
"-" + testBeans.get(0).getName() + "-" + model.get("myKey")); "-" + ((TestBean) testBeans.get(0)).getName() + "-" + model.get("myKey"));
} }
} }
@ -830,7 +830,7 @@ public class PortletAnnotationControllerTests extends TestCase {
@Override @Override
public org.springframework.web.servlet.ModelAndView resolveModelAndView(Method handlerMethod, public org.springframework.web.servlet.ModelAndView resolveModelAndView(Method handlerMethod,
Class handlerType, Class<?> handlerType,
Object returnValue, Object returnValue,
ExtendedModelMap implicitModel, ExtendedModelMap implicitModel,
NativeWebRequest webRequest) { NativeWebRequest webRequest) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -245,8 +245,7 @@ public final class PortletUtilsTests {
public void testClearAllRenderParametersDoesNotPropagateExceptionIfRedirectAlreadySentAtTimeOfCall() throws Exception { public void testClearAllRenderParametersDoesNotPropagateExceptionIfRedirectAlreadySentAtTimeOfCall() throws Exception {
MockActionResponse response = new MockActionResponse() { MockActionResponse response = new MockActionResponse() {
@Override @Override
@SuppressWarnings("unchecked") public void setRenderParameters(Map<String, String[]> parameters) {
public void setRenderParameters(Map parameters) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
}; };
@ -302,7 +301,6 @@ public final class PortletUtilsTests {
PortletUtils.exposeRequestAttributes(new MockPortletRequest(), null); PortletUtils.exposeRequestAttributes(new MockPortletRequest(), null);
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testExposeRequestAttributesSunnyDay() throws Exception { public void testExposeRequestAttributesSunnyDay() throws Exception {
MockPortletRequest request = new MockPortletRequest(); MockPortletRequest request = new MockPortletRequest();
@ -314,7 +312,6 @@ public final class PortletUtilsTests {
assertEquals("Roy Fokker", request.getAttribute("mentor")); assertEquals("Roy Fokker", request.getAttribute("mentor"));
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testExposeRequestAttributesWithEmptyAttributesMapIsAnIdempotentOperation() throws Exception { public void testExposeRequestAttributesWithEmptyAttributesMapIsAnIdempotentOperation() throws Exception {
MockPortletRequest request = new MockPortletRequest(); MockPortletRequest request = new MockPortletRequest();