Package org.springframework.test.web.servlet

Examples of org.springframework.test.web.servlet.MockMvc


  public void oauth2ErrorCallback_noDescriptionOrUri() throws Exception {
    ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    StubConnectionRepository connectionRepository = new StubConnectionRepository();
    MockMvc mockMvc = standaloneSetup(new ConnectController(connectionFactoryLocator, connectionRepository)).build();
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
    HashMap<String, String> expectedError = new HashMap<String, String>();
    expectedError.put("error", "access_denied");
    mockMvc.perform(get("/connect/oauth2Provider").param("error", "access_denied"))
      .andExpect(redirectedUrl("/connect/oauth2Provider"))
      .andExpect(request().sessionAttribute("social_authorization_error", notNullValue()))
      .andExpect(request().sessionAttribute("social_authorization_error", expectedError));
  }
View Full Code Here


    Map<String, String> tokens = new HashMap<String, String>();
    tokens.put("foo", "yabbadabbadoo");
    List<UpdateHandler> updateHandlers = new ArrayList<UpdateHandler>();
    RealTimeUpdateController controller = new RealTimeUpdateController(tokens, updateHandlers, "signature");
   
    MockMvc mockMvc = standaloneSetup(controller).build();
    mockMvc.perform(get("/realtime/facebook/foo")
              .param("hub.mode", "subscribe")
              .param("hub.verify_token", "yabbadabbadoo")
              .param("hub.challenge", "123456789")).andExpect(content().string("123456789"));
  }
View Full Code Here

    Map<String, String> tokens = new HashMap<String, String>();
    tokens.put("foo", "yabbadabbadoo");
    List<UpdateHandler> updateHandlers = new ArrayList<UpdateHandler>();
    RealTimeUpdateController controller = new RealTimeUpdateController(tokens, updateHandlers, "shhhhh!!!!");
   
    MockMvc mockMvc = standaloneSetup(controller).build();
    mockMvc.perform(get("/realtime/facebook/foo")
              .param("hub.mode", "subscribe")
              .param("hub.verify_token", "doh!")
              .param("hub.challenge", "123456789")).andExpect(content().string(""));
  }
View Full Code Here

  public void receiveUpdate_simple() throws Exception {   
    TestUpdateHandler handler = new TestUpdateHandler();
    List<UpdateHandler> handlers = new ArrayList<UpdateHandler>();
    handlers.add(handler);
    RealTimeUpdateController controller = new RealTimeUpdateController(new HashMap<String, String>(), handlers, "shhhhh!!!!");
    MockMvc mockMvc =
        standaloneSetup(controller)
        .build();
    mockMvc.perform(post("/realtime/facebook/foo")
              .contentType(APPLICATION_JSON)
              .content(jsonFromFile("rtupdate-simple"))
              .header("X-Hub-Signature", "sha1=765aa709e93724268969ad0cd922d6e0acbb3f35"))
      .andExpect(content().string(""));
   
View Full Code Here

  public void receiveUpdate_manyUpdatesSingleSubscription() throws Exception {
    TestUpdateHandler handler = new TestUpdateHandler();
    List<UpdateHandler> handlers = new ArrayList<UpdateHandler>();
    handlers.add(handler);
    RealTimeUpdateController controller = new RealTimeUpdateController(new HashMap<String, String>(), handlers, "shhhhh!!!!");
    MockMvc mockMvc =
        standaloneSetup(controller)
        .build();
    mockMvc.perform(post("/realtime/facebook/foo")
              .contentType(APPLICATION_JSON)
              .content(jsonFromFile("rtupdate-many"))
              .header("X-Hub-Signature", "sha1=816505e95f33287950e8992488637871085164c2"))
      .andExpect(content().string(""));
    MultiValueMap<String, RealTimeUpdate> updates = handler.getUpdates();
View Full Code Here

  public void receiveUpdate_manySubscriptions() throws Exception {
    TestUpdateHandler handler = new TestUpdateHandler();
    List<UpdateHandler> handlers = new ArrayList<UpdateHandler>();
    handlers.add(handler);
    RealTimeUpdateController controller = new RealTimeUpdateController(new HashMap<String, String>(), handlers, "shhhhh!!!!");
    MockMvc mockMvc =
        standaloneSetup(controller)
        .build();
    mockMvc.perform(post("/realtime/facebook/foo")
              .contentType(APPLICATION_JSON)
              .content(jsonFromFile("rtupdate-simple"))
              .header("X-Hub-Signature", "sha1=765aa709e93724268969ad0cd922d6e0acbb3f35"))
      .andExpect(content().string(""));
    mockMvc.perform(post("/realtime/facebook/bar")
        .contentType(APPLICATION_JSON)
        .content(jsonFromFile("rtupdate-simple"))
        .header("X-Hub-Signature", "sha1=765aa709e93724268969ad0cd922d6e0acbb3f35"))
      .andExpect(content().string(""));
   
View Full Code Here

  public void receiveUpdate_badSignature() throws Exception {   
    TestUpdateHandler handler = new TestUpdateHandler();
    List<UpdateHandler> handlers = new ArrayList<UpdateHandler>();
    handlers.add(handler);
    RealTimeUpdateController controller = new RealTimeUpdateController(new HashMap<String, String>(), handlers, "shhhhh!!!!");
    MockMvc mockMvc =
        standaloneSetup(controller)
        .build();
    mockMvc.perform(post("/realtime/facebook/foo")
              .contentType(APPLICATION_JSON)
              .content(jsonFromFile("rtupdate-simple"))
              .header("X-Hub-Signature", "sha1=765aa709e93724268969ad0cd922d6e0acbb3f36"))
      .andExpect(content().string(""));
   
View Full Code Here

  public void receiveUpdate_missingSignature() throws Exception {   
    TestUpdateHandler handler = new TestUpdateHandler();
    List<UpdateHandler> handlers = new ArrayList<UpdateHandler>();
    handlers.add(handler);
    RealTimeUpdateController controller = new RealTimeUpdateController(new HashMap<String, String>(), handlers, "shhhhh!!!!");
    MockMvc mockMvc =
        standaloneSetup(controller)
        .build();
    mockMvc.perform(post("/realtime/facebook/foo")
              .contentType(APPLICATION_JSON)
              .content(jsonFromFile("rtupdate-simple")))
      .andExpect(content().string(""));
   
    MultiValueMap<String, RealTimeUpdate> updates = handler.getUpdates();
View Full Code Here

    StubUsersConnectionRepository usersConnectionRepository = new StubUsersConnectionRepository();
    ConnectionRepository connectionRepository = usersConnectionRepository.createConnectionRepository("habuma");
    connectionRepository.addConnection(connection);
    assertEquals(1, connectionRepository.findAllConnections().size());
    DisconnectController controller = new DisconnectController(usersConnectionRepository, CLIENT_SECRET);
    MockMvc mockMvc = standaloneSetup(controller).build();
    mockMvc.perform(post("/disconnect/facebook").param("signed_request", SIGNED_REQUEST))
      .andExpect(status().isNoContent());   
    assertEquals(0, connectionRepository.findAllConnections().size());
  }
View Full Code Here

TOP

Related Classes of org.springframework.test.web.servlet.MockMvc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.