Permalink
Browse files

Merged in changes from 1.0.2.BRANCH

  • Loading branch information...
2 parents 4154de0 + 66c2030 commit fecb7dcc6bf6937e34a39d689f777ac9ef1b90f9 Craig Walls committed Aug 24, 2012
Showing with 663 additions and 265 deletions.
  1. +2 −2 build.gradle
  2. +5 −0 spring-social-facebook/src/main/java/org/springframework/social/facebook/api/Page.java
  3. +1 −11 ...ial-facebook/src/main/java/org/springframework/social/facebook/api/impl/FacebookErrorHandler.java
  4. +23 −0 ...ng-social-facebook/src/main/java/org/springframework/social/facebook/api/impl/json/PageMixin.java
  5. +0 −5 ...ocial-facebook/src/test/java/org/springframework/social/facebook/api/AbstractFacebookApiTest.java
  6. +9 −7 ...ng-social-facebook/src/test/java/org/springframework/social/facebook/api/CommentTemplateTest.java
  7. +32 −24 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/ErrorHandlingTest.java
  8. +19 −18 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/EventTemplateTest.java
  9. +41 −42 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/FeedTemplateTest.java
  10. +6 −5 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/FqlTemplateTest.java
  11. +24 −23 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/FriendTemplateTest.java
  12. +8 −7 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/GroupTemplateTest.java
  13. +35 −28 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/LikeTemplateTest.java
  14. +314 −0 ...ebook/src/test/java/org/springframework/social/facebook/api/LikeTemplate_PreOctober2012_Test.java
  15. +22 −21 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/MediaTemplateTest.java
  16. +2 −1 ...-social-facebook/src/test/java/org/springframework/social/facebook/api/OpenGraphTemplateTest.java
  17. +10 −9 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/PageTemplateTest.java
  18. +10 −9 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/PlacesTemplateTest.java
  19. +11 −10 ...g-social-facebook/src/test/java/org/springframework/social/facebook/api/QuestionTemplateTest.java
  20. +8 −11 spring-social-facebook/src/test/java/org/springframework/social/facebook/api/UserTemplateTest.java
  21. +0 −6 ...facebook/src/test/java/org/springframework/social/facebook/api/testdata/error-not-a-question.json
  22. +0 −24 ...ng-social-facebook/src/test/java/org/springframework/social/facebook/api/testdata/user-likes.json
  23. 0 ...cebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/accounts.json
  24. 0 ...book/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/activities.json
  25. 0 ...ava → resources}/org/springframework/social/facebook/api/testdata/album-with-unknown-privacy.json
  26. 0 .../{java → resources}/org/springframework/social/facebook/api/testdata/album-with-unknown-type.json
  27. 0 ...-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/album.json
  28. 0 ...facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/albums.json
  29. 0 ...rc/test/{java → resources}/org/springframework/social/facebook/api/testdata/application-page.json
  30. 0 ...ebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/attending.json
  31. 0 ...acebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/checkin.json
  32. 0 ...cebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/checkins.json
  33. 0 ...acebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/comment.json
  34. +1 −1 ...cebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/comments.json
  35. 0 .../test/{java → resources}/org/springframework/social/facebook/api/testdata/create-friend-list.json
  36. 0 ...cebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/declined.json
  37. 0 ...est/{java → resources}/org/springframework/social/facebook/api/testdata/error-app-capability.json
  38. 0 ...va → resources}/org/springframework/social/facebook/api/testdata/error-current-user-no-token.json
  39. 0 ...t/{java → resources}/org/springframework/social/facebook/api/testdata/error-duplicate-status.json
  40. 0 ...ava → resources}/org/springframework/social/facebook/api/testdata/error-duplicate-to-twitter.json
  41. 0 ...test/{java → resources}/org/springframework/social/facebook/api/testdata/error-expired-token.json
  42. 0 ...a → resources}/org/springframework/social/facebook/api/testdata/error-insufficient-privilege.json
  43. 0 .../test/{java → resources}/org/springframework/social/facebook/api/testdata/error-invalid-fbid.json
  44. 0 ...ava → resources}/org/springframework/social/facebook/api/testdata/error-invalid-token-deauth.json
  45. 0 ...a → resources}/org/springframework/social/facebook/api/testdata/error-invalid-token-password.json
  46. 0 ...va → resources}/org/springframework/social/facebook/api/testdata/error-invalid-token-signout.json
  47. 0 .../test/{java → resources}/org/springframework/social/facebook/api/testdata/error-not-a-friend.json
  48. 0 .../src/test/{java → resources}/org/springframework/social/facebook/api/testdata/error-not-json.html
  49. 0 ...test/{java → resources}/org/springframework/social/facebook/api/testdata/error-not-the-owner.json
  50. 0 ...rc/test/{java → resources}/org/springframework/social/facebook/api/testdata/error-permission.json
  51. 0 ...rc/test/{java → resources}/org/springframework/social/facebook/api/testdata/error-rate-limit.json
  52. 0 ...test/{java → resources}/org/springframework/social/facebook/api/testdata/error-unknown-alias.json
  53. 0 .../test/{java → resources}/org/springframework/social/facebook/api/testdata/error-unknown-path.json
  54. 0 ...test/{java → resources}/org/springframework/social/facebook/api/testdata/error-url-parameter.json
  55. 0 ...va → resources}/org/springframework/social/facebook/api/testdata/error-user-hasnt-authorized.json
  56. 0 ...src/test/{java → resources}/org/springframework/social/facebook/api/testdata/error-whitelist.json
  57. 0 ...book/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/event-list.json
  58. 0 ...-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/event.json
  59. 0 ...facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/family.json
  60. 0 ...t/{java → resources}/org/springframework/social/facebook/api/testdata/feed-with-unknown-type.json
  61. 0 ...l-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/feed.json
  62. 0 ...va → resources}/org/springframework/social/facebook/api/testdata/fql-result-basic-with-float.json
  63. 0 ...rc/test/{java → resources}/org/springframework/social/facebook/api/testdata/fql-result-basic.json
  64. 0 ...ava → resources}/org/springframework/social/facebook/api/testdata/fql-result-list-of-objects.json
  65. 0 ...a → resources}/org/springframework/social/facebook/api/testdata/fql-result-with-object-field.json
  66. 0 .../src/test/{java → resources}/org/springframework/social/facebook/api/testdata/fql-with-nulls.json
  67. 0 ...book/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/friend-ids.json
  68. 0 ...ook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/friend-list.json
  69. 0 ...ok/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/friend-lists.json
  70. 0 ...acebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/friends.json
  71. 0 ...book/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/full-event.json
  72. 0 ...ok/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/full-profile.json
  73. 0 ...-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/games.json
  74. 0 ...book/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/group-list.json
  75. 0 ...k/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/group-members.json
  76. 0 ...c/test/{java → resources}/org/springframework/social/facebook/api/testdata/group-memberships.json
  77. 0 ...-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/group.json
  78. 0 ...acebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/id-only.json
  79. 0 ...ebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/interests.json
  80. 0 ...acebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/invited.json
  81. 0 ...-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/likes.json
  82. 0 ...-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/links.json
  83. 0 ...src/test/{java → resources}/org/springframework/social/facebook/api/testdata/maybe-attending.json
  84. 0 ...→ resources}/org/springframework/social/facebook/api/testdata/minimal-profile-no-middle-name.json
  85. 0 ...src/test/{java → resources}/org/springframework/social/facebook/api/testdata/minimal-profile.json
  86. +50 −0 ...-facebook/src/test/resources/org/springframework/social/facebook/api/testdata/new-user-likes.json
  87. 0 ...book/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/no-replies.json
  88. 0 ...c/test/{java → resources}/org/springframework/social/facebook/api/testdata/organization-page.json
  89. 0 ...-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/photo.json
  90. 0 ...facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/photos.json
  91. 0 ...book/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/place-page.json
  92. 0 ...ook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/places-list.json
  93. 0 ...ebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/post-list.json
  94. 0 ...l-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/post.json
  95. 0 ...ok/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/post_nolikes.json
  96. 0 ...ok/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/product-page.json
  97. 0 ...src/test/{java → resources}/org/springframework/social/facebook/api/testdata/question-option.json
  98. 0 ...rc/test/{java → resources}/org/springframework/social/facebook/api/testdata/question-options.json
  99. 0 ...st/{java → resources}/org/springframework/social/facebook/api/testdata/question-with-options.json
  100. 0 ...{java → resources}/org/springframework/social/facebook/api/testdata/question-without-options.json
  101. 0 ...est/{java → resources}/org/springframework/social/facebook/api/testdata/questions-asked-list.json
  102. 0 ...ebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/questions.json
  103. 0 ...ok/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/simple-event.json
  104. 0 .../src/test/{java → resources}/org/springframework/social/facebook/api/testdata/subscribe-list.json
  105. BIN ...facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/tinyrod.jpg
  106. 0 ...ook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/user-events.json
  107. +26 −0 ...cial-facebook/src/test/resources/org/springframework/social/facebook/api/testdata/user-likes.json
  108. 0 ...book/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/user-notes.json
  109. 0 ...rc/test/{java → resources}/org/springframework/social/facebook/api/testdata/user-permissions.json
  110. 0 ...k/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/user-profiles.json
  111. 0 ...src/test/{java → resources}/org/springframework/social/facebook/api/testdata/user-references.json
  112. 0 ...k/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/user-statuses.json
  113. 0 ...-facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/video.json
  114. 0 ...facebook/src/test/{java → resources}/org/springframework/social/facebook/api/testdata/videos.json
  115. +4 −0 src/dist/changelog.txt
  116. +0 −1 src/dist/readme.txt
View
@@ -18,13 +18,13 @@ configure(allprojects) {
targetCompatibility=1.5
springSocialVersion = '1.1.0.BUILD-SNAPSHOT'
- jacksonVersion = '1.9.6'
+ jacksonVersion = '1.9.9'
jspApiVersion = '2.1'
junitVersion = '4.10'
mockitoVersion = '1.9.0'
servletApiVersion = '2.5'
springSecurityCryptoVersion = '3.1.0.RELEASE'
- springVersion = '3.1.1.RELEASE'
+ springVersion = '3.1.2.RELEASE'
springTestMvcVersion = "1.0.0.BUILD-SNAPSHOT"
[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:none']
@@ -87,6 +87,11 @@ public String getWebsite() {
return website;
}
+ /**
+ * The page's picture.
+ * @deprecated This method will be replaced in Spring 1.1.0 with a new version that returns an object with more details about the picture.
+ */
+ @Deprecated
public String getPicture() {
return picture;
}
@@ -62,16 +62,6 @@ public void handleError(ClientHttpResponse response) throws IOException {
// if not otherwise handled, do default handling and wrap with UncategorizedApiException
handleUncategorizedError(response, errorDetails);
}
-
- @Override
- public boolean hasError(ClientHttpResponse response) throws IOException {
- if(super.hasError(response)) {
- return true;
- }
- // only bother checking the body for errors if we get past the default error check
- String content = readFully(response.getBody());
- return content.startsWith("{\"error\":") || content.equals("false");
- }
/**
* Examines the error data returned from Facebook and throws the most applicable exception.
@@ -82,7 +72,7 @@ void handleFacebookError(HttpStatus statusCode, Map<String, String> errorDetails
// Can rely only on the message (which itself isn't very consistent).
String message = errorDetails.get("message");
- if (statusCode == HttpStatus.OK) {
+ if (statusCode == HttpStatus.NOT_FOUND) {
if (message.contains("Some of the aliases you requested do not exist")) {
throw new ResourceNotFoundException(message);
}
@@ -15,9 +15,17 @@
*/
package org.springframework.social.facebook.api.impl.json;
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.springframework.social.facebook.api.Location;
/**
@@ -44,6 +52,7 @@
String website;
@JsonProperty("picture")
+ @JsonDeserialize(using=PagePictureDeserializer.class)
String picture;
@JsonProperty("phone")
@@ -63,4 +72,18 @@
@JsonProperty("checkins")
int checkins;
+
+ private static class PagePictureDeserializer extends JsonDeserializer<String> {
+ @Override
+ public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
+ JsonNode tree = jp.readValueAsTree();
+ if (tree.isObject() && tree.has("data")) {
+ return tree.get("data").get("url").asText();
+ } else if (tree.isTextual()) {
+ return tree.asText();
+ }
+ return null;
+ }
+ }
+
}
@@ -24,8 +24,6 @@
import org.junit.Before;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
import org.springframework.social.facebook.api.impl.FacebookTemplate;
import org.springframework.test.web.client.MockRestServiceServer;
@@ -35,14 +33,11 @@
protected FacebookTemplate facebook;
protected FacebookTemplate unauthorizedFacebook;
protected MockRestServiceServer mockServer;
- protected HttpHeaders responseHeaders;
@Before
public void setup() {
facebook = createFacebookTemplate();
mockServer = MockRestServiceServer.createServer(facebook.getRestTemplate());
- responseHeaders = new HttpHeaders();
- responseHeaders.setContentType(MediaType.APPLICATION_JSON);
unauthorizedFacebook = new FacebookTemplate();
MockRestServiceServer.createServer(unauthorizedFacebook.getRestTemplate());
@@ -23,6 +23,8 @@
import java.util.List;
import org.junit.Test;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.http.MediaType;
import org.springframework.social.NotAuthorizedException;
/**
@@ -31,11 +33,11 @@
public class CommentTemplateTest extends AbstractFacebookApiTest {
@Test
- public void getComments() {
+ public void getComments() throws Exception {
mockServer.expect(requestTo("https://graph.facebook.com/123456/comments?offset=0&limit=25"))
.andExpect(method(GET))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andRespond(withResponse(jsonResource("testdata/comments"), responseHeaders));
+ .andRespond(withSuccess(new FileSystemResource("/Users/habuma/foo.json"), MediaType.APPLICATION_JSON));
List<Comment> comments = facebook.commentOperations().getComments("123456");
assertEquals(2, comments.size());
@@ -54,7 +56,7 @@ public void getComments_withOffsetAndLimit() {
mockServer.expect(requestTo("https://graph.facebook.com/123456/comments?offset=75&limit=100"))
.andExpect(method(GET))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andRespond(withResponse(jsonResource("testdata/comments"), responseHeaders));
+ .andRespond(withSuccess(jsonResource("testdata/comments"), MediaType.APPLICATION_JSON));
List<Comment> comments = facebook.commentOperations().getComments("123456", 75, 100);
assertEquals(2, comments.size());
@@ -73,7 +75,7 @@ public void getComment() {
mockServer.expect(requestTo("https://graph.facebook.com/1533260333_122829644452184_587062"))
.andExpect(method(GET))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andRespond(withResponse(jsonResource("testdata/comment"), responseHeaders));
+ .andRespond(withSuccess(jsonResource("testdata/comment"), MediaType.APPLICATION_JSON));
Comment comment = facebook.commentOperations().getComment("1533260333_122829644452184_587062");
assertEquals("1533260333", comment.getFrom().getId());
assertEquals("Art Names", comment.getFrom().getName());
@@ -88,7 +90,7 @@ public void addComment() {
.andExpect(method(POST))
.andExpect(body("message=Cool+beans"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andRespond(withResponse("{\"id\":\"123456_543210\"}", responseHeaders));
+ .andRespond(withSuccess("{\"id\":\"123456_543210\"}", MediaType.APPLICATION_JSON));
assertEquals("123456_543210", facebook.commentOperations().addComment("123456", "Cool beans"));
}
@@ -103,7 +105,7 @@ public void deleteComment() {
.andExpect(method(POST))
.andExpect(body("method=delete"))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andRespond(withResponse("{}", responseHeaders));
+ .andRespond(withSuccess("{}", MediaType.APPLICATION_JSON));
facebook.commentOperations().deleteComment("1533260333_122829644452184_587062");
mockServer.verify();
}
@@ -117,7 +119,7 @@ public void deleteComment_unauthorized() {
public void getLikes() {
mockServer.expect(requestTo("https://graph.facebook.com/123456/likes")).andExpect(method(GET))
.andExpect(header("Authorization", "OAuth someAccessToken"))
- .andRespond(withResponse(jsonResource("testdata/likes"), responseHeaders));
+ .andRespond(withSuccess(jsonResource("testdata/likes"), MediaType.APPLICATION_JSON));
List<Reference> likes = facebook.commentOperations().getLikes("123456");
assertEquals(3, likes.size());
Reference like1 = likes.get(0);
Oops, something went wrong.

0 comments on commit fecb7dc

Please sign in to comment.