Example usage for org.springframework.mock.web MockHttpServletRequest MockHttpServletRequest

List of usage examples for org.springframework.mock.web MockHttpServletRequest MockHttpServletRequest

Introduction

In this page you can find the example usage for org.springframework.mock.web MockHttpServletRequest MockHttpServletRequest.

Prototype

public MockHttpServletRequest() 

Source Link

Document

Create a new MockHttpServletRequest with a default MockServletContext .

Usage

From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.LocationControllerTest.java

@Before
public void before() {
    this.service = Context.getLocationService();
    this.controller = new LocationController();
    this.request = new MockHttpServletRequest();
    this.response = new MockHttpServletResponse();
}

From source file:org.raxa.module.raxacore.web.v1_0.controller.DrugGroupControllerTest.java

@Before
public void before() throws Exception {
    executeDataSet(MODULE_TEST_DATA_XML);
    this.request = new MockHttpServletRequest();
    this.response = new MockHttpServletResponse();
    this.controller = new DrugGroupController();
    this.service = Context.getService(DrugGroupService.class);
}

From source file:net.lshift.diffa.adapter.scanning.ConstraintsBuilderTest.java

@Test
public void shouldNotAddSetConstraintForEmptyRequest() {
    MockHttpServletRequest req = new MockHttpServletRequest();
    ConstraintsBuilder builder = new ConstraintsBuilder(req);

    builder.maybeAddSetConstraint("test");
    assertEquals(0, builder.toList().size());
}

From source file:com.google.api.server.spi.auth.EndpointsPeerAuthenticatorTest.java

@Before
public void setUp() throws Exception {
    System.clearProperty(EnvUtil.ENV_APPENGINE_RUNTIME);
    authenticator = new EndpointsPeerAuthenticator(jwtAuthenticator);
    request = new MockHttpServletRequest();
    request.setRemoteAddr("8.8.8.8");
}

From source file:org.openmrs.module.webservices.rest19ext.web.v1_0.controller.ProviderAttributeControllerTest.java

@Before
public void before() throws Exception {
    executeDataSet(Rest19ExtTestConstants.TEST_DATASET);
    this.service = Context.getProviderService();
    this.controller = new ProviderAttributeController();
    this.request = new MockHttpServletRequest();
    this.response = new MockHttpServletResponse();
}

From source file:org.sventon.web.UserRepositoryContextTest.java

@Test
public void testGetUserContext() throws Exception {
    final RepositoryName name = new RepositoryName("repository1");
    final HttpServletRequest request = new MockHttpServletRequest();
    assertNull(request.getSession().getAttribute("userContext"));
    final UserRepositoryContext userRepositoryContext = UserRepositoryContext.getContext(request, name);
    assertNotNull(request.getSession());
    final Object o = request.getSession().getAttribute("userContext");
    assertNotNull(o);//from  w  ww  .  j  a  v a  2 s.co m
    assertTrue(o instanceof UserContext);
    final UserRepositoryContext contextFromSession = ((UserContext) o).getUserRepositoryContext(name);
    assertSame(contextFromSession, userRepositoryContext);
}

From source file:org.jasig.cas.web.FlowExecutionExceptionResolverTests.java

@Test
public void testNoSuchFlowExecutionException() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("test");
    ModelAndView model = this.resolver.resolveException(request, new MockHttpServletResponse(), null,
            new NoSuchFlowExecutionException(new FlowExecutionKey() {

                private static final long serialVersionUID = 1443616250214416520L;

                @Override//from   w  w  w .j  a v  a  2 s  .c o m
                public String toString() {
                    return "test";
                }

                @Override
                public boolean equals(final Object o) {
                    return true;
                }

                @Override
                public int hashCode() {
                    return 0;
                }
            }, new RuntimeException()));

    assertEquals(request.getRequestURI(), ((RedirectView) model.getView()).getUrl());
}

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   ww  w .j a  v a2 s. c  o m*/
    assertThat(resolved.getValue()).isFalse();
}

From source file:ch.rasc.extclassgenerator.ModelGeneratorBeanWithGenericValidationTest.java

@Test
public void testWriteModelHttpServletRequestHttpServletResponseClassOfQOutputFormatBoolean()
        throws IOException {
    MockHttpServletResponse response = new MockHttpServletResponse();
    ModelGenerator.writeModel(new MockHttpServletRequest(), response, BeanWithGenericValidation.class,
            OutputFormat.EXTJS4, IncludeValidation.ALL, true);
    GeneratorTestUtil.compareExtJs4Code("BeanWithGenericValidation", response.getContentAsString(), true,
            false);/*from   ww w.  ja v a 2 s .  co  m*/

    response = new MockHttpServletResponse();
    ModelGenerator.writeModel(new MockHttpServletRequest(), response, BeanWithGenericValidation.class,
            OutputFormat.TOUCH2, IncludeValidation.ALL, false);
    GeneratorTestUtil.compareTouch2Code("BeanWithGenericValidation", response.getContentAsString(), false,
            false);

    response = new MockHttpServletResponse();
    ModelGenerator.writeModel(new MockHttpServletRequest(), response, BeanWithGenericValidation.class,
            OutputFormat.EXTJS4, IncludeValidation.ALL, true);
    GeneratorTestUtil.compareExtJs4Code("BeanWithGenericValidation", response.getContentAsString(), true,
            false);

    response = new MockHttpServletResponse();
    ModelGenerator.writeModel(new MockHttpServletRequest(), response, BeanWithGenericValidation.class,
            OutputFormat.TOUCH2, IncludeValidation.ALL, true);
    GeneratorTestUtil.compareTouch2Code("BeanWithGenericValidation", response.getContentAsString(), true,
            false);
}

From source file:org.cloudfoundry.identity.uaa.oauth.AccessControllerTests.java

@Test
public void testSunnyDay() throws Exception {
    InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService();
    clientDetailsService.setClientDetailsStore(Collections.singletonMap("client", new BaseClientDetails()));
    controller.setClientDetailsService(clientDetailsService);
    controller.setApprovalStore(Mockito.mock(ApprovalStore.class));
    Authentication auth = UaaAuthenticationTestFactory.getAuthentication("foo@bar.com", "Foo Bar",
            "foo@bar.com");
    String result = controller.confirm(new ModelMap(), new MockHttpServletRequest(), auth,
            new SimpleSessionStatus());
    assertEquals("access_confirmation", result);
}