Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial Gradle Integration

  • Loading branch information...
commit d41a1c400bb99b7c3d942508384083788d30f37e 1 parent 76da87c
@vbfischer authored
Showing with 902 additions and 408 deletions.
  1. +3 −0  .gitmodules
  2. +145 −0 build.gradle
  3. +1 −0  buildSrc
  4. +45 −0 gradle.properties
  5. +151 −0 gradlew
  6. +126 −0 gradlew.bat
  7. +21 −0 settings.gradle
  8. +15 −15 { → spring-social-dropbox}/src/main/java/org/springframework/social/dropbox/api/DropboxApi.java
  9. +9 −9 { → spring-social-dropbox}/src/main/java/org/springframework/social/dropbox/api/DropboxItemMetadata.java
  10. +62 −62 { → spring-social-dropbox}/src/main/java/org/springframework/social/dropbox/api/DropboxUserProfile.java
  11. +21 −21 { → spring-social-dropbox}/src/main/java/org/springframework/social/dropbox/api/impl/DropboxModule.java
  12. +52 −52 { → spring-social-dropbox}/src/main/java/org/springframework/social/dropbox/api/impl/DropboxTemplate.java
  13. +41 −41 ...ring-social-dropbox}/src/main/java/org/springframework/social/dropbox/api/impl/DropboxUserProfileMixin.java
  14. +45 −45 { → spring-social-dropbox}/src/main/java/org/springframework/social/dropbox/connect/DropboxAdapter.java
  15. +15 −15 ...ring-social-dropbox}/src/main/java/org/springframework/social/dropbox/connect/DropboxConnectionFactory.java
  16. +28 −28 ...spring-social-dropbox}/src/main/java/org/springframework/social/dropbox/connect/DropboxServiceProvider.java
  17. +33 −32 ...pring-social-dropbox}/src/test/java/org/springframework/social/dropbox/api/impl/AbstractDropboxApiTest.java
  18. +37 −37 ...; spring-social-dropbox}/src/test/java/org/springframework/social/dropbox/api/impl/DropboxTemplateTest.java
  19. +41 −40 ...rr; spring-social-dropbox}/src/test/java/org/springframework/social/dropbox/connect/DropboxAdapterTest.java
  20. +11 −11 { → spring-social-dropbox}/src/test/resources/profileValid.json
View
3  .gitmodules
@@ -0,0 +1,3 @@
+[submodule "buildSrc"]
+ path = buildSrc
+ url = https://github.com/SpringSource/spring-build-gradle.git
View
145 build.gradle
@@ -1,5 +1,150 @@
+// -----------------------------------------------------------------------------
+// Main gradle build file for Spring Social Facebook
+// @author Bryce Fischer
+// ** WITH A LOT OF COPY/PASTA from the spring-social-facebook crew of
+// Craig Walls and Chris Beams.
+// -----------------------------------------------------------------------------
+ import org.springframework.build.Version
+
+// -----------------------------------------------------------------------------
+// Configuration for the root project
+// -----------------------------------------------------------------------------
description = 'Spring Social Dropbox'
abbreviation = 'SOCIAL-DROPBOX'
apply plugin: 'base'
+apply plugin: 'idea'
+
+def buildSrcDir = "$rootDir/buildSrc"
+apply from: "$buildSrcDir/wrapper.gradle"
+apply from: "$buildSrcDir/maven-root-pom.gradle"
+
+// -----------------------------------------------------------------------------
+// Configuration for all projects including this one (the root project)
+//
+// @see settings.gradle for list of all subprojects
+// -----------------------------------------------------------------------------
+allprojects {
+ // group will translate to groupId during pom generation and deployment
+ group = 'org.springframework.social'
+
+ // version will be used in maven pom generation as well as determining
+ // where artifacts should be deployed, based on release type of snapshot,
+ // milestone or release.
+ // @see org.springframework.build.Version under buildSrc/ for more info
+ // @see gradle.properties for the declaration of this property.
+ version = new Version(springSocialDropboxVersion)
+
+ // default set of maven repositories to be used when resolving dependencies
+ repositories {
+ mavenRepo urls: 'http://maven.springframework.org/release'
+ mavenRepo urls: 'http://maven.springframework.org/milestone'
+ mavenRepo urls: 'http://maven.springframework.org/snapshot'
+ mavenCentral()
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// Create collections of subprojects - each will receive their own configuration
+// - all subprojects that start with spring-social-* are 'java projects'
+// - documentation-related subprojects are not collected here
+//
+// @see configure(*) sections below
+// -----------------------------------------------------------------------------
+
+javaprojects = subprojects.findAll { project ->
+ project.path.startsWith(':spring-social-')
+}
+
+// -----------------------------------------------------------------------------
+// Configuration for all java subprojects
+// -----------------------------------------------------------------------------
+configure(javaprojects) {
+
+ apply plugin: 'java' // tasks for conventional java lifecycle
+ apply plugin: 'maven' // `gradle install` to push jars to local .m2 cache
+ apply plugin: 'eclipse' // `gradle eclipse` to generate .classpath/.project
+ apply plugin: 'idea' // `gradle idea` to generate .ipr/.iml
+
+ // set up dedicated directories for jars and source jars.
+ // this makes it easier when putting together the distribution
+ libsBinDir = new File(libsDir, 'bin')
+ libsSrcDir = new File(libsDir, 'src')
+
+ // add tasks for creating source jars and generating poms etc
+ apply from: "$buildSrcDir/maven-deployment.gradle"
+
+ // add tasks for finding and publishing .xsd files
+ apply from: "$buildSrcDir/schema-publication.gradle"
+
+ springSocialVersion = '1.0.2.BUILD-SNAPSHOT'
+ jacksonVersion = '1.9.3'
+ jspApiVersion = '2.1'
+ junitVersion = '4.10'
+ mockitoVersion = '1.9.0'
+ servletApiVersion = '2.5'
+ springVersion = '3.1.0.RELEASE'
+
+ sourceSets {
+ main {
+ resources {
+ srcDirs = ['src/main/java']
+ }
+ }
+ test {
+ resources {
+ srcDirs = ['src/test/java']
+ }
+ }
+ }
+
+ // dependencies that are common across all java projects
+ dependencies {
+ testCompile "junit:junit-dep:$junitVersion"
+ testCompile "org.mockito:mockito-all:$mockitoVersion"
+ testCompile "org.springframework:spring-test:$springVersion"
+ }
+
+ // enable all compiler warnings (GRADLE-1077)
+ [compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all']
+
+ // generate .classpath files without GRADLE_CACHE variable (GRADLE-1079)
+ eclipseClasspath.variables = [:]
+}
+
+// -----------------------------------------------------------------------------
+// Configuration for each individual core java subproject
+//
+// @see configure(javaprojects) above for general config
+// -----------------------------------------------------------------------------
+
+project('spring-social-dropbox') {
+ description = 'Drobox API'
+ dependencies {
+ compile "org.springframework.social:spring-social-core:$springSocialVersion"
+ compile "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion"
+ testCompile "org.springframework.social:spring-social-test:$springSocialVersion"
+ }
+}
+
+project('spring-social-dropbox-web') {
+ description = 'Drobox Web'
+ dependencies {
+ compile ("org.springframework:spring-web:$springVersion")
+ compile ("javax.servlet:servlet-api:$servletApiVersion") { provided = true }
+ compile ("javax.servlet.jsp:jsp-api:$jspApiVersion") { provided = true }
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+// Configuration for the docs subproject
+// -----------------------------------------------------------------------------
+project('docs') {
+ apply from: "$buildSrcDir/docs.gradle"
+}
+
+apply from: "$buildSrcDir/dist.gradle"
+apply from: "$buildSrcDir/checks.gradle"
1  buildSrc
@@ -0,0 +1 @@
+Subproject commit db443164bf02a122f771a2bf4ed72df932779652
View
45 gradle.properties
@@ -0,0 +1,45 @@
+# Copyright 2002-2010 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# NOTE: This is COPY/PASTA from spring-social-facebook project...
+#
+
+
+# ------------------------------------------------------------------------------
+# version to be applied to all projects in this multi-project build. this is
+# the one and only location version changes need to be made.
+# ------------------------------------------------------------------------------
+springSocialDropboxVersion=1.0.2.BUILD-SNAPSHOT
+
+# ------------------------------------------------------------------------------
+# build system user roles
+# role may be either 'developer' or 'buildmaster'
+# ------------------------------------------------------------------------------
+role=developer
+
+# ------------------------------------------------------------------------------
+# for buildmasters: create a $HOME/.gradle/gradle.properties with the following
+# properties. They'll be necessary uploading artifacts to s3, maven repos, and
+# static.springframework.org. By placing them in your home directory, there's
+# no need to change/check in this file. Remember that properties can also be
+# specified at the gradle command line with -P, e.g.: -Prole=buildmaster
+# ------------------------------------------------------------------------------
+# role = buildmaster # overrides default 'role = developer' above
+# s3AccessKey=<springsource s3 access key>
+# s3SecretAccessKey=<springsource s3 secret access key>
+# docsHost=static.springsource.org
+# sshHost=static.springsource.org
+# sshUsername=<your user id>
+# sshPrivateKey=<path to your ssh private key used for logging into sshHost
+# mavenSyncRepoDir=<path to sourceforge cvs checkout for maven central sync>
View
151 gradlew
@@ -0,0 +1,151 @@
+#!/bin/bash
+
+##############################################################################
+## ##
+## Gradle wrapper script for UN*X ##
+## ##
+##############################################################################
+
+# Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
+GRADLE_OPTS="$GRADLE_OPTS -Xmx512m"
+# JAVA_OPTS="$JAVA_OPTS -Xmx512m"
+
+GRADLE_APP_NAME=Gradle
+
+warn ( ) {
+ echo "${PROGNAME}: $*"
+}
+
+die ( ) {
+ warn "$*"
+ exit 1
+}
+
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set JAVA_HOME if it's not already set.
+if [ -z "$JAVA_HOME" ] ; then
+ if $darwin ; then
+ [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home"
+ [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
+ else
+ javaExecutable="`which javac`"
+ [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ export JAVA_HOME="$javaHome"
+ fi
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"`
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
+CLASSPATH=`dirname "$0"`/buildSrc/wrapper/gradle-wrapper.jar
+WRAPPER_PROPERTIES=`dirname "$0"`/buildSrc/wrapper/gradle-wrapper.properties
+# Determine the Java command to use to start the JVM.
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="java"
+ fi
+fi
+if [ ! -x "$JAVACMD" ] ; then
+ die "JAVA_HOME is not defined correctly, can not execute: $JAVACMD"
+fi
+if [ -z "$JAVA_HOME" ] ; then
+ warn "JAVA_HOME environment variable is not set"
+fi
+
+# For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name
+if $darwin; then
+ JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME"
+# we may also want to set -Xdock:image
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+GRADLE_APP_BASE_NAME=`basename "$0"`
+
+"$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
+ -classpath "$CLASSPATH" \
+ -Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \
+ -Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \
+ $STARTER_MAIN_CLASS \
+ "$@"
+
+RETCODE=$?
+
+if [ "$RETCODE" == "1" ] ; then
+ echo "Gradle classes not found -- did you forget to clone --recursive when checking out this repository? See README for more details"
+fi
View
126 gradlew.bat
@@ -0,0 +1,126 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem ##
+@rem Gradle startup script for Windows ##
+@rem ##
+@rem ##########################################################################
+
+@rem
+@rem $Revision: 10602 $ $Date: 2008-01-25 02:49:54 +0100 (ven., 25 janv. 2008) $
+@rem
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
+@rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512m
+@rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512m
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.\
+
+@rem Determine the command interpreter to execute the "CD" later
+set COMMAND_COM="cmd.exe"
+if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe"
+if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com"
+
+@rem Use explicit find.exe to prevent cygwin and others find.exe from being used
+set FIND_EXE="find.exe"
+if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe"
+if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe"
+
+:check_JAVA_HOME
+@rem Make sure we have a valid JAVA_HOME
+if not "%JAVA_HOME%" == "" goto have_JAVA_HOME
+
+echo.
+echo ERROR: Environment variable JAVA_HOME has not been set.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+echo.
+goto end
+
+:have_JAVA_HOME
+@rem Validate JAVA_HOME
+%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul
+if not errorlevel 1 goto init
+
+echo.
+echo ERROR: JAVA_HOME might be set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation if there are problems.
+echo.
+
+:init
+@rem get name of script to launch with full path
+@rem Get command-line arguments, handling Windowz variants
+SET _marker=%JAVA_HOME: =%
+@rem IF NOT "%_marker%" == "%JAVA_HOME%" ECHO JAVA_HOME "%JAVA_HOME%" contains spaces. Please change to a location without spaces if this causes problems.
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%eval[2+2]" == "4" goto 4NT_args
+
+IF "%_marker%" == "%JAVA_HOME%" goto :win9xME_args
+
+set _FIXPATH=
+call :fixpath "%JAVA_HOME%"
+set JAVA_HOME=%_FIXPATH:~1%
+
+goto win9xME_args
+
+:fixpath
+if not %1.==. (
+for /f "tokens=1* delims=;" %%a in (%1) do (
+call :shortfilename "%%a" & call :fixpath "%%b"
+)
+)
+goto :EOF
+:shortfilename
+for %%i in (%1) do set _FIXPATH=%_FIXPATH%;%%~fsi
+goto :EOF
+
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
+set CLASSPATH=%DIRNAME%\buildSrc\wrapper\gradle-wrapper.jar
+set WRAPPER_PROPERTIES=%DIRNAME%\buildSrc\wrapper\gradle-wrapper.properties
+set JAVA_EXE=%JAVA_HOME%\bin\java.exe
+
+set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%"
+
+"%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1
+
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit "%ERRORLEVEL%"
+exit /b "%ERRORLEVEL%"
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
View
21 settings.gradle
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+rootProject.name = 'spring-social-dropbox'
+
+include 'docs'
+include 'spring-social-dropbox'
+include 'spring-social-dropbox-web'
View
30 ...mework/social/dropbox/api/DropboxApi.java → ...mework/social/dropbox/api/DropboxApi.java
@@ -1,15 +1,15 @@
-package org.springframework.social.dropbox.api;
-
-import java.math.BigInteger;
-import java.util.List;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 8:57 AM
- */
-public interface DropboxApi {
- DropboxUserProfile getUserProfile();
-
- List<DropboxItemMetadata> getItemMetadata(String path, boolean list, BigInteger maxFiles);
-}
+package main.java.org.springframework.social.dropbox.api;
+
+import java.math.BigInteger;
+import java.util.List;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 8:57 AM
+ */
+public interface DropboxApi {
+ DropboxUserProfile getUserProfile();
+
+ List<DropboxItemMetadata> getItemMetadata(String path, boolean list, BigInteger maxFiles);
+}
View
18 ...cial/dropbox/api/DropboxItemMetadata.java → ...cial/dropbox/api/DropboxItemMetadata.java
@@ -1,9 +1,9 @@
-package org.springframework.social.dropbox.api;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 9:19 AM
- */
-public class DropboxItemMetadata {
-}
+package main.java.org.springframework.social.dropbox.api;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 9:19 AM
+ */
+public class DropboxItemMetadata {
+}
View
124 ...ocial/dropbox/api/DropboxUserProfile.java → ...ocial/dropbox/api/DropboxUserProfile.java
@@ -1,62 +1,62 @@
-package org.springframework.social.dropbox.api;
-
-import java.math.BigInteger;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 9:15 AM
- */
-public class DropboxUserProfile {
- private String country;
- private final String referralLink;
- private String displayName;
- private final String email;
- private BigInteger uid;
- private BigInteger sharedQuota;
- private BigInteger quota;
- private BigInteger normalQuota;
-
- public DropboxUserProfile(BigInteger uid, String displayName, String email, String country, String referralLink, BigInteger sharedQuota, BigInteger quota, BigInteger normalQuota) {
- this.uid = uid;
- this.displayName = displayName;
- this.email = email;
- this.country = country;
- this.referralLink = referralLink;
- this.sharedQuota = sharedQuota;
- this.quota = quota;
- this.normalQuota = normalQuota;
- }
-
- public String getCountry() {
- return country;
- }
-
- public String getDisplayName() {
- return displayName;
- }
-
- public BigInteger getSharedQuota() {
- return sharedQuota;
- }
-
- public BigInteger getQuota() {
- return quota;
- }
-
- public BigInteger getNormalQuota() {
- return normalQuota;
- }
-
- public BigInteger getUid() {
- return uid;
- }
-
- public String getReferralLink() {
- return referralLink;
- }
-
- public String getEmail() {
- return email;
- }
-}
+package main.java.org.springframework.social.dropbox.api;
+
+import java.math.BigInteger;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 9:15 AM
+ */
+public class DropboxUserProfile {
+ private String country;
+ private final String referralLink;
+ private String displayName;
+ private final String email;
+ private BigInteger uid;
+ private BigInteger sharedQuota;
+ private BigInteger quota;
+ private BigInteger normalQuota;
+
+ public DropboxUserProfile(BigInteger uid, String displayName, String email, String country, String referralLink, BigInteger sharedQuota, BigInteger quota, BigInteger normalQuota) {
+ this.uid = uid;
+ this.displayName = displayName;
+ this.email = email;
+ this.country = country;
+ this.referralLink = referralLink;
+ this.sharedQuota = sharedQuota;
+ this.quota = quota;
+ this.normalQuota = normalQuota;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public BigInteger getSharedQuota() {
+ return sharedQuota;
+ }
+
+ public BigInteger getQuota() {
+ return quota;
+ }
+
+ public BigInteger getNormalQuota() {
+ return normalQuota;
+ }
+
+ public BigInteger getUid() {
+ return uid;
+ }
+
+ public String getReferralLink() {
+ return referralLink;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+}
View
42 ...ocial/dropbox/api/impl/DropboxModule.java → ...ocial/dropbox/api/impl/DropboxModule.java
@@ -1,21 +1,21 @@
-package org.springframework.social.dropbox.api.impl;
-
-import org.codehaus.jackson.Version;
-import org.codehaus.jackson.map.module.SimpleModule;
-import org.springframework.social.dropbox.api.DropboxUserProfile;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 11:06 AM
- */
-public class DropboxModule extends SimpleModule {
- public DropboxModule() {
- super("DropboxModule", new Version(1, 0, 0, null));
- }
-
- @Override
- public void setupModule(SetupContext context) {
- context.setMixInAnnotations(DropboxUserProfile.class, DropboxUserProfileMixin.class);
- }
-}
+package main.java.org.springframework.social.dropbox.api.impl;
+
+import org.codehaus.jackson.Version;
+import org.codehaus.jackson.map.module.SimpleModule;
+import main.java.org.springframework.social.dropbox.api.DropboxUserProfile;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 11:06 AM
+ */
+public class DropboxModule extends SimpleModule {
+ public DropboxModule() {
+ super("DropboxModule", new Version(1, 0, 0, null));
+ }
+
+ @Override
+ public void setupModule(SetupContext context) {
+ context.setMixInAnnotations(DropboxUserProfile.class, DropboxUserProfileMixin.class);
+ }
+}
View
104 ...ial/dropbox/api/impl/DropboxTemplate.java → ...ial/dropbox/api/impl/DropboxTemplate.java
@@ -1,52 +1,52 @@
-package org.springframework.social.dropbox.api.impl;
-
-import org.codehaus.jackson.map.ObjectMapper;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
-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.AbstractOAuth1ApiBinding;
-import org.springframework.web.client.RestTemplate;
-
-import java.math.BigInteger;
-import java.util.List;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 9:22 AM
- */
-public class DropboxTemplate extends AbstractOAuth1ApiBinding implements DropboxApi {
- public DropboxTemplate(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) {
- super(consumerKey, consumerSecret, accessToken, accessTokenSecret);
-
- registerDropboxJsonModule(getRestTemplate());
- }
-
- public DropboxTemplate() {
- super();
- }
-
- public DropboxUserProfile getUserProfile() {
- return getRestTemplate().getForObject("https://api.dropbox.com/0/account/info", DropboxUserProfile.class);
- }
-
- public List<DropboxItemMetadata> getItemMetadata(String path, boolean list, BigInteger maxFiles) {
- return null;
- }
-
- private void registerDropboxJsonModule(RestTemplate restTemplate) {
- List<HttpMessageConverter<?>> converters = restTemplate.getMessageConverters();
-
- for (HttpMessageConverter<?> converter : converters) {
- if (converter instanceof MappingJacksonHttpMessageConverter) {
- MappingJacksonHttpMessageConverter jsonConverter = (MappingJacksonHttpMessageConverter) converter;
-
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.registerModule(new DropboxModule());
- jsonConverter.setObjectMapper(objectMapper);
- }
- }
- }
-}
+package main.java.org.springframework.social.dropbox.api.impl;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
+import main.java.org.springframework.social.dropbox.api.DropboxApi;
+import main.java.org.springframework.social.dropbox.api.DropboxItemMetadata;
+import main.java.org.springframework.social.dropbox.api.DropboxUserProfile;
+import org.springframework.social.oauth1.AbstractOAuth1ApiBinding;
+import org.springframework.web.client.RestTemplate;
+
+import java.math.BigInteger;
+import java.util.List;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 9:22 AM
+ */
+public class DropboxTemplate extends AbstractOAuth1ApiBinding implements DropboxApi {
+ public DropboxTemplate(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret) {
+ super(consumerKey, consumerSecret, accessToken, accessTokenSecret);
+
+ registerDropboxJsonModule(getRestTemplate());
+ }
+
+ public DropboxTemplate() {
+ super();
+ }
+
+ public DropboxUserProfile getUserProfile() {
+ return getRestTemplate().getForObject("https://api.dropbox.com/0/account/info", DropboxUserProfile.class);
+ }
+
+ public List<DropboxItemMetadata> getItemMetadata(String path, boolean list, BigInteger maxFiles) {
+ return null;
+ }
+
+ private void registerDropboxJsonModule(RestTemplate restTemplate) {
+ List<HttpMessageConverter<?>> converters = restTemplate.getMessageConverters();
+
+ for (HttpMessageConverter<?> converter : converters) {
+ if (converter instanceof MappingJacksonHttpMessageConverter) {
+ MappingJacksonHttpMessageConverter jsonConverter = (MappingJacksonHttpMessageConverter) converter;
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.registerModule(new DropboxModule());
+ jsonConverter.setObjectMapper(objectMapper);
+ }
+ }
+ }
+}
View
82 ...box/api/impl/DropboxUserProfileMixin.java → ...box/api/impl/DropboxUserProfileMixin.java
@@ -1,41 +1,41 @@
-package org.springframework.social.dropbox.api.impl;
-
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.DeserializationContext;
-import org.codehaus.jackson.map.JsonDeserializer;
-import org.codehaus.jackson.map.annotate.JsonDeserialize;
-import org.springframework.social.dropbox.api.DropboxUserProfile;
-
-import java.io.IOException;
-import java.math.BigInteger;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 11:07 AM
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonDeserialize(using = DropboxUserProfileMixin.DropboxUserProfileDeserializer.class)
-public class DropboxUserProfileMixin {
- static class DropboxUserProfileDeserializer extends JsonDeserializer<DropboxUserProfile>{
- @Override
- public DropboxUserProfile deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
- JsonNode tree = jp.readValueAsTree();
-
- String referralLink = tree.get("referral_link").getValueAsText();
- String country = tree.get("country").getValueAsText();
- String displayName = tree.get("display_name").getValueAsText();
- String email = tree.get("email").getValueAsText();
- BigInteger uid = tree.get("uid").getBigIntegerValue();
-
- JsonNode quotaNode = tree.get("quota_info");
- BigInteger sharedQuota = quotaNode.get("shared").getBigIntegerValue();
- BigInteger quota = quotaNode.get("quota").getBigIntegerValue();
- BigInteger normalQuota = quotaNode.get("normal").getBigIntegerValue();
-
- return new DropboxUserProfile(uid, displayName, email, country, referralLink, sharedQuota, quota, normalQuota);
- }
- }
-}
+package main.java.org.springframework.social.dropbox.api.impl;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
+import main.java.org.springframework.social.dropbox.api.DropboxUserProfile;
+
+import java.io.IOException;
+import java.math.BigInteger;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 11:07 AM
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonDeserialize(using = DropboxUserProfileMixin.DropboxUserProfileDeserializer.class)
+public class DropboxUserProfileMixin {
+ static class DropboxUserProfileDeserializer extends JsonDeserializer<DropboxUserProfile>{
+ @Override
+ public DropboxUserProfile deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
+ JsonNode tree = jp.readValueAsTree();
+
+ String referralLink = tree.get("referral_link").getValueAsText();
+ String country = tree.get("country").getValueAsText();
+ String displayName = tree.get("display_name").getValueAsText();
+ String email = tree.get("email").getValueAsText();
+ BigInteger uid = tree.get("uid").getBigIntegerValue();
+
+ JsonNode quotaNode = tree.get("quota_info");
+ BigInteger sharedQuota = quotaNode.get("shared").getBigIntegerValue();
+ BigInteger quota = quotaNode.get("quota").getBigIntegerValue();
+ BigInteger normalQuota = quotaNode.get("normal").getBigIntegerValue();
+
+ return new DropboxUserProfile(uid, displayName, email, country, referralLink, sharedQuota, quota, normalQuota);
+ }
+ }
+}
View
90 ...ocial/dropbox/connect/DropboxAdapter.java → ...ocial/dropbox/connect/DropboxAdapter.java
@@ -1,45 +1,45 @@
-package org.springframework.social.dropbox.connect;
-
-import org.springframework.social.connect.ApiAdapter;
-import org.springframework.social.connect.ConnectionValues;
-import org.springframework.social.connect.UserProfile;
-import org.springframework.social.connect.UserProfileBuilder;
-import org.springframework.social.dropbox.api.DropboxApi;
-import org.springframework.social.dropbox.api.DropboxUserProfile;
-import org.springframework.web.client.HttpClientErrorException;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 11:33 AM
- */
-public class DropboxAdapter implements ApiAdapter<DropboxApi> {
- @Override
- public boolean test(DropboxApi dropboxApi) {
- try {
- dropboxApi.getUserProfile();
- return true;
- } catch (HttpClientErrorException e) {
- return false;
- }
- }
-
- @Override
- public void setConnectionValues(DropboxApi dropboxApi, ConnectionValues values) {
- DropboxUserProfile profile = dropboxApi.getUserProfile();
- values.setProviderUserId(profile.getUid().toString());
- values.setDisplayName(profile.getDisplayName());
- values.setProfileUrl(profile.getReferralLink());
- }
-
- @Override
- public UserProfile fetchUserProfile(DropboxApi dropboxApi) {
- DropboxUserProfile profile = dropboxApi.getUserProfile();
- return new UserProfileBuilder().setName(profile.getDisplayName()).setUsername(profile.getEmail()).setEmail(profile.getEmail()).build();
- }
-
- @Override
- public void updateStatus(DropboxApi dropboxApi, String s) {
- // Not Supported
- }
-}
+package main.java.org.springframework.social.dropbox.connect;
+
+import org.springframework.social.connect.ApiAdapter;
+import org.springframework.social.connect.ConnectionValues;
+import org.springframework.social.connect.UserProfile;
+import org.springframework.social.connect.UserProfileBuilder;
+import main.java.org.springframework.social.dropbox.api.DropboxApi;
+import main.java.org.springframework.social.dropbox.api.DropboxUserProfile;
+import org.springframework.web.client.HttpClientErrorException;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 11:33 AM
+ */
+public class DropboxAdapter implements ApiAdapter<DropboxApi> {
+ @Override
+ public boolean test(DropboxApi dropboxApi) {
+ try {
+ dropboxApi.getUserProfile();
+ return true;
+ } catch (HttpClientErrorException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public void setConnectionValues(DropboxApi dropboxApi, ConnectionValues values) {
+ DropboxUserProfile profile = dropboxApi.getUserProfile();
+ values.setProviderUserId(profile.getUid().toString());
+ values.setDisplayName(profile.getDisplayName());
+ values.setProfileUrl(profile.getReferralLink());
+ }
+
+ @Override
+ public UserProfile fetchUserProfile(DropboxApi dropboxApi) {
+ DropboxUserProfile profile = dropboxApi.getUserProfile();
+ return new UserProfileBuilder().setName(profile.getDisplayName()).setUsername(profile.getEmail()).setEmail(profile.getEmail()).build();
+ }
+
+ @Override
+ public void updateStatus(DropboxApi dropboxApi, String s) {
+ // Not Supported
+ }
+}
View
30 ...box/connect/DropboxConnectionFactory.java → ...box/connect/DropboxConnectionFactory.java
@@ -1,15 +1,15 @@
-package org.springframework.social.dropbox.connect;
-
-import org.springframework.social.connect.support.OAuth1ConnectionFactory;
-import org.springframework.social.dropbox.api.DropboxApi;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 11:38 AM
- */
-public class DropboxConnectionFactory extends OAuth1ConnectionFactory<DropboxApi> {
- public DropboxConnectionFactory(String consumerKey, String consumerSecret) {
- super("dropbox", new DropboxServiceProvider(consumerKey, consumerSecret), new DropboxAdapter());
- }
-}
+package main.java.org.springframework.social.dropbox.connect;
+
+import org.springframework.social.connect.support.OAuth1ConnectionFactory;
+import main.java.org.springframework.social.dropbox.api.DropboxApi;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 11:38 AM
+ */
+public class DropboxConnectionFactory extends OAuth1ConnectionFactory<DropboxApi> {
+ public DropboxConnectionFactory(String consumerKey, String consumerSecret) {
+ super("dropbox", new DropboxServiceProvider(consumerKey, consumerSecret), new DropboxAdapter());
+ }
+}
View
56 ...opbox/connect/DropboxServiceProvider.java → ...opbox/connect/DropboxServiceProvider.java
@@ -1,28 +1,28 @@
-package org.springframework.social.dropbox.connect;
-
-import org.springframework.social.dropbox.api.DropboxApi;
-import org.springframework.social.dropbox.api.impl.DropboxTemplate;
-import org.springframework.social.oauth1.AbstractOAuth1ServiceProvider;
-import org.springframework.social.oauth1.OAuth1Template;
-import org.springframework.social.oauth1.OAuth1Version;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 11:29 AM
- */
-public class DropboxServiceProvider extends AbstractOAuth1ServiceProvider<DropboxApi> {
-
- public DropboxServiceProvider(String consumerKey, String consumerSecret) {
- super(consumerKey, consumerSecret, new OAuth1Template(consumerKey, consumerSecret,
- "https://api.dropbox.com/0/oauth/request_token",
- "https://www.dropbox.com/0/oauth/authorize",
- "https://api.dropbox.com/0/oauth/access_token",
- OAuth1Version.CORE_10));
- }
-
- @Override
- public DropboxApi getApi(String accessToken, String secret) {
- return new DropboxTemplate(getConsumerKey(), getConsumerSecret(), accessToken, secret);
- }
-}
+package main.java.org.springframework.social.dropbox.connect;
+
+import main.java.org.springframework.social.dropbox.api.DropboxApi;
+import main.java.org.springframework.social.dropbox.api.impl.DropboxTemplate;
+import org.springframework.social.oauth1.AbstractOAuth1ServiceProvider;
+import org.springframework.social.oauth1.OAuth1Template;
+import org.springframework.social.oauth1.OAuth1Version;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 11:29 AM
+ */
+public class DropboxServiceProvider extends AbstractOAuth1ServiceProvider<DropboxApi> {
+
+ public DropboxServiceProvider(String consumerKey, String consumerSecret) {
+ super(consumerKey, consumerSecret, new OAuth1Template(consumerKey, consumerSecret,
+ "https://api.dropbox.com/0/oauth/request_token",
+ "https://www.dropbox.com/0/oauth/authorize",
+ "https://api.dropbox.com/0/oauth/access_token",
+ OAuth1Version.CORE_10));
+ }
+
+ @Override
+ public DropboxApi getApi(String accessToken, String secret) {
+ return new DropboxTemplate(getConsumerKey(), getConsumerSecret(), accessToken, secret);
+ }
+}
View
65 ...pbox/api/impl/AbstractDropboxApiTest.java → ...pbox/api/impl/AbstractDropboxApiTest.java
@@ -1,32 +1,33 @@
-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");
- }
-}
+package test.java.org.springframework.social.dropbox.api.impl;
+
+import main.java.org.springframework.social.dropbox.api.impl.DropboxTemplate;
+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
74 ...dropbox/api/impl/DropboxTemplateTest.java → ...dropbox/api/impl/DropboxTemplateTest.java
@@ -1,37 +1,37 @@
-package org.springframework.social.dropbox.api.impl;
-
-import org.junit.Test;
-import org.springframework.social.dropbox.api.DropboxUserProfile;
-
-import java.math.BigInteger;
-
-import static junit.framework.Assert.assertEquals;
-import static org.springframework.http.HttpMethod.GET;
-import static org.springframework.social.test.client.RequestMatchers.method;
-import static org.springframework.social.test.client.RequestMatchers.requestTo;
-import static org.springframework.social.test.client.ResponseCreators.withResponse;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 9:41 AM
- */
-public class DropboxTemplateTest extends AbstractDropboxApiTest {
- @Test
- public void getUserProfileValid() throws Exception {
- mockServer
- .expect(requestTo("https://api.dropbox.com/0/account/info"))
- .andExpect(method(GET))
- .andRespond(withResponse(jsonResource("/profileValid"), responseHeaders));
-
- DropboxUserProfile profile = dropbox.getUserProfile();
- 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());
- }
-}
+package test.java.org.springframework.social.dropbox.api.impl;
+
+import org.junit.Test;
+import main.java.org.springframework.social.dropbox.api.DropboxUserProfile;
+
+import java.math.BigInteger;
+
+import static junit.framework.Assert.assertEquals;
+import static org.springframework.http.HttpMethod.GET;
+import static org.springframework.social.test.client.RequestMatchers.method;
+import static org.springframework.social.test.client.RequestMatchers.requestTo;
+import static org.springframework.social.test.client.ResponseCreators.withResponse;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 9:41 AM
+ */
+public class DropboxTemplateTest extends AbstractDropboxApiTest {
+ @Test
+ public void getUserProfileValid() throws Exception {
+ mockServer
+ .expect(requestTo("https://api.dropbox.com/0/account/info"))
+ .andExpect(method(GET))
+ .andRespond(withResponse(jsonResource("/profileValid"), responseHeaders));
+
+ DropboxUserProfile profile = dropbox.getUserProfile();
+ 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
81 ...l/dropbox/connect/DropboxAdapterTest.java → ...l/dropbox/connect/DropboxAdapterTest.java
@@ -1,40 +1,41 @@
-package org.springframework.social.dropbox.connect;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.springframework.social.connect.UserProfile;
-import org.springframework.social.dropbox.api.DropboxApi;
-import org.springframework.social.dropbox.api.DropboxUserProfile;
-
-import java.math.BigInteger;
-
-import static junit.framework.Assert.assertEquals;
-
-/**
- * User: Bryce Fischer
- * Date: 5/17/11
- * Time: 11:40 AM
- */
-public class DropboxAdapterTest {
- private DropboxAdapter adapter = new DropboxAdapter();
- private DropboxApi dropboxApi = Mockito.mock(DropboxApi.class);
-
- @Test
- public void fetchProfile() throws Exception {
- final String country = "USA";
- final String displayName = "DisplayName";
- final BigInteger uid = BigInteger.valueOf(1);
- final BigInteger sharedQuota = BigInteger.valueOf(123);
- final BigInteger quota = new BigInteger("62277025792");
- final BigInteger normalQuota = BigInteger.valueOf(323);
- 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());
- }
-}
+package test.java.org.springframework.social.dropbox.connect;
+
+import main.java.org.springframework.social.dropbox.connect.DropboxAdapter;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.springframework.social.connect.UserProfile;
+import main.java.org.springframework.social.dropbox.api.DropboxApi;
+import main.java.org.springframework.social.dropbox.api.DropboxUserProfile;
+
+import java.math.BigInteger;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * User: Bryce Fischer
+ * Date: 5/17/11
+ * Time: 11:40 AM
+ */
+public class DropboxAdapterTest {
+ private DropboxAdapter adapter = new DropboxAdapter();
+ private DropboxApi dropboxApi = Mockito.mock(DropboxApi.class);
+
+ @Test
+ public void fetchProfile() throws Exception {
+ final String country = "USA";
+ final String displayName = "DisplayName";
+ final BigInteger uid = BigInteger.valueOf(1);
+ final BigInteger sharedQuota = BigInteger.valueOf(123);
+ final BigInteger quota = new BigInteger("62277025792");
+ final BigInteger normalQuota = BigInteger.valueOf(323);
+ 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());
+ }
+}
View
22 src/test/resources/profileValid.json → ...pbox/src/test/resources/profileValid.json
@@ -1,12 +1,12 @@
-{
- "referral_link":"referralLink",
- "display_name":"Some User",
- "uid":10,
- "country":"US",
- "quota_info":
- {
- "shared":44962990383,
- "quota":108179488768,
- "normal":46970996076
- },
+{
+ "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.