-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from loilo-inc/withOkhttp
With okhttp
- Loading branch information
Showing
141 changed files
with
2,932 additions
and
391 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 9 | ||
targetSdkVersion 23 | ||
versionCode Integer.parseInt(VERSION_CODE) | ||
versionName VERSION_NAME | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
lintOptions { | ||
disable 'InvalidPackage' | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.android.support:support-v4:23.3.0' | ||
compile 'com.squareup.okhttp3:okhttp:3.2.0' | ||
compile 'com.google.code.gson:gson:2.6.2' | ||
compile project(':promise') | ||
androidTestCompile 'com.android.support.test:runner:0.5' | ||
androidTestCompile 'com.android.support.test:rules:0.5' | ||
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' | ||
} | ||
|
||
apply from: rootProject.file('gradle/gradle-mvn-push.gradle') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
POM_NAME=loilo-promise-http | ||
POM_ARTIFACT_ID=promise-http | ||
POM_PACKAGING=aar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/pepeotoito/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
29 changes: 29 additions & 0 deletions
29
promise-http/src/androidTest/java/tv/loilo/promise/http/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2015-2016 LoiLo inc. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package tv.loilo.promise.http; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
140 changes: 140 additions & 0 deletions
140
promise-http/src/androidTest/java/tv/loilo/promise/http/HttpContentDispositionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/* | ||
* Copyright (c) 2015-2016 LoiLo inc. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package tv.loilo.promise.http; | ||
|
||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.CoreMatchers.notNullValue; | ||
import static org.hamcrest.CoreMatchers.nullValue; | ||
import static org.junit.Assert.*; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class HttpContentDispositionTest { | ||
|
||
//see http://greenbytes.de/tech/tc2231/#attwithfn2231utf8 | ||
|
||
//@DataPoints | ||
public static Fixture[] FIXTURES = { | ||
new Fixture(true, "", null), | ||
new Fixture(true, "inline", new Expected("inline", null, null, null)), | ||
new Fixture(true, "inline; filename=\"foo.html\"", new Expected("inline", "foo.html", null, null)), | ||
new Fixture(true, "inline; filename=\"Not an attachment!\"", new Expected("inline", "Not an attachment!", null, null)), | ||
new Fixture(true, "inline; filename=\"foo.pdf\"", new Expected("inline", "foo.pdf", null, null)), | ||
new Fixture(true, "attachment", new Expected("attachment", null, null, null)), | ||
new Fixture(true, "ATTACHMENT", new Expected("attachment", null, null, null)), | ||
new Fixture(true, "attachment; filename=\"foo.html\"", new Expected("attachment", "foo.html", null, null)), | ||
new Fixture(true, "attachment; filename=\"0000000000111111111122222\"", new Expected("attachment", "0000000000111111111122222", null, null)), | ||
new Fixture(true, "attachment; filename=\"00000000001111111111222222222233333\"", new Expected("attachment", "00000000001111111111222222222233333", null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename=\"f\\oo.html\"", new Expected("attachment", "f\\oo.html", null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename=\"\\\"quoting\\\" tested.html\"", new Expected("attachment", "\"quoting\" tested.html", null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename=\"Here's a semicolon;.html\"", new Expected("attachment", "Here's a semicolon;.html", null, null)), | ||
new Fixture(true, "attachment; foo=\"bar\"; filename=\"foo.html\"", new Expected("attachment", "foo.html", null, null)), | ||
new Fixture(true, "attachment; foo=\"\\\"\\\\\";filename=\"foo.html\"", new Expected("attachment", "foo.html", null, null)), | ||
new Fixture(true, "attachment; FILENAME=\"foo.html\"", new Expected("attachment", "foo.html", null, null)), | ||
new Fixture(true, "attachment; filename=foo.html", new Expected("attachment", "foo.html", null, null)), | ||
new Fixture(true, "attachment; filename='foo.bar'", new Expected("attachment", "foo.bar", null, null)), | ||
new Fixture(true, "attachment; filename=\"foo-ä.html\"", new Expected("attachment", "foo-ä.html", null, null)), | ||
new Fixture(true, "attachment; filename=\"foo-ä.html\"", new Expected("attachment", "foo-ä.html", null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename=\"foo-%41.html\"", new Expected("attachment", "foo-%41.html", null, null)), | ||
new Fixture(true, "attachment; filename=\"50%.html\"", new Expected("attachment", "50%.html", null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename=\"foo-%\\41.html\"", new Expected("attachment", "foo-%41.html", null, null)), | ||
new Fixture(true, "attachment; name=\"foo-%41.html\"", new Expected("attachment", null, null, "foo-%41.html")), | ||
new Fixture(/* 失敗していい */false, "attachment; filename=\"ä-%41.html\"", new Expected("attachment", "ä-%41.html", null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename=\"foo-%c3%a4-%e2%82%ac.html\"", new Expected("attachment", "foo-%c3%a4-%e2%82%ac.html", null, null)), | ||
new Fixture(true, "attachment; filename =\"foo.html\"", new Expected("attachment", "foo.html", null, null)), | ||
new Fixture(true, "attachment; xfilename=foo.html", new Expected("attachment", "foo.html", null, null)), | ||
new Fixture(true, "attachment; filename=\"/foo.html\"", new Expected("attachment", "/foo.html", null, null)), | ||
new Fixture(true, "attachment; filename=\"\\\\foo.html\"", new Expected("attachment", "\\foo.html", null, null)), | ||
new Fixture(true, "attachment; creation-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"", new Expected("attachment", null, null, null)), | ||
new Fixture(true, "attachment; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"", new Expected("attachment", null, null, null)), | ||
new Fixture(/* 失敗していい */true, "foobar", new Expected("foobar", null, null, null)), | ||
new Fixture(true, "attachment; example=\"filename=example.txt\"", new Expected("attachment", null, null, null)), | ||
new Fixture(true, "attachment; filename*=iso-8859-1''foo-%E4.html", new Expected("attachment", null, "foo-ä.html", null)), | ||
new Fixture(true, "attachment; filename*=UTF-8''foo-%c3%a4-%e2%82%ac.html", new Expected("attachment", null, "foo-ä-€.html", null)), | ||
new Fixture(true, "attachment; filename*=''foo-%c3%a4-%e2%82%ac.html", new Expected("attachment", null, "foo-%c3%a4-%e2%82%ac.html", null)), | ||
new Fixture(true, "attachment; filename*=UTF-8''foo-a%cc%88.html", new Expected("attachment", null, "foo-ä.html", null)), | ||
new Fixture(true, "attachment; filename*= UTF-8''foo-%c3%a4.html", new Expected("attachment", null, "foo-ä.html", null)), | ||
new Fixture(true, "attachment; filename* =UTF-8''foo-%c3%a4.html", new Expected("attachment", null, "foo-ä.html", null)), | ||
new Fixture(true, "attachment; filename*=UTF-8''A-%2541.html", new Expected("attachment", null, "A-%41.html", null)), | ||
new Fixture(true, "attachment; filename*=UTF-8''%5cfoo.html", new Expected("attachment", null, "\\foo.html", null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename*0=\"foo.\"; filename*1=\"html\"", new Expected("attachment", null, null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename*0=\"foo\"; filename*1=\"\\b\\a\\r.html\"", new Expected("attachment", null, null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename*0*=UTF-8''foo-%c3%a4; filename*1=\".html\"", new Expected("attachment", null, null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename*0=\"foo\"; filename*01=\"bar\"", new Expected("attachment", null, null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename*0=\"foo\"; filename*2=\"bar\"", new Expected("attachment", null, null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename*1=\"foo.\"; filename*2=\"html\"", new Expected("attachment", null, null, null)), | ||
new Fixture(/* 失敗していい */false, "attachment; filename*1=\"bar\"; filename*0=\"foo\"", new Expected("attachment", null, null, null)), | ||
new Fixture(true, "attachment; filename*=UTF-8''foo-%c3%a4.html; filename=\"foo-ae.html\"", new Expected("attachment", "foo-ae.html", "foo-ä.html", null)), | ||
new Fixture(true, "attachment; filename=\"foo-ae.html\"; filename*=UTF-8''foo-%c3%a4.html", new Expected("attachment", "foo-ae.html", "foo-ä.html", null)), | ||
new Fixture(true, "attachment; filename*0*=ISO-8859-15''euro-sign%3d%a4; filename*=ISO-8859-1''currency-sign%3d%a4", new Expected("attachment", null, "currency-sign=¤", null)), | ||
new Fixture(true, "attachment; foobar=x; filename=\"foo.html\"", new Expected("attachment", "foo.html", null, null)), | ||
new Fixture(true, "attachment; filename=\"=?ISO-8859-1?Q?foo-=E4.html?=\"", new Expected("attachment", "=?ISO-8859-1?Q?foo-=E4.html?=", null, null)) | ||
}; | ||
|
||
@Test | ||
public void testTryParse() throws Exception { | ||
for(final Fixture fixture : FIXTURES){ | ||
testFixture(fixture); | ||
} | ||
} | ||
|
||
public void testFixture(final Fixture fixture) throws Exception { | ||
if (!fixture.mEnable) { | ||
return; | ||
} | ||
final HttpContentDisposition result = HttpContentDisposition.tryParse(fixture.mInput); | ||
if (fixture.mExpected == null) { | ||
assertThat(result, nullValue()); | ||
} else { | ||
assertThat(result, notNullValue()); | ||
assertThat(result.getDispositionType(), equalTo(fixture.mExpected.mDispositionType)); | ||
assertThat(result.getFileName(), equalTo(fixture.mExpected.mFileName)); | ||
assertThat(result.getFileNameStar(), equalTo(fixture.mExpected.mFileNameStar)); | ||
assertThat(result.getName(), equalTo(fixture.mExpected.mName)); | ||
} | ||
} | ||
|
||
public static class Expected { | ||
private final String mDispositionType; | ||
private final String mFileName; | ||
private final String mFileNameStar; | ||
private final String mName; | ||
|
||
public Expected(final String dispositionType, final String fileName, final String fileNameStar, final String name) { | ||
mDispositionType = dispositionType; | ||
mFileName = fileName; | ||
mFileNameStar = fileNameStar; | ||
mName = name; | ||
} | ||
} | ||
|
||
public static class Fixture { | ||
private final boolean mEnable; | ||
private final String mInput; | ||
private final Expected mExpected; | ||
|
||
public Fixture(final boolean enable, final String input, final Expected expected) { | ||
mEnable = enable; | ||
mInput = input; | ||
mExpected = expected; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="tv.loilo.promise.http"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
> | ||
|
||
</application> | ||
|
||
</manifest> |
Oops, something went wrong.