import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
-import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.http.OAuth2ErrorHandler;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import static org.springframework.security.oauth2.common.OAuth2AccessToken.OAUTH2_TYPE;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
-import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.HttpClientErrorException;
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(OAuth2Exception e)
+ catch(HttpClientErrorException e)
{
log.debug("{}", e.toString());
- assertEquals("invalid_request", e.getOAuth2ErrorCode());
- assertFalse(e instanceof GraphApiException);
+ }
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
}
clientTemplate.getForObject("ANY", SOME.class);
fail("The expected exception was not thrown");
}
- catch(HttpMessageNotReadableException e)
+ catch(HttpClientErrorException e)
{
- // TODO: OAuth2ErrorHandler fails, if body contains no valid JSON!
log.debug("{}", e.toString());
}
+ catch(Exception e)
+ {
+ fail("A wrong exception was thrown: " + e.toString());
+ }
}