Browse Source

fixed Portlet UnavailableException tests (SPR-7542)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3695 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 16 years ago
parent
commit
8a8a6dee7e
  1. 2
      org.springframework.web.portlet/src/test/java/org/springframework/web/portlet/ComplexPortletApplicationContext.java
  2. 16
      org.springframework.web.portlet/src/test/java/org/springframework/web/portlet/DispatcherPortletTests.java
  3. 6
      org.springframework.web.portlet/src/test/java/org/springframework/web/portlet/mvc/annotation/Portlet20AnnotationControllerTests.java

2
org.springframework.web.portlet/src/test/java/org/springframework/web/portlet/ComplexPortletApplicationContext.java

@ -159,7 +159,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo @@ -159,7 +159,7 @@ public class ComplexPortletApplicationContext extends StaticPortletApplicationCo
pvs.add("exceptionMappings",
"java.lang.IllegalAccessException=failed-illegalaccess\n" +
"PortletRequestBindingException=failed-binding\n" +
"UnavailableException=failed-unavailable");
"NoHandlerFoundException=failed-unavailable");
pvs.add("defaultErrorView", "failed-default-1");
registerSingleton("exceptionResolver", SimpleMappingExceptionResolver.class, pvs);

16
org.springframework.web.portlet/src/test/java/org/springframework/web/portlet/DispatcherPortletTests.java

@ -136,7 +136,7 @@ public class DispatcherPortletTests extends TestCase { @@ -136,7 +136,7 @@ public class DispatcherPortletTests extends TestCase {
simpleDispatcherPortlet.processAction(request, response);
String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
assertNotNull(exceptionParam);
assertTrue(exceptionParam.startsWith(UnavailableException.class.getName()));
assertTrue(exceptionParam.startsWith(NoHandlerFoundException.class.getName()));
}
public void testSimpleFormViewNoBindOnNewForm() throws Exception {
@ -246,7 +246,7 @@ public class DispatcherPortletTests extends TestCase { @@ -246,7 +246,7 @@ public class DispatcherPortletTests extends TestCase {
simpleDispatcherPortlet.doDispatch(request, response);
fail("Should have thrown UnavailableException");
}
catch (UnavailableException ex) {
catch (NoHandlerFoundException ex) {
// expected
}
}
@ -279,7 +279,7 @@ public class DispatcherPortletTests extends TestCase { @@ -279,7 +279,7 @@ public class DispatcherPortletTests extends TestCase {
complexDispatcherPortlet.processAction(request, response);
String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
assertNotNull(exceptionParam);
assertTrue(exceptionParam.startsWith(UnavailableException.class.getName()));
assertTrue(exceptionParam.startsWith(NoHandlerFoundException.class.getName()));
}
public void testPortletModeParameterMappingInvalidHelpRenderRequest() throws Exception {
@ -289,7 +289,7 @@ public class DispatcherPortletTests extends TestCase { @@ -289,7 +289,7 @@ public class DispatcherPortletTests extends TestCase {
request.setParameter("action", "help3");
complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
assertTrue(model.get("exception").getClass().equals(UnavailableException.class));
assertTrue(model.get("exception").getClass().equals(NoHandlerFoundException.class));
InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
assertEquals("failed-unavailable", view.getBeanName());
}
@ -405,7 +405,7 @@ public class DispatcherPortletTests extends TestCase { @@ -405,7 +405,7 @@ public class DispatcherPortletTests extends TestCase {
complexDispatcherPortlet.processAction(request, response);
String exceptionParam = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
assertNotNull(exceptionParam);
assertTrue(exceptionParam.startsWith(UnavailableException.class.getName()));
assertTrue(exceptionParam.startsWith(NoHandlerFoundException.class.getName()));
}
public void testNoDetectAllHandlerMappingsWithParameterRenderRequest() throws Exception {
@ -420,7 +420,7 @@ public class DispatcherPortletTests extends TestCase { @@ -420,7 +420,7 @@ public class DispatcherPortletTests extends TestCase {
complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
Exception exception = (Exception) model.get("exception");
assertTrue(exception.getClass().equals(UnavailableException.class));
assertTrue(exception.getClass().equals(NoHandlerFoundException.class));
InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
assertEquals("failed-unavailable", view.getBeanName());
}
@ -900,9 +900,9 @@ public class DispatcherPortletTests extends TestCase { @@ -900,9 +900,9 @@ public class DispatcherPortletTests extends TestCase {
try {
simpleDispatcherPortlet.doDispatch(request, response);
fail("should have failed to find a handler and raised an UnavailableException");
fail("should have failed to find a handler and raised an NoHandlerFoundExceptionException");
}
catch (UnavailableException ex) {
catch (NoHandlerFoundException ex) {
// expected
}

6
org.springframework.web.portlet/src/test/java/org/springframework/web/portlet/mvc/annotation/Portlet20AnnotationControllerTests.java

@ -34,7 +34,6 @@ import javax.portlet.PortletSession; @@ -34,7 +34,6 @@ import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.StateAwareResponse;
import javax.portlet.UnavailableException;
import javax.portlet.WindowState;
import javax.servlet.http.Cookie;
@ -86,6 +85,7 @@ import org.springframework.web.context.request.WebRequest; @@ -86,6 +85,7 @@ import org.springframework.web.context.request.WebRequest;
import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.portlet.DispatcherPortlet;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.NoHandlerFoundException;
import org.springframework.web.portlet.bind.annotation.ActionMapping;
import org.springframework.web.portlet.bind.annotation.EventMapping;
import org.springframework.web.portlet.bind.annotation.RenderMapping;
@ -419,9 +419,9 @@ public class Portlet20AnnotationControllerTests { @@ -419,9 +419,9 @@ public class Portlet20AnnotationControllerTests {
MockRenderResponse response = new MockRenderResponse();
try {
portlet.render(request, response);
fail("Should have thrown UnavailableException");
fail("Should have thrown NoHandlerFoundException");
}
catch (UnavailableException ex) {
catch (NoHandlerFoundException ex) {
// expected
}

Loading…
Cancel
Save