Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: SkygearIO/skygear-SDK-Android
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.6.3
Choose a base ref
...
head repository: SkygearIO/skygear-SDK-Android
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jul 18, 2018

  1. Copy the full SHA
    0d2d7c0 View commit details
  2. Update RecordSerializer for new record ID format

    Ben Lei committed Jul 18, 2018
    Copy the full SHA
    4711e61 View commit details
  3. Update delete record API for new record ID format

    Ben Lei committed Jul 18, 2018
    Copy the full SHA
    5b62438 View commit details
  4. Update save record API for new record ID format

    Ben Lei committed Jul 18, 2018
    Copy the full SHA
    f116b87 View commit details
  5. Update example project due to the API updates

    Ben Lei committed Jul 18, 2018
    Copy the full SHA
    55c3db1 View commit details

Commits on Jul 20, 2018

  1. Refactor different serializers

    Ben Lei committed Jul 20, 2018
    Copy the full SHA
    a78ba3d View commit details
  2. Copy the full SHA
    fd44b67 View commit details
  3. Support delete records with record type and IDs

    Ben Lei committed Jul 20, 2018
    Copy the full SHA
    2e0b958 View commit details

Commits on Jul 30, 2018

  1. Remove extra _id field on delete record request

    Ben Lei committed Jul 30, 2018
    Copy the full SHA
    b705621 View commit details

Commits on Jul 31, 2018

  1. Use new record ID representation

    refs #255
    cheungpat committed Jul 31, 2018
    Copy the full SHA
    24e149f View commit details

Commits on Aug 8, 2018

  1. Copy the full SHA
    747fe19 View commit details

Commits on Aug 9, 2018

  1. Copy the full SHA
    d3df525 View commit details
  2. Copy the full SHA
    c9e09a2 View commit details
  3. Copy the full SHA
    f05e0a7 View commit details
  4. Copy the full SHA
    a0892bc View commit details
  5. Copy the full SHA
    fcd8a81 View commit details
  6. Copy the full SHA
    83b40f7 View commit details
  7. Copy the full SHA
    2e5df7d View commit details

Commits on Aug 10, 2018

  1. Support create Asset with stream

    Ben Lei committed Aug 10, 2018
    Copy the full SHA
    5acd390 View commit details
  2. Add reference of request to response handler

    Ben Lei committed Aug 10, 2018
    Copy the full SHA
    7d74011 View commit details
  3. Enable serializing deleted record

    Ben Lei committed Aug 10, 2018
    Copy the full SHA
    3fa63e8 View commit details
  4. Copy the full SHA
    a432d00 View commit details
  5. Copy the full SHA
    299ea98 View commit details
  6. Copy the full SHA
    f1d73e3 View commit details
  7. Copy the full SHA
    228c8e1 View commit details
  8. Update save record APIs on Database

    Ben Lei committed Aug 10, 2018
    Copy the full SHA
    812e525 View commit details
  9. Add fetch record by id APIs

    Ben Lei committed Aug 10, 2018
    Copy the full SHA
    b062d79 View commit details
  10. Update example project for updated APIs

    Ben Lei committed Aug 10, 2018
    Copy the full SHA
    18a70b8 View commit details
  11. Rename MultiRecordXXX class to RecordsXXX

    Ben Lei committed Aug 10, 2018
    Copy the full SHA
    8a69ff9 View commit details
  12. Add back the missing return

    Ben Lei committed Aug 10, 2018
    Copy the full SHA
    e5edfd0 View commit details

Commits on Aug 14, 2018

  1. Copy the full SHA
    4c7ffcb View commit details
  2. Install xml parser

    Steven-Chan committed Aug 14, 2018
    Copy the full SHA
    0b1befa View commit details
  3. Copy the full SHA
    606d681 View commit details
  4. Copy the full SHA
    1951d8f View commit details
  5. Copy the full SHA
    77ad192 View commit details

Commits on Aug 15, 2018

  1. Configure lint to ignore simple-xml problem

    The lint would check the dependencies use java libraries that are not
    included Android.
    
    However, this library internally uses a default implementation if the
    library is not available.
    Steven-Chan committed Aug 15, 2018
    Copy the full SHA
    64443cb View commit details

Commits on Aug 16, 2018

  1. Handle S3 error when uploading asset

    Ben Lei committed Aug 16, 2018
    Copy the full SHA
    14b2f1c View commit details

Commits on Aug 23, 2018

  1. Copy the full SHA
    bf99d29 View commit details

Commits on Sep 27, 2018

  1. Adding SecurePersistentStore class to encrypt current user data and a…

    …ccess token before storing to SharedPreferences.
    carmenlau committed Sep 27, 2018
    Copy the full SHA
    696d09e View commit details
  2. Copy the full SHA
    136bc81 View commit details
  3. Copy the full SHA
    d88b9a0 View commit details
  4. Copy the full SHA
    c17ddfb View commit details
  5. Remove provider and let Chiper to traverse the providers list to find…

    … the most preferred one
    carmenlau committed Sep 27, 2018
    Copy the full SHA
    2822960 View commit details
  6. Update Encryptor class

    - Remove inner class context, access context of `SecurePersistentStore` instead
    - Change EncryptedResult to static class
    carmenlau committed Sep 27, 2018
    Copy the full SHA
    861e60d View commit details
  7. Update AES mode to AES/ECB/PKCS5Padding

    - To ensure it is supported in most of the android devices, `AES/ECB/PKCS5Padding` is supported by api level 1+.
    Refs: https://developer.android.com/reference/javax/crypto/Cipher
    carmenlau committed Sep 27, 2018
    Copy the full SHA
    0ae8f66 View commit details
  8. Copy the full SHA
    f168161 View commit details
  9. Copy the full SHA
    5d35822 View commit details

Commits on Oct 2, 2018

  1. Copy the full SHA
    1734129 View commit details

Commits on Oct 4, 2018

  1. Update Java-WebSocket to v1.3.9

    To fix randomly crash on SendPing
    Related issue: TooTallNate/Java-WebSocket#715
    
    Refs #268.
    carmenlau authored and Steven-Chan committed Oct 4, 2018
    Copy the full SHA
    113ed1e View commit details

Commits on Oct 5, 2018

  1. Update joda-time to v2.10

    carmenlau committed Oct 5, 2018
    Copy the full SHA
    36d9428 View commit details
Showing with 3,886 additions and 1,328 deletions.
  1. +1 −0 build.gradle
  2. +1 −1 scripts/release-commit.sh
  3. +15 −10 skygear/build.gradle
  4. +11 −0 skygear/lint.xml
  5. +20 −18 skygear/src/androidTest/java/io/skygear/skygear/AssetPostRequestUnitTest.java
  6. +7 −1 skygear/src/androidTest/java/io/skygear/skygear/AssetPreparePostRequestUnitTest.java
  7. +26 −8 skygear/src/androidTest/java/io/skygear/skygear/AssetPreparePostResponseHandlerUnitTest.java
  8. +82 −2 skygear/src/androidTest/java/io/skygear/skygear/AssetUnitTest.java
  9. +3 −3 skygear/src/androidTest/java/io/skygear/skygear/AuthResponseHandlerUnitTest.java
  10. +5 −5 skygear/src/androidTest/java/io/skygear/skygear/AuthResponseHandlerWrapperUnitTest.java
  11. +0 −3 skygear/src/androidTest/java/io/skygear/skygear/ConfigurationUnitTest.java
  12. +1 −1 skygear/src/androidTest/java/io/skygear/skygear/FetchUserRoleResponseHandlerUnitTest.java
  13. +1 −1 skygear/src/androidTest/java/io/skygear/skygear/LambdaResponseHandlerUnitTest.java
  14. +1 −1 skygear/src/androidTest/java/io/skygear/skygear/LogoutResponseHandlerUnitTest.java
  15. +1 −1 skygear/src/androidTest/java/io/skygear/skygear/LogoutResponseHandlerWrapperUnitTest.java
  16. +4 −2 skygear/src/androidTest/java/io/skygear/skygear/PersistentStoreUnitTest.java
  17. +61 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordDeleteByIDResponseHandlerUnitTest.java
  18. +80 −20 skygear/src/androidTest/java/io/skygear/skygear/RecordDeleteRequestUnitTest.java
  19. +24 −154 skygear/src/androidTest/java/io/skygear/skygear/RecordDeleteResponseHandlerUnitTest.java
  20. +97 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordFetchRequestUnitTest.java
  21. +158 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordFetchResponseHandlerUnitTest.java
  22. +125 −0 ...ear/src/androidTest/java/io/skygear/skygear/RecordNonAtomicDeleteByIDResponseHandlerUnitTest.java
  23. +133 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordNonAtomicDeleteResponseHandlerUnitTest.java
  24. +205 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordNonAtomicSaveResponseHandlerUnitTest.java
  25. +1 −1 skygear/src/androidTest/java/io/skygear/skygear/RecordQueryResponseHandlerUnitTest.java
  26. +26 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordResultUnitTest.java
  27. +23 −14 skygear/src/androidTest/java/io/skygear/skygear/RecordSaveRequestUnitTest.java
  28. +19 −207 skygear/src/androidTest/java/io/skygear/skygear/RecordSaveResponseHandlerUnitTest.java
  29. +90 −12 skygear/src/androidTest/java/io/skygear/skygear/RecordSerializerUnitTest.java
  30. +69 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordsDeleteByIDResponseHandlerUnitTest.java
  31. +76 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordsDeleteResponseHandlerUnitTest.java
  32. +222 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordsFetchResponseHandlerUnitTest.java
  33. +128 −0 skygear/src/androidTest/java/io/skygear/skygear/RecordsSaveResponseHandlerUnitTest.java
  34. +45 −0 skygear/src/androidTest/java/io/skygear/skygear/ReferenceSerializerUnitTest.java
  35. +1 −1 skygear/src/androidTest/java/io/skygear/skygear/RegisterDeviceResponseHandlerUnitTest.java
  36. +18 −15 skygear/src/androidTest/java/io/skygear/skygear/RequestManagerUnitTest.java
  37. +4 −4 skygear/src/androidTest/java/io/skygear/skygear/RequestUnitTest.java
  38. +115 −0 skygear/src/androidTest/java/io/skygear/skygear/SecurePersistentStoreUnitTest.java
  39. +1 −1 skygear/src/androidTest/java/io/skygear/skygear/SetRoleResponseHandlerUnitTest.java
  40. +1 −1 skygear/src/androidTest/java/io/skygear/skygear/TypedLambdaResponseHandlerUnitTest.java
  41. +1 −1 skygear/src/androidTest/java/io/skygear/skygear/UnregisterDeviceResponseHandlerUnitTest.java
  42. +20 −2 skygear/src/androidTest/java/io/skygear/skygear/ValueSerializerUnitTest.java
  43. +3 −3 skygear/src/androidTest/java/io/skygear/skygear/internal/sso/WebOAuthUnitTest.java
  44. +156 −19 skygear/src/main/java/io/skygear/skygear/Asset.java
  45. +99 −7 skygear/src/main/java/io/skygear/skygear/AssetPostRequest.java
  46. +3 −3 skygear/src/main/java/io/skygear/skygear/AssetPreparePostResponseHandler.java
  47. +14 −14 skygear/src/main/java/io/skygear/skygear/AuthContainer.java
  48. +3 −3 skygear/src/main/java/io/skygear/skygear/AuthResponseHandler.java
  49. +5 −5 skygear/src/main/java/io/skygear/skygear/AuthResponseHandlerWrapper.java
  50. +34 −31 skygear/src/main/java/io/skygear/skygear/Configuration.java
  51. +36 −18 skygear/src/main/java/io/skygear/skygear/Container.java
  52. +166 −51 skygear/src/main/java/io/skygear/skygear/Database.java
  53. +2 −0 skygear/src/main/java/io/skygear/skygear/Error.java
  54. +15 −8 skygear/src/main/java/io/skygear/skygear/ErrorSerializer.java
  55. +3 −5 skygear/src/main/java/io/skygear/skygear/FetchUserRoleResponseHandler.java
  56. +9 −4 skygear/src/main/java/io/skygear/skygear/LambdaRequest.java
  57. +2 −2 skygear/src/main/java/io/skygear/skygear/LambdaResponseHandler.java
  58. +4 −3 skygear/src/main/java/io/skygear/skygear/LogoutResponseHandler.java
  59. +4 −4 skygear/src/main/java/io/skygear/skygear/LogoutResponseHandlerWrapper.java
  60. +5 −5 skygear/src/main/java/io/skygear/skygear/PersistentStore.java
  61. +3 −16 skygear/src/main/java/io/skygear/skygear/PushContainer.java
  62. +4 −0 skygear/src/main/java/io/skygear/skygear/Record.java
  63. +28 −0 skygear/src/main/java/io/skygear/skygear/RecordDeleteByIDResponseHandler.java
  64. +80 −19 skygear/src/main/java/io/skygear/skygear/RecordDeleteRequest.java
  65. +26 −0 skygear/src/main/java/io/skygear/skygear/RecordDeleteResponseBaseHandler.java
  66. +11 −70 skygear/src/main/java/io/skygear/skygear/RecordDeleteResponseHandler.java
  67. +42 −0 skygear/src/main/java/io/skygear/skygear/RecordFetchRequest.java
  68. +68 −0 skygear/src/main/java/io/skygear/skygear/RecordFetchResponseBaseHandler.java
  69. +22 −0 skygear/src/main/java/io/skygear/skygear/RecordFetchResponseHandler.java
  70. +16 −0 skygear/src/main/java/io/skygear/skygear/RecordNonAtomicDeleteByIDResponseHandler.java
  71. +71 −0 skygear/src/main/java/io/skygear/skygear/RecordNonAtomicDeleteResponseBaseHandler.java
  72. +20 −0 skygear/src/main/java/io/skygear/skygear/RecordNonAtomicDeleteResponseHandler.java
  73. +57 −0 skygear/src/main/java/io/skygear/skygear/RecordNonAtomicSaveResponseHandler.java
  74. +35 −4 skygear/src/main/java/io/skygear/skygear/RecordQueryRequest.java
  75. +6 −5 skygear/src/main/java/io/skygear/skygear/RecordQueryResponseHandler.java
  76. +24 −0 skygear/src/main/java/io/skygear/skygear/RecordResult.java
  77. +27 −15 skygear/src/main/java/io/skygear/skygear/RecordSaveRequest.java
  78. +50 −0 skygear/src/main/java/io/skygear/skygear/RecordSaveResponseBaseHandler.java
  79. +9 −98 skygear/src/main/java/io/skygear/skygear/RecordSaveResponseHandler.java
  80. +115 −41 skygear/src/main/java/io/skygear/skygear/RecordSerializer.java
  81. +29 −0 skygear/src/main/java/io/skygear/skygear/RecordsDeleteByIDResponseHandler.java
  82. +31 −0 skygear/src/main/java/io/skygear/skygear/RecordsDeleteResponseHandler.java
  83. +18 −0 skygear/src/main/java/io/skygear/skygear/RecordsFetchResponseHandler.java
  84. +14 −0 skygear/src/main/java/io/skygear/skygear/RecordsSaveResponseHandler.java
  85. +65 −14 skygear/src/main/java/io/skygear/skygear/ReferenceSerializer.java
  86. +3 −3 skygear/src/main/java/io/skygear/skygear/RegisterDeviceResponseHandler.java
  87. +27 −7 skygear/src/main/java/io/skygear/skygear/Request.java
  88. +24 −7 skygear/src/main/java/io/skygear/skygear/RequestManager.java
  89. +14 −28 skygear/src/main/java/io/skygear/skygear/ResponseHandler.java
  90. +4 −2 skygear/src/main/java/io/skygear/skygear/{ResultCallback.java → ResultHandling.java}
  91. +292 −0 skygear/src/main/java/io/skygear/skygear/SecurePersistentStore.java
  92. +3 −3 skygear/src/main/java/io/skygear/skygear/SetDisableUserResponseHandler.java
  93. +3 −3 skygear/src/main/java/io/skygear/skygear/SetRoleResponseHandler.java
  94. +3 −3 skygear/src/main/java/io/skygear/skygear/SetUserRoleResponseHandler.java
  95. +9 −8 skygear/src/main/java/io/skygear/skygear/SkygearApplication.java
  96. +4 −9 skygear/src/main/java/io/skygear/skygear/TypedLambdaResponseHandler.java
  97. +3 −3 skygear/src/main/java/io/skygear/skygear/UnregisterDeviceResponseHandler.java
  98. +39 −17 ...r/src/main/java/io/skygear/skygear/{gcm/ListenerService.java → fcm/FirebaseMessagingService.java}
  99. +0 −39 skygear/src/main/java/io/skygear/skygear/gcm/InstanceIDListenerService.java
  100. +0 −75 skygear/src/main/java/io/skygear/skygear/gcm/RegistrationIntentService.java
  101. +5 −5 skygear/src/main/java/io/skygear/skygear/internal/sso/OAuthManager.java
  102. +6 −1 skygear_example/build.gradle
  103. +4 −32 skygear_example/src/main/AndroidManifest.xml
  104. +0 −6 skygear_example/src/main/java/io/skygear/skygear_example/MainActivity.java
  105. +4 −4 skygear_example/src/main/java/io/skygear/skygear_example/OAuthActivity.java
  106. +60 −59 skygear_example/src/main/java/io/skygear/skygear_example/RecordCreateActivity.java
  107. +4 −15 skygear_example/src/main/java/io/skygear/skygear_example/RecordQueryActivity.java
  108. +8 −20 skygear_example/src/main/java/io/skygear/skygear_example/ServerConfigurationActivity.java
  109. +5 −5 skygear_example/src/main/java/io/skygear/skygear_example/ServerConfigurationPreference.java
  110. +5 −17 skygear_example/src/main/res/layout/activity_server_configuration.xml
  111. +1 −0 skygear_example/src/main/res/values/strings.xml
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.google.gms:google-services:4.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
2 changes: 1 addition & 1 deletion scripts/release-commit.sh
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ else
fi

github-release release -u skygeario -r skygear-SDK-Android --draft --tag $SKYGEAR_VERSION --name "$SKYGEAR_VERSION" --description "`cat new-release`"
cat CHANGELOG.md >> new-release && mv new-release CHANGELOG.md
echo "" >> new-release && cat CHANGELOG.md >> new-release && mv new-release CHANGELOG.md
make update-version VERSION=$SKYGEAR_VERSION
git add CHANGELOG.md skygear/build.gradle
git commit -m "Update CHANGELOG for $SKYGEAR_VERSION"
25 changes: 15 additions & 10 deletions skygear/build.gradle
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ android {
useLibrary 'org.apache.http.legacy'

defaultConfig {
minSdkVersion 16
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName skygearVersion
@@ -61,25 +61,30 @@ android {
}

dependencies {

compile 'com.google.android.gms:play-services-base:11.4.2'
compile 'com.google.android.gms:play-services-gcm:11.4.2'
compile 'com.google.firebase:firebase-messaging:17.3.4'
compile 'com.android.support:appcompat-v7:26.1.0'

compile 'com.android.volley:volley:1.0.0'

compile 'com.android.volley:volley:1.1.0'
compile ('io.skygear:volleyEx:0.0.1') {
exclude group: 'com.android.support'
}
compile 'joda-time:joda-time:2.9.4'
compile 'org.java-websocket:Java-WebSocket:1.3.8'
compile 'joda-time:joda-time:2.10'
compile 'org.java-websocket:Java-WebSocket:1.3.9'

compile('org.simpleframework:simple-xml:2.7.+'){
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}

compile fileTree(dir: 'libs', include: ['*.jar'])

testCompile 'junit:junit:4.12'

androidTestCompile 'com.android.support:support-annotations:26.1.0'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test:rules:1.0.1'
androidTestCompile 'com.android.support:support-annotations:28.0.0'
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'
}

task generateSourcesJar(type: Jar) {
11 changes: 11 additions & 0 deletions skygear/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="InvalidPackage">
<!--
http://sourceforge.net/p/simple/mailman/simple-support/thread/339270128E13BE47A6B10EED7367E7852BC2A912@MERCMBX18D.na.SAS.com/
Q: "The new Android developer tools (21.1) are reporting many cases of invalid package references in the SimpleXML library jar"
A: "Just ignore this, it should be a warning only, this references StAX which is not available on Android. SimpleXML will default to XmlPull"
-->
<ignore path="**/simple-xml-2.7.1.jar"/>
</issue>
</lint>
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.InvalidParameterException;
import java.util.HashMap;
import java.util.Map;
@@ -42,12 +44,12 @@ public class AssetPostRequestUnitTest {

@Before
public void setUp() throws Exception {
asset = new Asset(
"hello.txt",
"http://skygear.dev/asset/3f72d553-3aca-4668-8c9f-a454cf7b28e8-hello.txt",
"text/plain"
);
asset.data = "hello world".getBytes();
byte[] data = "hello world".getBytes();
asset = new Asset.Builder("hello.txt")
.setMimeType("text/plain")
.setData(data)
.build();
asset.url = "http://skygear.dev/asset/3f72d553-3aca-4668-8c9f-a454cf7b28e8-hello.txt";
}

@After
@@ -131,12 +133,12 @@ public void testAssetPostRequestValidationNotAllowAssetNoData() throws Exception

@Test(expected = InvalidParameterException.class)
public void testAssetPostRequestValidationNotAllowNonTypedAsset() throws Exception {
Asset assetWithoutType = new Asset(
"hello.txt",
"http://skygear.dev/asset/3f72d553-3aca-4668-8c9f-a454cf7b28e8-hello.txt",
""
);
assetWithoutType.data = "hello world".getBytes();
byte[] data = "hello world".getBytes();
Asset assetWithoutType = new Asset.Builder("hello.txt")
.setMimeType("")
.setData(data)
.build();
assetWithoutType.url = "http://skygear.dev/asset/3f72d553-3aca-4668-8c9f-a454cf7b28e8-hello.txt";

AssetPostRequest postRequest = new AssetPostRequest(
assetWithoutType,
@@ -157,7 +159,7 @@ public void testAssetPostRequestHandleSuccessResponse() throws Exception {
);

final boolean[] checkpoints = new boolean[]{ false };
postRequest.responseHandler = new AssetPostRequest.ResponseHandler() {
postRequest.setResponseHandler(new AssetPostRequest.ResponseHandler() {
@Override
public void onPostSuccess(Asset asset, String response) {
assertEquals(response, "Upload success");
@@ -166,7 +168,7 @@ public void onPostSuccess(Asset asset, String response) {
assertEquals(assetToUpload.getUrl(), asset.getUrl());
assertEquals(assetToUpload.getMimeType(), asset.getMimeType());
assertEquals(assetToUpload.getSize(), asset.getSize());
assertEquals(assetToUpload.data, asset.data);
assertEquals(assetToUpload.inputStream, asset.inputStream);
assertFalse(asset.isPendingUpload());

checkpoints[0] = true;
@@ -176,7 +178,7 @@ public void onPostSuccess(Asset asset, String response) {
public void onPostFail(Asset asset, Error error) {
fail("Should not get fail callback");
}
};
});

postRequest.onResponse("Upload success");
assertTrue(checkpoints[0]);
@@ -192,7 +194,7 @@ public void testAssetPostRequestHandleErrorResponse() throws Exception {
);

final boolean[] checkpoints = new boolean[]{ false };
postRequest.responseHandler = new AssetPostRequest.ResponseHandler() {
postRequest.setResponseHandler(new AssetPostRequest.ResponseHandler() {
@Override
public void onPostSuccess(Asset asset, String response) {
fail("Should not get success callback");
@@ -204,13 +206,13 @@ public void onPostFail(Asset asset, Error error) {
assertEquals(assetToUpload.getUrl(), asset.getUrl());
assertEquals(assetToUpload.getMimeType(), asset.getMimeType());
assertEquals(assetToUpload.getSize(), asset.getSize());
assertEquals(assetToUpload.data, asset.data);
assertEquals(assetToUpload.inputStream, asset.inputStream);

assertEquals("Test Error", error.getDetailMessage());

checkpoints[0] = true;
}
};
});

postRequest.onErrorResponse(new VolleyError("Test Error"));
assertTrue(checkpoints[0]);
Original file line number Diff line number Diff line change
@@ -30,7 +30,10 @@
public class AssetPreparePostRequestUnitTest {
@Test
public void testAssetPreparePostRequestNormalFlow() throws Exception {
Asset asset = new Asset("hello.txt", "text/plain", "Hello World".getBytes());
Asset asset = new Asset.Builder("hello.txt")
.setMimeType("text/plain")
.setData("Hello World".getBytes())
.build();
AssetPreparePostRequest request = new AssetPreparePostRequest(asset);

assertEquals("asset:put", request.action);
@@ -41,6 +44,7 @@ public void testAssetPreparePostRequestNormalFlow() throws Exception {

@Test(expected = InvalidParameterException.class)
public void testAssetPreparePostRequestNotAllowNoFilename() throws Exception {
// Use deprecated constructor to test request.validate
Asset asset = new Asset(null, "text/plain", "Hello World".getBytes());
AssetPreparePostRequest request = new AssetPreparePostRequest(asset);

@@ -49,6 +53,7 @@ public void testAssetPreparePostRequestNotAllowNoFilename() throws Exception {

@Test(expected = InvalidParameterException.class)
public void testAssetPreparePostRequestNotAllowNoMimeType() throws Exception {
// Use deprecated constructor to test request.validate
Asset asset = new Asset("hello.txt", null, "Hello World".getBytes());
AssetPreparePostRequest request = new AssetPreparePostRequest(asset);

@@ -57,6 +62,7 @@ public void testAssetPreparePostRequestNotAllowNoMimeType() throws Exception {

@Test(expected = InvalidParameterException.class)
public void testAssetPreparePostRequestNotAllowNoData() throws Exception {
// Use deprecated constructor to test request.validate
Asset asset = new Asset("hello.txt", "text/plain", new byte[]{});
AssetPreparePostRequest request = new AssetPreparePostRequest(asset);

Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.util.Map;

import static junit.framework.Assert.assertEquals;
@@ -37,11 +38,10 @@ public class AssetPreparePostResponseHandlerUnitTest {

@Before
public void setUp() throws Exception {
asset = new Asset(
"hello.txt",
"text/plain",
"hello world".getBytes()
);
asset = new Asset.Builder("hello.txt")
.setMimeType("text/plain")
.setData("hello world".getBytes())
.build();
}

@After
@@ -73,8 +73,17 @@ public void testAssetPreparePostResponseHandlerSuccessFlow() throws Exception {
@Override
public void onPreparePostSuccess(AssetPostRequest postRequest) {
Asset asset = postRequest.getAsset();
byte[] data = null;
try {
data = new byte[asset.inputStream.available()];
asset.inputStream.read(data);
} catch (IOException e) {
e.printStackTrace();
assertTrue(false);
}

assertEquals("598bfc9a-ba98-45a5-b194-22ceea2b4954-hello.txt", asset.getName());
assertEquals("hello world", new String(asset.data));
assertEquals("hello world", new String(data));
assertEquals(11, asset.getSize());
assertEquals("text/plain", asset.getMimeType());
assertEquals(
@@ -125,8 +134,17 @@ public void testAssetPreparePostResponseHandlerSuccessWithNoExtraPostFieldsFlow(
@Override
public void onPreparePostSuccess(AssetPostRequest postRequest) {
Asset asset = postRequest.getAsset();
byte[] data = null;
try {
data = new byte[asset.inputStream.available()];
asset.inputStream.read(data);
} catch (IOException e) {
e.printStackTrace();
assertTrue(false);
}

assertEquals("598bfc9a-ba98-45a5-b194-22ceea2b4954-hello.txt", asset.getName());
assertEquals("hello world", new String(asset.data));
assertEquals("hello world", new String(data));
assertEquals(11, asset.getSize());
assertEquals("text/plain", asset.getMimeType());
assertEquals(
@@ -170,7 +188,7 @@ public void onPreparePostFail(Error error) {
checkpoints[0] = true;
}
};
handler.onFail(new Error("Test Error"));
handler.onFailure(new Error("Test Error"));
assertTrue(checkpoints[0]);
}
}
84 changes: 82 additions & 2 deletions skygear/src/androidTest/java/io/skygear/skygear/AssetUnitTest.java
Original file line number Diff line number Diff line change
@@ -17,11 +17,20 @@

package io.skygear.skygear;

import android.net.Uri;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
@@ -33,11 +42,17 @@ public class AssetUnitTest {
public void testAssetCreationFromData() throws Exception {
byte[] data = "Hello World".getBytes();

Asset asset = new Asset("hello.txt", "text/plain", data);
Asset asset = new Asset.Builder("hello.txt")
.setMimeType("text/plain")
.setData(data)
.build();

String result = new BufferedReader(new InputStreamReader(asset.inputStream)).readLine();

assertEquals("hello.txt", asset.getName());
assertEquals("text/plain", asset.getMimeType());
assertEquals(11, asset.getSize());
assertEquals("Hello World", result);
assertTrue(asset.isPendingUpload());
assertNull(asset.getUrl());
}
@@ -59,4 +74,69 @@ public void testAssetCreationFromUrl() throws Exception {
asset.getUrl()
);
}
}

@Test
public void testAssetCreationFromInputStream() throws Exception {
String string = "Hello World";
InputStream inputStream = new ByteArrayInputStream(string.getBytes());

Asset asset = new Asset.Builder("hello.txt")
.setMimeType("text/plain")
.setSize(11L)
.setInputStream(inputStream)
.build();

String result = new BufferedReader(new InputStreamReader(asset.inputStream)).readLine();

assertEquals("hello.txt", asset.getName());
assertEquals("text/plain", asset.getMimeType());
assertEquals(11, asset.getSize());
assertEquals("Hello World", result);
assertTrue(asset.isPendingUpload());
assertNull(asset.getUrl());
}

@Test(expected = IllegalStateException.class)
public void testAssetBuilderWithoutSettingAnyDataSource() throws Exception {
new Asset.Builder("hello.txt").build();
}

@Test(expected = IllegalStateException.class)
public void testAssetBuilderWithDataButMissingName() throws Exception {
new Asset.Builder(null)
.setMimeType("text/plain")
.setData("Hello World".getBytes())
.build();
}

@Test(expected = IllegalStateException.class)
public void testAssetBuilderWithDataButMissingMimeType() throws Exception {
new Asset.Builder("hello.txt")
.setMimeType(null)
.setData("Hello World".getBytes())
.build();
}

@Test(expected = IllegalStateException.class)
public void testAssetBuilderWithUriButMissingContext() throws Exception {
new Asset.Builder("hello.txt")
.setUri(Uri.parse("content://abc.txt"))
.build();
}

@Test(expected = IllegalStateException.class)
public void testAssetBuilderWithInputStreamButMissingSize() throws Exception {
new Asset.Builder("hello.txt")
.setInputStream(new ByteArrayInputStream(new byte[]{}))
.setMimeType("text/plain")
.build();
}

@Test(expected = IllegalStateException.class)
public void testAssetBuilderWithInputStreamButMissingMimeType() throws Exception {
new Asset.Builder("hello.txt")
.setInputStream(new ByteArrayInputStream(new byte[]{}))
.setSize(0L)
.build();
}
}
Loading