Package org.springframework.test.web.servlet

Examples of org.springframework.test.web.servlet.MockMvc.perform()


    ConnectController connectController = new ConnectController(connectionFactoryLocator, null);
    List<ConnectInterceptor<?>> interceptors = getConnectInterceptor();
    connectController.setConnectInterceptors(interceptors);
    connectController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(connectController).build();
    mockMvc.perform(post("/connect/oauth2Provider"))
      .andExpect(redirectedUrl(OAUTH2_AUTHORIZE_URL + "&state=STATE"));
    // Check for preConnect() only. The postConnect() won't be invoked until after callback
    assertFalse(((TestConnectInterceptor<?>)(interceptors.get(0))).preConnectInvoked);
    TestConnectInterceptor<?> testInterceptor2 = (TestConnectInterceptor<?>)(interceptors.get(1));
    assertTrue(testInterceptor2.preConnectInvoked);
View Full Code Here


    ConnectionFactory<TestApi2> connectionFactory = new StubOAuth2ConnectionFactory("clientId", "clientSecret");
    connectionFactoryLocator.addConnectionFactory(connectionFactory);
    ConnectController connectController = new ConnectController(connectionFactoryLocator, null);
    connectController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(connectController).build();
    mockMvc.perform(post("/connect/oauth2Provider").param("scope", "read,write"))
      .andExpect(redirectedUrl(OAUTH2_AUTHORIZE_URL + "&scope=read%2Cwrite&state=STATE"));
  }
 
  @Test
  public void oauth2Callback() throws Exception {
View Full Code Here

    List<ConnectInterceptor<?>> interceptors = getConnectInterceptor();
    connectController.setConnectInterceptors(interceptors);
    connectController.afterPropertiesSet();
    MockMvc mockMvc = standaloneSetup(connectController).build();
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
    mockMvc.perform(get("/connect/oauth2Provider").param("code", "oauth2Code"))
      .andExpect(redirectedUrl("/connect/oauth2Provider"));
    List<Connection<?>> connections = connectionRepository.findConnections("oauth2Provider");
    assertEquals(1, connections.size());
    assertEquals("oauth2Provider", connections.get(0).getKey().getProviderId());
    // Check for postConnect() only. The preConnect() is only invoked during the initial portion of the flow
View Full Code Here

    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());   
    mockMvc.perform(get("/connect/oauth2Provider").param("code", "oauth2Code"))
      .andExpect(redirectedUrl("/connect/oauth2Provider"))
      .andExpect(request().sessionAttribute("social_provider_error", notNullValue()));
    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
  }
 
View Full Code Here

    assertEquals(0, connectionRepository.findConnections("oauth2Provider").size());   
    HashMap<String, String> expectedError = new HashMap<String, String>();
    expectedError.put("error", "access_denied");
    expectedError.put("errorDescription", "The user said no.");
    expectedError.put("errorUri", "http://provider.com/user/said/no");
    mockMvc.perform(get("/connect/oauth2Provider").param("error", "access_denied")
                            .param("error_description", "The user said no.")
                            .param("error_uri", "http://provider.com/user/said/no"))
      .andExpect(redirectedUrl("/connect/oauth2Provider"))
      .andExpect(request().sessionAttribute("social_authorization_error", notNullValue()))
      .andExpect(request().sessionAttribute("social_authorization_error", expectedError));
View Full Code Here

    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

    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

    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

    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

    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

TOP
Copyright © 2018 www.massapi.com. 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.