Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed to support latest Spring Social

  • Loading branch information...
commit 0ab1c1cb70a2179d665bf7542d89b5d05eae3a32 1 parent b0b9e6c
@vbfischer authored
View
5 build.gradle
@@ -0,0 +1,5 @@
+
+description = 'Spring Social Dropbox'
+abbreviation = 'SOCIAL-DROPBOX'
+
+apply plugin: 'base'
View
25 pom.xml
@@ -12,8 +12,8 @@
<properties>
<java-version>1.6</java-version>
<org.springframework.social-version>1.0.0.BUILD-SNAPSHOT</org.springframework.social-version>
- <org.springframework-version>3.1.0.M1</org.springframework-version>
- <org.springframework.security-version>3.1.0.RC1</org.springframework.security-version>
+ <org.springframework-version>3.1.0.M2</org.springframework-version>
+ <org.springframework.security-version>3.1.0.RC2</org.springframework.security-version>
<org.slf4j-version>1.6.1</org.slf4j-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -36,16 +36,24 @@
<version>${org.springframework.social-version}</version>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.2</version>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-core</artifactId>
+ <version>${org.springframework.security-version}</version>
</dependency>
+
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.5</version>
</dependency>
<dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+
+ <dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.7.3</version>
@@ -54,6 +62,13 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.2</version>
+ <scope>test</scope>
</dependency>
</dependencies>
View
6 src/main/java/org/springframework/social/dropbox/api/impl/DropboxTemplate.java
@@ -6,7 +6,7 @@
import org.springframework.social.dropbox.api.DropboxApi;
import org.springframework.social.dropbox.api.DropboxItemMetadata;
import org.springframework.social.dropbox.api.DropboxUserProfile;
-import org.springframework.social.oauth1.AbstractOAuth1ApiTemplate;
+import org.springframework.social.oauth1.AbstractOAuth1ApiBinding;
import org.springframework.web.client.RestTemplate;
import java.math.BigInteger;
@@ -17,7 +17,7 @@
* Date: 5/17/11
* Time: 9:22 AM
*/
-public class DropboxTemplate extends AbstractOAuth1ApiTemplate implements DropboxApi {
+public class DropboxTemplate extends AbstractOAuth1ApiBinding implements DropboxApi {
public DropboxTemplate(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) {
super(consumerKey, consumerSecret, accessToken, accessTokenSecret);
@@ -33,7 +33,7 @@ public DropboxUserProfile getUserProfile() {
}
public List<DropboxItemMetadata> getItemMetadata(String path, boolean list, BigInteger maxFiles) {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
private void registerDropboxJsonModule(RestTemplate restTemplate) {
View
32 src/test/java/org/springframework/social/dropbox/api/impl/AbstractDropboxApiTest.java
@@ -0,0 +1,32 @@
+package org.springframework.social.dropbox.api.impl;
+
+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.test.client.MockRestServiceServer;
+
+
+/**
+ * User: Bryce Fischer
+ * Date: 7/7/11
+ * Time: 1:01 PM
+ */
+public abstract class AbstractDropboxApiTest {
+ protected DropboxTemplate dropbox;
+ protected MockRestServiceServer mockServer;
+ protected HttpHeaders responseHeaders;
+
+ @Before
+ public void setUp() throws Exception {
+ dropbox = new DropboxTemplate("API_KEY", "API_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET");
+ mockServer = MockRestServiceServer.createServer(dropbox.getRestTemplate());
+ responseHeaders = new HttpHeaders();
+ responseHeaders.setContentType(MediaType.APPLICATION_JSON);
+ }
+
+ protected Resource jsonResource(String filename) {
+ return new ClassPathResource(filename + ".json");
+ }
+}
View
40 src/test/java/org/springframework/social/dropbox/api/impl/DropboxTemplateTest.java
@@ -1,12 +1,7 @@
package org.springframework.social.dropbox.api.impl;
-import org.junit.Before;
import org.junit.Test;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
import org.springframework.social.dropbox.api.DropboxUserProfile;
-import org.springframework.social.test.client.MockRestServiceServer;
import java.math.BigInteger;
@@ -21,31 +16,22 @@
* Date: 5/17/11
* Time: 9:41 AM
*/
-public class DropboxTemplateTest {
- private DropboxTemplate dropbox;
- private MockRestServiceServer mockServer;
- private HttpHeaders responseHeaders;
-
- @Before
- public void setUp() throws Exception {
- dropbox = new DropboxTemplate("API_KEY", "API_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET");
- mockServer = MockRestServiceServer.createServer(dropbox.getRestTemplate());
- responseHeaders = new HttpHeaders();
- responseHeaders.setContentType(MediaType.APPLICATION_JSON);
- }
-
+public class DropboxTemplateTest extends AbstractDropboxApiTest {
@Test
public void getUserProfileValid() throws Exception {
- final ClassPathResource classPathResource = new ClassPathResource("profile-valid.json", getClass());
-
- mockServer.expect(requestTo("https://api.dropbox.com/0/account/info")).andExpect(method(GET))
- .andRespond(withResponse(classPathResource, responseHeaders));
+ mockServer
+ .expect(requestTo("https://api.dropbox.com/0/account/info"))
+ .andExpect(method(GET))
+ .andRespond(withResponse(jsonResource("/profileValid"), responseHeaders));
DropboxUserProfile profile = dropbox.getUserProfile();
- assertEquals("USA", profile.getCountry());
- assertEquals("Test Q User", profile.getDisplayName());
- assertEquals(37378890, profile.getSharedQuota());
- assertEquals(new BigInteger("62277025792"), profile.getQuota());
- assertEquals(263758550, profile.getNormalQuota());
+ assertEquals("US", profile.getCountry());
+ assertEquals("Some User", profile.getDisplayName());
+ assertEquals("some email", profile.getEmail());
+ assertEquals(BigInteger.valueOf(10), profile.getUid());
+ assertEquals("referralLink", profile.getReferralLink());
+ assertEquals(BigInteger.valueOf(108179488768L), profile.getQuota());
+ assertEquals(BigInteger.valueOf(44962990383L), profile.getSharedQuota());
+ assertEquals(BigInteger.valueOf(46970996076L), profile.getNormalQuota());
}
}
View
10 src/test/java/org/springframework/social/dropbox/api/impl/profile-valid.json
@@ -1,10 +0,0 @@
-{
- "country": "USA",
- "display_name": "Test Q User",
- "quota_info": {
- "shared": 37378890,
- "quota": 62277025792,
- "normal": 263758550
- },
- "uid": "174"
-}
View
9 src/test/java/org/springframework/social/dropbox/connect/DropboxAdapterTest.java
@@ -23,15 +23,18 @@
public void fetchProfile() throws Exception {
final String country = "USA";
final String displayName = "DisplayName";
- final String uid = "UID";
+ final BigInteger uid = BigInteger.valueOf(1);
final BigInteger sharedQuota = BigInteger.valueOf(123);
final BigInteger quota = new BigInteger("62277025792");
final BigInteger normalQuota = BigInteger.valueOf(323);
- Mockito.when(dropboxApi.getUserProfile()).thenReturn(new DropboxUserProfile(country, displayName, uid, sharedQuota, quota, normalQuota));
+ String email = "emailaddress";
+ String referralLink = "referralLink";
+
+ Mockito.when(dropboxApi.getUserProfile())
+ .thenReturn(new DropboxUserProfile(uid, displayName, email, country, referralLink, sharedQuota, quota, normalQuota));
UserProfile profile = adapter.fetchUserProfile(dropboxApi);
assertEquals(displayName, profile.getName());
- assertEquals(uid, profile.getUsername());
}
}
View
12 src/test/resources/profileValid.json
@@ -0,0 +1,12 @@
+{
+ "referral_link":"referralLink",
+ "display_name":"Some User",
+ "uid":10,
+ "country":"US",
+ "quota_info":
+ {
+ "shared":44962990383,
+ "quota":108179488768,
+ "normal":46970996076
+ },
+"email":"some email"}
Please sign in to comment.
Something went wrong with that request. Please try again.