コード例 #1
0
 public void testNoParameterValueSetWithNonDefaultParameterNameWhenHandlerMappingProvided()
     throws Exception {
   String param = "myParam";
   ParameterHandlerMapping handlerMapping = new ParameterHandlerMapping();
   handlerMapping.setParameterName(param);
   ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
   interceptor.setParameterName(param);
   Object handler = new Object();
   MockActionRequest request = new MockActionRequest();
   MockActionResponse response = new MockActionResponse();
   assertNull(response.getRenderParameter(param));
   boolean shouldProceed = interceptor.preHandle(request, response, handler);
   assertTrue(shouldProceed);
   assertNull(response.getRenderParameter(param));
 }
コード例 #2
0
 public void testNonDefaultParameterMappedWhenHandlerMappingProvided() throws Exception {
   String param = "myParam";
   String value = "someValue";
   ParameterHandlerMapping handlerMapping = new ParameterHandlerMapping();
   handlerMapping.setParameterName(param);
   ParameterMappingInterceptor interceptor = new ParameterMappingInterceptor();
   interceptor.setParameterName(param);
   Object handler = new Object();
   MockActionRequest request = new MockActionRequest();
   MockActionResponse response = new MockActionResponse();
   request.setParameter(param, value);
   assertNull(response.getRenderParameter(param));
   boolean shouldProceed = interceptor.preHandleAction(request, response, handler);
   assertTrue(shouldProceed);
   assertNull(response.getRenderParameter(ParameterHandlerMapping.DEFAULT_PARAMETER_NAME));
   assertNotNull(response.getRenderParameter(param));
   assertEquals(value, response.getRenderParameter(param));
 }