List of usage examples for org.springframework.web.context.request ServletWebRequest ServletWebRequest
public ServletWebRequest(HttpServletRequest request)
From source file:io.pivotal.cla.mvc.support.ImportedSignaturesSessionAttrTests.java
@Before public void setup() { request = new MockHttpServletRequest(); attr = new ImportedSignaturesSessionAttr(new ServletWebRequest(request)); }
From source file:com.springsource.greenhouse.connect.TwitterConnectInterceptorTest.java
@Before public void setup() { interceptor = new TwitterConnectInterceptor(); httpServletRequest = new MockHttpServletRequest(); request = new ServletWebRequest(httpServletRequest); }
From source file:org.mytms.common.web.RequestCustomerResolverImpl.java
@Override public Object getCustomer(HttpServletRequest request) { return getCustomer(new ServletWebRequest(request)); }
From source file:com.scf.web.context.DefaultWebContext.java
@Override protected HttpServletResponse getHttpServletResponse() { ServletWebRequest servletWebRequest = new ServletWebRequest(getHttpServletRequest()); HttpServletResponse response = servletWebRequest.getResponse(); return response; }
From source file:org.moserp.infrastructure.gateway.filter.ResponseLinksMapperTest.java
@Before public void setUp() { MockHttpServletRequest servletRequest = new MockHttpServletRequest(); servletRequest.setRequestURI("/api/products"); servletRequest.setServerPort(8080);/*from w ww . j a va2s. co m*/ RequestContextHolder.setRequestAttributes(new ServletWebRequest(servletRequest)); }
From source file:org.openmrs.web.controller.user.UserFormControllerTest.java
/** * @see UserFormController#handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult) * *//*w ww . j a v a 2 s .c o m*/ @Test @Verifies(value = "should work for an example", method = "handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult)") public void handleSubmission_shouldWorkForAnExample() throws Exception { WebRequest request = new ServletWebRequest(new MockHttpServletRequest()); User user = controller.formBackingObject(request, null); user.addName(new PersonName("This", "is", "Test")); user.getPerson().setGender("F"); controller.handleSubmission(request, new MockHttpSession(), new ModelMap(), "", "Save User", "pass123", "pass123", null, null, null, new String[0], "true", null, user, new BindException(user, "user")); }
From source file:io.pivotal.cla.mvc.support.ImportedSignaturesSessionAttrResolverTests.java
@Test public void resolveArgumentFalse() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); NativeWebRequest webRequest = new ServletWebRequest(request); MethodParameter parameter = new MethodParameter(method, 0); ImportedSignaturesSessionAttr resolved = (ImportedSignaturesSessionAttr) resolver.resolveArgument(parameter, null, webRequest, null);//from w ww . ja v a 2 s . c om assertThat(resolved.getValue()).isFalse(); }
From source file:org.springframework.cloud.aws.messaging.endpoint.BaseNotificationMessageHandlerMethodArgumentResolverTest.java
@Test public void resolveArgument_SubScriptionMessage_createsObjectWithAllFields() throws Exception { //Arrange/*from w ww. j ava 2 s . c o m*/ AbstractNotificationMessageHandlerMethodArgumentResolver resolver = new AbstractNotificationMessageHandlerMethodArgumentResolver() { @Override protected Object doResolveArgumentFromNotificationMessage(JsonNode content, HttpInputMessage request, Class<?> parameterType) { return content; } @Override public boolean supportsParameter(MethodParameter parameter) { return true; } }; MockHttpServletRequest servletRequest = new MockHttpServletRequest(); ServletWebRequest servletWebRequest = new ServletWebRequest(servletRequest); byte[] fileContent = FileCopyUtils.copyToByteArray(new ClassPathResource("subscriptionConfirmation.json", AbstractNotificationMessageHandlerMethodArgumentResolver.class).getInputStream()); servletRequest.setContent(fileContent); MethodParameter methodParameter = new MethodParameter(ReflectionUtils.findMethod(NotificationMethods.class, "subscriptionMethod", NotificationStatus.class), 0); //Act @SuppressWarnings("unchecked") ObjectNode content = (ObjectNode) resolver.resolveArgument(methodParameter, null, servletWebRequest, null); //Assert assertEquals("SubscriptionConfirmation", content.get("Type").asText()); assertEquals("e267b24c-5532-472f-889d-c2cdd2143bbc", content.get("MessageId").asText()); assertEquals( "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", content.get("Token").asText()); assertEquals("arn:aws:sns:eu-west-1:111111111111:mySampleTopic", content.get("TopicArn").asText()); assertEquals( "You have chosen to subscribe to the topic arn:aws:sns:eu-west-1:721324560415:mySampleTopic.To confirm the subscription, visit the SubscribeURL included in this message.", content.get("Message").asText()); assertEquals( "https://sns.eu-west-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:eu-west-1:111111111111:mySampleTopic&Token=111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", content.get("SubscribeURL").asText()); assertEquals("2014-06-28T10:22:18.086Z", content.get("Timestamp").asText()); assertEquals("1", content.get("SignatureVersion").asText()); assertEquals( "JLdRUR+uhP4cyVW6bRuUSAkUosFMJyO7g7WCAwEUJoB4y8vQE1uDUWGpbQSEbruVTjPEM8hFsf4/95NftfM0W5IgND1uSnv4P/4AYyL+q0bLOJlquzXrw4w2NX3QShS3y+r/gXzo7p/UP4NOr35MGCEGPqHAEe1Coc5S0eaP3JvKU6xY1tcop6ze2RNHTwzhM43dda2bnjPYogAJzA5uHfmSjs3cMVvPCckj3zdLyvxISp+RgrogdvlNyu9ycND1SxagmbzjkBaqvF/4aiSYFxsEXX4e9zuNuHGmXGWgm1ppYUGLSPPJruCsPUa7Ii1mYvpX7SezuFZlAAXXBk0mHg==", content.get("Signature").asText()); assertEquals( "https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-e372f8ca30337fdb084e8ac449342c77.pem", content.get("SigningCertURL").asText()); }
From source file:com.luna.common.web.bind.method.annotation.PageableMethodArgumentResolverTest.java
@Test public void testPageable() throws Exception { int pn = 1;//from w w w.j a v a 2 s . c o m int pageSize = 10; request.setParameter("page.pn", String.valueOf(pn)); request.setParameter("page.size", String.valueOf(pageSize)); MethodParameter parameter = new MethodParameter(pageable, 0); NativeWebRequest webRequest = new ServletWebRequest(request); Pageable pageable = (Pageable) new PageableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null); //-10 assertEquals(pn - 1, pageable.getPageNumber()); assertEquals(pageSize, pageable.getPageSize()); assertEquals(null, pageable.getSort()); }
From source file:edu.duke.cabig.c3pr.domain.scheduler.runtime.job.ScheduledJob.java
/** * @author Vinay Gangoli// ww w . j a va 2s . com * All jobs must extend this class. this handles the hibernate session scope for the jobs. */ public void execute(JobExecutionContext context) throws JobExecutionException { logger.debug("Executing Scheduled Job"); WebRequest webRequest = new ServletWebRequest(new MockHttpServletRequest()); OpenSessionInViewInterceptor interceptor = null; try { // init the member variables scheduler = context.getScheduler(); jobDetail = context.getJobDetail(); applicationContext = (ApplicationContext) scheduler.getContext().get("applicationContext"); plannedNotificationDao = (PlannedNotificationDao) applicationContext.getBean("plannedNotificationDao"); recipientScheduledNotificationDao = (RecipientScheduledNotificationDao) applicationContext .getBean("recipientScheduledNotificationDao"); interceptor = (OpenSessionInViewInterceptor) applicationContext.getBean("openSessionInViewInterceptor"); interceptor.preHandle(webRequest); JobDataMap jobDataMap = jobDetail.getJobDataMap(); Integer plannedNotificationId = jobDataMap.getInt("plannedNotificationId"); //PlannedNotification plannedNotification = plannedNotificationDao.getInitializedPlannedNotificationById(plannedNotificationId); PlannedNotification plannedNotification = plannedNotificationDao.getById(plannedNotificationId); setAuditInfo(); RecipientScheduledNotification recipientScheduledNotification = null; if (jobDataMap.containsKey("recipientScheduledNotificationId")) { Integer recipientScheduledNotificationId = jobDataMap.getInt("recipientScheduledNotificationId"); //recipientScheduledNotification = recipientScheduledNotificationDao.getInitializedRecipientScheduledNotificationById(recipientScheduledNotificationId); recipientScheduledNotification = recipientScheduledNotificationDao .getById(recipientScheduledNotificationId); } if (plannedNotification.getEventName() != null) { try { processJob(jobDataMap, recipientScheduledNotification, plannedNotification); } catch (JobExecutionException jee) { logger.error(jee.getMessage()); } } //try commenting out the postHandle ...might not be necessary! interceptor.postHandle(webRequest, null); } catch (RuntimeException exception) { logger.error(exception.getMessage()); // Get cause if present Throwable t = ((HibernateJdbcException) exception).getRootCause(); while (t != null) { //t = t.getCause(); } catch (Exception e) { logger.error("execution of job failed", e); } finally { interceptor.afterCompletion(webRequest, null); } }