From 1a590063e3039ccd850c761d5484cb4f7ebfdbf9 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Sun, 8 Nov 2015 17:25:06 +0700 Subject: [PATCH 01/16] Clean 'em up --- fuel/build.gradle | 17 +- .../main/kotlin/fuel/core/Deserializable.kt | 4 +- .../main/kotlin/fuel/util/DefaultExecutor.kt | 2 + fuel/src/test/kotlin/fuel/BaseTestCase.kt | 2 - .../kotlin/fuel/RequestAuthenticationTest.kt | 5 - .../test/kotlin/fuel/RequestDownloadTest.kt | 10 +- .../test/kotlin/fuel/RequestHandlerTest.kt | 253 +++++++++--------- .../src/test/kotlin/fuel/RequestHeaderTest.kt | 5 - .../src/test/kotlin/fuel/RequestObjectTest.kt | 10 +- ...questPathStringConvertibleExtensionTest.kt | 10 +- .../kotlin/fuel/RequestSharedInstanceTest.kt | 6 - .../kotlin/fuel/RequestStringExtensionTest.kt | 11 +- fuel/src/test/kotlin/fuel/RequestTest.kt | 10 +- .../src/test/kotlin/fuel/RequestUploadTest.kt | 10 +- .../test/kotlin/fuel/RequestValidationTest.kt | 5 - 15 files changed, 142 insertions(+), 218 deletions(-) diff --git a/fuel/build.gradle b/fuel/build.gradle index 452ed6c26..36ba53ecc 100644 --- a/fuel/build.gradle +++ b/fuel/build.gradle @@ -1,5 +1,11 @@ + apply plugin: 'kotlin' +sourceSets { + main.java.srcDirs += 'src/main/kotlin' + test.java.srcDirs += 'src/test/kotlin' +} + repositories { jcenter() } @@ -8,17 +14,15 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" testCompile "junit:junit:$junit_version" - testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - testCompile "org.robolectric:robolectric:$robolectric_version" - testCompile "com.google.android:android:4.1.1.4" } buildscript { ext { //dependencies version kotlin_version = '1.0.0-beta-1038' + + //test dependencies version junit_version = '4.12' - robolectric_version = '3.0' } repositories { @@ -30,10 +34,5 @@ buildscript { } } -sourceSets { - main.java.srcDirs += 'src/main/kotlin' - test.java.srcDirs += 'src/test/kotlin' -} - //apply from: '../gradle/install.gradle' //apply from: '../gradle/bintray.gradle' diff --git a/fuel/src/main/kotlin/fuel/core/Deserializable.kt b/fuel/src/main/kotlin/fuel/core/Deserializable.kt index 4ecf7b233..8030fe4e3 100644 --- a/fuel/src/main/kotlin/fuel/core/Deserializable.kt +++ b/fuel/src/main/kotlin/fuel/core/Deserializable.kt @@ -36,7 +36,7 @@ public interface ResponseDeserializable : Deserializable { } -fun > Request.response(deserializable: U, handler: (Request, Response, Either) -> Unit) { +public fun > Request.response(deserializable: U, handler: (Request, Response, Either) -> Unit) { response(deserializable, { request, response, value -> handler(this@response, response, Either.Right(value)) }, { request, response, error -> @@ -44,7 +44,7 @@ fun > Request.response(deserializable: U, handler: }) } -fun > Request.response(deserializable: U, handler: Handler) { +public fun > Request.response(deserializable: U, handler: Handler) { response(deserializable, { request, response, value -> handler.success(request, response, value) }, { request, response, error -> diff --git a/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt b/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt index 980232bf5..915045f37 100644 --- a/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt +++ b/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt @@ -3,7 +3,9 @@ package fuel.util import java.util.concurrent.Executor class DefaultExecutor : Executor { + override fun execute(command: Runnable) { command.run() } + } \ No newline at end of file diff --git a/fuel/src/test/kotlin/fuel/BaseTestCase.kt b/fuel/src/test/kotlin/fuel/BaseTestCase.kt index 14ea78201..2cc5d9117 100644 --- a/fuel/src/test/kotlin/fuel/BaseTestCase.kt +++ b/fuel/src/test/kotlin/fuel/BaseTestCase.kt @@ -1,7 +1,5 @@ package fuel -import org.junit.runner.RunWith -import org.junit.runners.Suite import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit import kotlin.properties.Delegates diff --git a/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt b/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt index 233430402..2091b0639 100644 --- a/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt @@ -27,11 +27,6 @@ class RequestAuthenticationTest : BaseTestCase() { val manager: Manager by lazy { Manager().apply { basePath = "http://httpbin.org" - callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } } diff --git a/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt b/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt index 0a806a2f6..6544d3b68 100644 --- a/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt @@ -1,9 +1,6 @@ package fuel -import fuel.core.FuelError -import fuel.core.Manager -import fuel.core.Request -import fuel.core.Response +import fuel.core.* import org.junit.Before import org.junit.Test import java.io.File @@ -24,11 +21,6 @@ class RequestDownloadTest : BaseTestCase() { val manager: Manager by lazy { Manager().apply { basePath = "http://httpbin.org" - callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } } diff --git a/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt b/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt index 1c62dce5c..9e19a09b8 100644 --- a/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt @@ -1,7 +1,6 @@ package fuel import fuel.core.* -import org.json.JSONObject import org.junit.Before import org.junit.Test import java.net.HttpURLConnection @@ -16,40 +15,35 @@ import kotlin.test.assertTrue */ class RequestHandlerTest : BaseTestCase() { + init { Manager.instance.basePath = "https://httpbin.org" Manager.instance.baseHeaders = mapOf("foo" to "bar") Manager.instance.baseParams = listOf("key" to "value") - - Manager.instance.callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } //Model data class HttpBinHeadersModel(var headers: MutableMap = hashMapOf()) //Deserializer - class HttpBinHeadersDeserializer : ResponseDeserializable { - - override fun deserialize(content: String): HttpBinHeadersModel { - val results = hashMapOf() - - val jsonHeaders = JSONObject(content).getJSONObject("headers") - jsonHeaders.keys().asSequence().fold(results) { results, key -> - results.put(key as String, jsonHeaders.getString(key)) - results - } - - val model = HttpBinHeadersModel() - model.headers = results - - return model - } - - } +// class HttpBinHeadersDeserializer : ResponseDeserializable { +// +// override fun deserialize(content: String): HttpBinHeadersModel { +// val results = hashMapOf() +// +// val jsonHeaders = JSONObject(content).getJSONObject("headers") +// jsonHeaders.keys().asSequence().fold(results) { results, key -> +// results.put(key as String, jsonHeaders.getString(key)) +// results +// } +// +// val model = HttpBinHeadersModel() +// model.headers = results +// +// return model +// } +// +// } @Before fun setUp() { @@ -157,112 +151,111 @@ class RequestHandlerTest : BaseTestCase() { assertTrue(string.contains(paramKey) && string.contains(paramValue), "url query param should be sent along with url and present in response of httpbin.org") } - @Test - fun httpGetRequestJsonValid() { - var req: Request? = null - var res: Response? = null - var data: Any? = null - var err: FuelError? = null - - Fuel.get("/user-agent").responseJson(object : Handler { - override fun success(request: Request, response: Response, value: JSONObject) { - req = request - res = response - data = value - - lock.countDown() - } - - override fun failure(request: Request, response: Response, error: FuelError) { - println(error) - } - }) - - await() - - assertNotNull(req, "request should not be null") - assertNotNull(res, "response should not be null") - assertNull(err, "error should be null") - assertNotNull(data, "data should not be null") - assertTrue(data is JSONObject, "data should be JSONObject type") - assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code should be ${HttpURLConnection.HTTP_OK}") - } - - @Test - fun httpGetRequestJsonInvalid() { - var req: Request? = null - var res: Response? = null - var data: Any? = null - var err: FuelError? = null - - Fuel.get("/html").responseJson(object : Handler { - override fun success(request: Request, response: Response, value: JSONObject) { - } - - override fun failure(request: Request, response: Response, error: FuelError) { - req = request - res = response - err = error - - lock.countDown() - println(error) - } - }) - - await() - - assertNotNull(req, "request should not be null") - assertNotNull(res, "response should not be null") - assertNotNull(err, "error should not be null") - assertNull(data, "data should be null") - assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code (${res?.httpStatusCode}) should be ${HttpURLConnection.HTTP_OK}") - } - - @Test - fun httpGetRequestObject() { - var req: Request? = null - var res: Response? = null - var data: Any? = null - var err: FuelError? = null - - Fuel.get("/headers").responseObject(HttpBinHeadersDeserializer(), object : Handler { - - override fun success(request: Request, response: Response, value: HttpBinHeadersModel) { - req = request - res = response - data = value - - lock.countDown() - } - - override fun failure(request: Request, response: Response, error: FuelError) { - } - - }) - - await() - - assertNotNull(req, "request should not be null") - assertNotNull(res, "response should not be null") - assertNull(err, "error should be null") - assertNotNull(data, "data should not be null") - assertTrue(data is HttpBinHeadersModel, "data should be HttpBinHeadersModel type") - assertTrue((data as HttpBinHeadersModel).headers.isNotEmpty(), "model must properly be serialized") - } +// @Test +// fun httpGetRequestJsonValid() { +// var req: Request? = null +// var res: Response? = null +// var data: Any? = null +// var err: FuelError? = null +// +// Fuel.get("/user-agent").responseJson(object : Handler { +// override fun success(request: Request, response: Response, value: JSONObject) { +// req = request +// res = response +// data = value +// +// lock.countDown() +// } +// +// override fun failure(request: Request, response: Response, error: FuelError) { +// println(error) +// } +// }) +// +// await() +// +// assertNotNull(req, "request should not be null") +// assertNotNull(res, "response should not be null") +// assertNull(err, "error should be null") +// assertNotNull(data, "data should not be null") +// assertTrue(data is JSONObject, "data should be JSONObject type") +// assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code should be ${HttpURLConnection.HTTP_OK}") +// } + +// @Test +// fun httpGetRequestJsonInvalid() { +// var req: Request? = null +// var res: Response? = null +// var data: Any? = null +// var err: FuelError? = null +// +// Fuel.get("/html").responseJson(object : Handler { +// override fun success(request: Request, response: Response, value: JSONObject) { +// } +// +// override fun failure(request: Request, response: Response, error: FuelError) { +// req = request +// res = response +// err = error +// +// lock.countDown() +// println(error) +// } +// }) +// +// await() +// +// assertNotNull(req, "request should not be null") +// assertNotNull(res, "response should not be null") +// assertNotNull(err, "error should not be null") +// assertNull(data, "data should be null") +// assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code (${res?.httpStatusCode}) should be ${HttpURLConnection.HTTP_OK}") +// } + +// @Test +// fun httpGetRequestObject() { +// var req: Request? = null +// var res: Response? = null +// var data: Any? = null +// var err: FuelError? = null +// +// Fuel.get("/headers").responseObject(HttpBinHeadersDeserializer(), object : Handler { +// +// override fun success(request: Request, response: Response, value: HttpBinHeadersModel) { +// req = request +// res = response +// data = value +// +// lock.countDown() +// } +// +// override fun failure(request: Request, response: Response, error: FuelError) { +// } +// +// }) +// +// await() +// +// assertNotNull(req, "request should not be null") +// assertNotNull(res, "response should not be null") +// assertNull(err, "error should be null") +// assertNotNull(data, "data should not be null") +// assertTrue(data is HttpBinHeadersModel, "data should be HttpBinHeadersModel type") +// assertTrue((data as HttpBinHeadersModel).headers.isNotEmpty(), "model must properly be serialized") +// } //jsonObject - public fun Request.responseJson(handler: (Request, Response, Either) -> Unit): Unit = - response(jsonDeserializer(), handler) - - public fun Request.responseJson(handler: Handler): Unit = response(jsonDeserializer(), handler) - - public fun jsonDeserializer(): Deserializable { - return object : Deserializable { - override fun deserialize(response: Response): JSONObject { - return JSONObject(String(response.data)) - } - } - } - +// public fun Request.responseJson(handler: (Request, Response, Either) -> Unit): Unit = +// response(jsonDeserializer(), handler) +// +// public fun Request.responseJson(handler: Handler): Unit = response(jsonDeserializer(), handler) +// +// public fun jsonDeserializer(): Deserializable { +// return object : Deserializable { +// override fun deserialize(response: Response): JSONObject { +// return JSONObject(String(response.data)) +// } +// } +// } } \ No newline at end of file diff --git a/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt b/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt index 796b4cbc7..d547ffed0 100644 --- a/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt @@ -19,11 +19,6 @@ class RequestHeaderTest : BaseTestCase() { val manager: Manager by lazy { Manager().apply { basePath = "http://httpbin.org" - callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } } diff --git a/fuel/src/test/kotlin/fuel/RequestObjectTest.kt b/fuel/src/test/kotlin/fuel/RequestObjectTest.kt index 19b78904b..d7d8b8842 100644 --- a/fuel/src/test/kotlin/fuel/RequestObjectTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestObjectTest.kt @@ -1,7 +1,6 @@ package fuel import fuel.core.* -import org.json.JSONException import org.junit.Before import org.junit.Test import java.io.Reader @@ -19,11 +18,6 @@ class RequestObjectTest : BaseTestCase() { init { Manager.instance.basePath = "http://httpbin.org" - Manager.instance.callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } //Model @@ -41,7 +35,7 @@ class RequestObjectTest : BaseTestCase() { class HttpBinMalformedDeserializer : ResponseDeserializable { override fun deserialize(reader: Reader): HttpBinUserAgentModel { - throw JSONException("Test malformed data") + throw IllegalStateException("Malformed data") } } @@ -103,7 +97,7 @@ class RequestObjectTest : BaseTestCase() { assertNotNull(response, "response should not be null") assertNotNull(error, "error should not be null") assertNull(data, "data should be null") - assertTrue(error?.exception is JSONException, "exception is JSONException so that user can react with exception") + assertTrue(error?.exception is IllegalStateException, "exception is JSONException so that user can react with exception") } } \ No newline at end of file diff --git a/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt b/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt index 002cfb096..04dd6e1b4 100644 --- a/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt @@ -1,9 +1,6 @@ package fuel -import fuel.core.FuelError -import fuel.core.Manager -import fuel.core.Request -import fuel.core.Response +import fuel.core.* import org.junit.Before import org.junit.Test import java.net.HttpURLConnection @@ -21,11 +18,6 @@ class RequestPathStringConvertibleExtensionTest : BaseTestCase() { init { Manager.instance.basePath = "https://httpbin.org" - Manager.instance.callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } enum class HttpsBin(val relativePath: String) : Fuel.PathStringConvertible { diff --git a/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt b/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt index 371391909..5d9c31181 100644 --- a/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt @@ -21,12 +21,6 @@ class RequestSharedInstanceTest : BaseTestCase() { Manager.instance.basePath = "https://httpbin.org" Manager.instance.baseHeaders = mapOf("foo" to "bar") Manager.instance.baseParams = listOf("key" to "value") - - Manager.instance.callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } enum class HttpsBin(override val path: String) : Fuel.PathStringConvertible { diff --git a/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt b/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt index 8f0a79e55..502d06b2c 100644 --- a/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt @@ -1,9 +1,6 @@ package fuel -import fuel.core.FuelError -import fuel.core.Manager -import fuel.core.Request -import fuel.core.Response +import fuel.core.* import org.junit.Before import org.junit.Test import java.net.HttpURLConnection @@ -23,12 +20,6 @@ class RequestStringExtensionTest : BaseTestCase() { Manager.instance.basePath = "https://httpbin.org" Manager.instance.baseHeaders = mapOf("foo" to "bar") Manager.instance.baseParams = listOf("key" to "value") - - Manager.instance.callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } @Before diff --git a/fuel/src/test/kotlin/fuel/RequestTest.kt b/fuel/src/test/kotlin/fuel/RequestTest.kt index da2c49167..c819efd1f 100644 --- a/fuel/src/test/kotlin/fuel/RequestTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestTest.kt @@ -16,15 +16,7 @@ import kotlin.test.assertTrue class RequestTest : BaseTestCase() { - val manager: Manager by lazy { - Manager().apply { - callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } - } - } + val manager: Manager by lazy { Manager() } enum class HttpsBin(val relativePath: String) : Fuel.PathStringConvertible { USER_AGENT("user-agent"), diff --git a/fuel/src/test/kotlin/fuel/RequestUploadTest.kt b/fuel/src/test/kotlin/fuel/RequestUploadTest.kt index 90de4616f..3eec30973 100644 --- a/fuel/src/test/kotlin/fuel/RequestUploadTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestUploadTest.kt @@ -1,9 +1,6 @@ package fuel -import fuel.core.FuelError -import fuel.core.Manager -import fuel.core.Request -import fuel.core.Response +import fuel.core.* import org.junit.Before import org.junit.Test import java.io.File @@ -24,11 +21,6 @@ class RequestUploadTest : BaseTestCase() { val manager: Manager by lazy { Manager().apply { basePath = "http://httpbin.org" - callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } } diff --git a/fuel/src/test/kotlin/fuel/RequestValidationTest.kt b/fuel/src/test/kotlin/fuel/RequestValidationTest.kt index fd2c183f2..1b62e17f8 100644 --- a/fuel/src/test/kotlin/fuel/RequestValidationTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestValidationTest.kt @@ -18,11 +18,6 @@ class RequestValidationTest : BaseTestCase() { val manager: Manager by lazy { Manager().apply { basePath = "http://httpbin.org" - callbackExecutor = object : Executor { - override fun execute(command: Runnable) { - command.run() - } - } } } From 93243c7f86dacc063fcf20be4caae566cf0810fd Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Sun, 8 Nov 2015 19:44:12 +0700 Subject: [PATCH 02/16] Stupid things that could possibly work --- fuel-android/.gitignore | 1 + fuel-android/build.gradle | 64 +++++++++++++++++++ fuel-android/proguard-rules.pro | 17 +++++ fuel-android/src/main/AndroidManifest.xml | 5 ++ .../kotlin/util/AndroidMainThreadExecutor.kt | 19 ++++++ .../fuel/android/RequestAndroidHandlerTest.kt | 10 +++ fuel/build.gradle | 1 - fuel/src/main/kotlin/fuel/core/Manager.kt | 9 ++- .../main/kotlin/fuel/util/DefaultExecutor.kt | 4 ++ gradle/wrapper/gradle-wrapper.properties | 6 +- sample-java/build.gradle | 10 ++- sample/build.gradle | 12 ++-- .../kotlin/com/example/fuel/MainActivity.kt | 22 +++---- settings.gradle | 2 +- 14 files changed, 157 insertions(+), 25 deletions(-) create mode 100644 fuel-android/.gitignore create mode 100644 fuel-android/build.gradle create mode 100644 fuel-android/proguard-rules.pro create mode 100644 fuel-android/src/main/AndroidManifest.xml create mode 100644 fuel-android/src/main/kotlin/util/AndroidMainThreadExecutor.kt create mode 100644 fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt diff --git a/fuel-android/.gitignore b/fuel-android/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/fuel-android/.gitignore @@ -0,0 +1 @@ +/build diff --git a/fuel-android/build.gradle b/fuel-android/build.gradle new file mode 100644 index 000000000..9f5c4c7f2 --- /dev/null +++ b/fuel-android/build.gradle @@ -0,0 +1,64 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +repositories { + jcenter() +} + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.1" + + defaultConfig { + minSdkVersion 9 + targetSdkVersion 23 + versionCode 1 + versionName "0.57" + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + test.java.srcDirs += 'src/test/kotlin' + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } + + lintOptions { + abortOnError false + } +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + + compile project(':fuel') + + testCompile "junit:junit:$junit_version" +} + +buildscript { + ext { + //dependencies version + kotlin_version = '1.0.0-beta-1038' + junit_version = '4.12' + } + + repositories { + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + diff --git a/fuel-android/proguard-rules.pro b/fuel-android/proguard-rules.pro new file mode 100644 index 000000000..7177abaf2 --- /dev/null +++ b/fuel-android/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/kittinunf/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 *; +#} diff --git a/fuel-android/src/main/AndroidManifest.xml b/fuel-android/src/main/AndroidManifest.xml new file mode 100644 index 000000000..e8d13779b --- /dev/null +++ b/fuel-android/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/fuel-android/src/main/kotlin/util/AndroidMainThreadExecutor.kt b/fuel-android/src/main/kotlin/util/AndroidMainThreadExecutor.kt new file mode 100644 index 000000000..bc1983a6e --- /dev/null +++ b/fuel-android/src/main/kotlin/util/AndroidMainThreadExecutor.kt @@ -0,0 +1,19 @@ +package util + +import android.os.Handler +import android.os.Looper +import java.util.concurrent.Executor + +/** + * Created by Kittinun Vantasin on 11/8/15. + */ + +public class AndroidMainThreadExecutor : Executor { + + val handler = Handler(Looper.getMainLooper()) + + override fun execute(command: Runnable?) { + handler.post(command) + } + +} \ No newline at end of file diff --git a/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt b/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt new file mode 100644 index 000000000..1521c83b3 --- /dev/null +++ b/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt @@ -0,0 +1,10 @@ +package fuel.android + +import fuel.BaseTestCase + +/** + * Created by Kittinun Vantasin on 11/8/15. + */ + +public class RequestAndroidHandlerTest : BaseTestCase() { +} \ No newline at end of file diff --git a/fuel/build.gradle b/fuel/build.gradle index 36ba53ecc..89ad98724 100644 --- a/fuel/build.gradle +++ b/fuel/build.gradle @@ -1,4 +1,3 @@ - apply plugin: 'kotlin' sourceSets { diff --git a/fuel/src/main/kotlin/fuel/core/Manager.kt b/fuel/src/main/kotlin/fuel/core/Manager.kt index 2fe772038..71a344472 100644 --- a/fuel/src/main/kotlin/fuel/core/Manager.kt +++ b/fuel/src/main/kotlin/fuel/core/Manager.kt @@ -31,7 +31,14 @@ public class Manager { } //callback executor - public var callbackExecutor: Executor by readWriteLazy { DefaultExecutor() } + public var callbackExecutor: Executor by readWriteLazy { + try { + val clazz = Class.forName("util.AndroidMainThreadExecutor") + return@readWriteLazy clazz.newInstance() as Executor + } catch(exception: ClassNotFoundException) { + return@readWriteLazy DefaultExecutor() + } + } companion object { diff --git a/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt b/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt index 915045f37..58db3a397 100644 --- a/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt +++ b/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt @@ -2,6 +2,10 @@ package fuel.util import java.util.concurrent.Executor +/** + * Created by Yoav Sternberg on 11/2/15. + */ + class DefaultExecutor : Executor { override fun execute(command: Runnable) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0446b9c77..05faddc42 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,8 +1,8 @@ -#Thu Aug 06 20:31:20 ICT 2015 +#Sun Nov 08 19:32:07 ICT 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip +org.gradle.jvmargs=-Xmx2048m -XX\:MaxPermSize\=2048m -Xms512m org.gradle.daemon=true -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=2048m -Xms512m +distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip diff --git a/sample-java/build.gradle b/sample-java/build.gradle index 1a44c6bcd..4fe330a02 100644 --- a/sample-java/build.gradle +++ b/sample-java/build.gradle @@ -11,12 +11,18 @@ android { versionCode 1 versionName "1.0" } + buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } } dependencies { @@ -24,14 +30,12 @@ dependencies { compile "com.android.support:appcompat-v7:$android_support_version" - compile project(':fuel') + compile project(':fuel-android') } buildscript { - ext { android_support_version = '23.1.0' } - } diff --git a/sample/build.gradle b/sample/build.gradle index 132cb5a4b..706497b04 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -13,6 +13,10 @@ android { versionName "1.0" } + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + buildTypes { release { minifyEnabled false @@ -25,8 +29,9 @@ android { exclude 'META-INF/NOTICE.txt' } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 } } @@ -37,11 +42,10 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "com.google.code.gson:gson:$gson_version" - compile project(':fuel') + compile project(':fuel-android') } buildscript { - ext { android_support_version = '23.1.0' kotlin_version = '1.0.0-beta-1038' diff --git a/sample/src/main/kotlin/com/example/fuel/MainActivity.kt b/sample/src/main/kotlin/com/example/fuel/MainActivity.kt index 2156b78e3..b5ac636cd 100644 --- a/sample/src/main/kotlin/com/example/fuel/MainActivity.kt +++ b/sample/src/main/kotlin/com/example/fuel/MainActivity.kt @@ -128,7 +128,7 @@ public class MainActivity : AppCompatActivity() { fun httpBasicAuthentication() { val username = URLEncoder.encode("username", "UTF-8") - val password = URLEncoder.encode("P@s\$vv0|2|)", "UTF-8") + val password = URLEncoder.encode("1234567890", "UTF-8") Fuel.get("/basic-auth/$username/$password").authenticate(username, password).responseString { request, response, either -> Log.d(TAG, request.toString()) updateUI(response, either) @@ -141,17 +141,15 @@ public class MainActivity : AppCompatActivity() { } fun updateUI(response: Response, either: Either) { - runOnUiThread { - //multi-declaration - val (error, data) = either - if (error != null) { - Log.e(TAG, response.toString()) - Log.e(TAG, error.toString()) - mainResultText.text = mainResultText.text.toString() + String(error.errorData) - } else { - Log.d(TAG, response.toString()) - mainResultText.text = mainResultText.text.toString() + data.toString() - } + //multi-declaration + val (error, data) = either + if (error != null) { + Log.e(TAG, response.toString()) + Log.e(TAG, error.toString()) + mainResultText.text = mainResultText.text.toString() + String(error.errorData) + } else { + Log.d(TAG, response.toString()) + mainResultText.text = mainResultText.text.toString() + data.toString() } } diff --git a/settings.gradle b/settings.gradle index b2b3963cd..8021c9191 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':sample', ':fuel', ':sample-java' +include ':sample', ':fuel', ':sample-java', ':fuel-android' From 519cb4acd5d89945f9ee6f2e52a852820ba47fa0 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Tue, 10 Nov 2015 14:56:06 +0700 Subject: [PATCH 03/16] Add relevant test to fuel-android --- fuel-android/build.gradle | 7 + .../src/main/kotlin/extension/Requests.kt | 22 ++ .../main/kotlin/util/AndroidEnvironment.kt | 24 ++ .../kotlin/util/AndroidMainThreadExecutor.kt | 19 -- .../test/kotlin/fuel/android/BaseTestCase.kt | 20 ++ .../fuel/android/RequestAndroidHandlerTest.kt | 223 +++++++++++++++++- fuel/src/main/kotlin/fuel/core/Environment.kt | 34 +++ fuel/src/main/kotlin/fuel/core/Manager.kt | 10 +- .../main/kotlin/fuel/util/DefaultExecutor.kt | 15 -- fuel/src/test/kotlin/fuel/BaseTestCase.kt | 2 +- .../test/kotlin/fuel/RequestHandlerTest.kt | 130 +--------- 11 files changed, 332 insertions(+), 174 deletions(-) create mode 100644 fuel-android/src/main/kotlin/extension/Requests.kt create mode 100644 fuel-android/src/main/kotlin/util/AndroidEnvironment.kt delete mode 100644 fuel-android/src/main/kotlin/util/AndroidMainThreadExecutor.kt create mode 100644 fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt create mode 100644 fuel/src/main/kotlin/fuel/core/Environment.kt delete mode 100644 fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt diff --git a/fuel-android/build.gradle b/fuel-android/build.gradle index 9f5c4c7f2..4851ac84d 100644 --- a/fuel-android/build.gradle +++ b/fuel-android/build.gradle @@ -36,6 +36,11 @@ android { lintOptions { abortOnError false } + + testOptions { + unitTests.returnDefaultValues = true + } + } dependencies { @@ -50,6 +55,8 @@ buildscript { ext { //dependencies version kotlin_version = '1.0.0-beta-1038' + + //test dependencies version junit_version = '4.12' } diff --git a/fuel-android/src/main/kotlin/extension/Requests.kt b/fuel-android/src/main/kotlin/extension/Requests.kt new file mode 100644 index 000000000..e2f5c6ef2 --- /dev/null +++ b/fuel-android/src/main/kotlin/extension/Requests.kt @@ -0,0 +1,22 @@ +package extension + +import fuel.core.* +import org.json.JSONObject + +/** + * Created by Kittinun Vantasin on 11/9/15. + */ + +//jsonObject +public fun Request.responseJson(handler: (Request, Response, Either) -> Unit): Unit = + response(jsonDeserializer(), handler) + +public fun Request.responseJson(handler: Handler): Unit = response(jsonDeserializer(), handler) + +public fun jsonDeserializer(): Deserializable { + return object : Deserializable { + override fun deserialize(response: Response): JSONObject { + return JSONObject(String(response.data)) + } + } +} diff --git a/fuel-android/src/main/kotlin/util/AndroidEnvironment.kt b/fuel-android/src/main/kotlin/util/AndroidEnvironment.kt new file mode 100644 index 000000000..23bdae804 --- /dev/null +++ b/fuel-android/src/main/kotlin/util/AndroidEnvironment.kt @@ -0,0 +1,24 @@ +package util + +import android.os.Handler +import android.os.Looper +import fuel.core.Environment +import java.util.concurrent.Executor + +/** + * Created by Kittinun Vantasin on 11/9/15. + */ + +internal class AndroidEnvironment : Environment { + + val handler = Handler(Looper.getMainLooper()) + + override var callbackExecutor: Executor = object : Executor { + + override fun execute(command: Runnable?) { + handler.post(command) + } + + } + +} \ No newline at end of file diff --git a/fuel-android/src/main/kotlin/util/AndroidMainThreadExecutor.kt b/fuel-android/src/main/kotlin/util/AndroidMainThreadExecutor.kt deleted file mode 100644 index bc1983a6e..000000000 --- a/fuel-android/src/main/kotlin/util/AndroidMainThreadExecutor.kt +++ /dev/null @@ -1,19 +0,0 @@ -package util - -import android.os.Handler -import android.os.Looper -import java.util.concurrent.Executor - -/** - * Created by Kittinun Vantasin on 11/8/15. - */ - -public class AndroidMainThreadExecutor : Executor { - - val handler = Handler(Looper.getMainLooper()) - - override fun execute(command: Runnable?) { - handler.post(command) - } - -} \ No newline at end of file diff --git a/fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt b/fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt new file mode 100644 index 000000000..5954891e8 --- /dev/null +++ b/fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt @@ -0,0 +1,20 @@ +package fuel.android + +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit + +/** + * Created by Kittinun Vantasin on 11/9/15. + */ + +abstract class BaseTestCase { + + val DEFAULT_TIMEOUT = 15L + + lateinit var lock: CountDownLatch + + fun await(seconds: Long = DEFAULT_TIMEOUT) { + lock.await(seconds, TimeUnit.SECONDS); + } + +} diff --git a/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt b/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt index 1521c83b3..8fa6090c8 100644 --- a/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt +++ b/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt @@ -1,10 +1,231 @@ package fuel.android -import fuel.BaseTestCase +import extension.responseJson +import fuel.Fuel +import fuel.core.* +import org.json.JSONObject +import org.junit.Before +import org.junit.Test +import java.net.HttpURLConnection +import java.util.concurrent.CountDownLatch +import java.util.concurrent.Executor +import kotlin.test.assertFalse +import kotlin.test.assertNotNull +import kotlin.test.assertNull +import kotlin.test.assertTrue /** * Created by Kittinun Vantasin on 11/8/15. */ public class RequestAndroidHandlerTest : BaseTestCase() { + + init { + Manager.instance.basePath = "https://httpbin.org" + Manager.instance.baseHeaders = mapOf("foo" to "bar") + Manager.instance.baseParams = listOf("key" to "value") + + Manager.instance.callbackExecutor = object : Executor { + override fun execute(command: Runnable) { + command.run() + } + } + + } + + //Model + data class HttpBinHeadersModel(var headers: Map = hashMapOf()) + + //Deserializer + class HttpBinHeadersDeserializer : ResponseDeserializable { + + override fun deserialize(content: String): HttpBinHeadersModel { + val json = JSONObject(content) + val headers = json.getJSONObject("headers") + val results = headers.keys().asSequence().toMap({ it }, { headers.getString(it) }) + val model = HttpBinHeadersModel() + model.headers = results + return model + } + + } + + @Before + fun setUp() { + lock = CountDownLatch(1) + } + + @Test + fun httpGetRequestJsonValid() { + var req: Request? = null + var res: Response? = null + var data: Any? = null + var err: FuelError? = null + + Fuel.get("/user-agent").responseJson { request, response, either -> + val (e, d) = either + data = d + err = e + + req = request + res = response + + lock.countDown() + } + + await() + + assertNotNull(req, "request should not be null") + assertNotNull(res, "response should not be null") + assertNull(err, "error should be null") + assertNotNull(data, "data should not be null") + assertTrue(data is JSONObject, "data should be JSONObject type") + assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code should be ${HttpURLConnection.HTTP_OK}") + } + + @Test + fun httpGetRequestJsonHandlerValid() { + var req: Request? = null + var res: Response? = null + var data: Any? = null + var err: FuelError? = null + + Fuel.get("/user-agent").responseJson(object : Handler { + override fun success(request: Request, response: Response, value: JSONObject) { + req = request + res = response + data = value + + lock.countDown() + } + + override fun failure(request: Request, response: Response, error: FuelError) { + } + }) + + await() + + assertNotNull(req, "request should not be null") + assertNotNull(res, "response should not be null") + assertNull(err, "error should be null") + assertNotNull(data, "data should not be null") + assertTrue(data is JSONObject, "data should be JSONObject type") + assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code should be ${HttpURLConnection.HTTP_OK}") + } + + @Test + fun httpGetRequestJsonInvalid() { + var req: Request? = null + var res: Response? = null + var data: Any? = null + var err: FuelError? = null + + Fuel.get("/404").responseJson { request, response, either -> + val (e, d) = either + data = d + err = e + + req = request + res = response + + lock.countDown() + } + + await() + + assertNotNull(req, "request should not be null") + assertNotNull(res, "response should not be null") + assertNotNull(err, "error should not be null") + assertNull(data, "data should be null") + assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_NOT_FOUND, "http status code (${res?.httpStatusCode}) should be ${HttpURLConnection.HTTP_NOT_FOUND}") + } + + @Test + fun httpGetRequestJsonHandlerInvalid() { + var req: Request? = null + var res: Response? = null + var data: Any? = null + var err: FuelError? = null + + Fuel.get("/404").responseJson(object : Handler { + override fun success(request: Request, response: Response, value: JSONObject) { + } + + override fun failure(request: Request, response: Response, error: FuelError) { + req = request + res = response + err = error + + lock.countDown() + } + }) + + await() + + assertNotNull(req, "request should not be null") + assertNotNull(res, "response should not be null") + assertNotNull(err, "error should not be null") + assertNull(data, "data should be null") + assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_NOT_FOUND, "http status code (${res?.httpStatusCode}) should be ${HttpURLConnection.HTTP_NOT_FOUND}") + } + + @Test + fun httpGetRequestObject() { + var req: Request? = null + var res: Response? = null + var data: Any? = null + var err: FuelError? = null + + Fuel.get("/headers").responseObject(HttpBinHeadersDeserializer()) { request, response, either -> + val (e, d) = either + req = request + res = response + data = d + err = e + + lock.countDown() + } + + await() + + assertNotNull(req, "request should not be null") + assertNotNull(res, "response should not be null") + assertNull(err, "error should be null") + assertNotNull(data, "data should not be null") + assertTrue(data is HttpBinHeadersModel, "data should be HttpBinHeadersModel type") + assertFalse((data as HttpBinHeadersModel).headers.isNotEmpty(), "model must properly be serialized") + } + + @Test + fun httpGetRequestHandlerObject() { + var req: Request? = null + var res: Response? = null + var data: Any? = null + var err: FuelError? = null + + Fuel.get("/headers").responseObject(HttpBinHeadersDeserializer(), object : Handler { + + override fun success(request: Request, response: Response, value: HttpBinHeadersModel) { + req = request + res = response + data = value + + lock.countDown() + } + + override fun failure(request: Request, response: Response, error: FuelError) { + } + + }) + + await() + + assertNotNull(req, "request should not be null") + assertNotNull(res, "response should not be null") + assertNull(err, "error should be null") + assertNotNull(data, "data should not be null") + assertTrue(data is HttpBinHeadersModel, "data should be HttpBinHeadersModel type") + assertFalse((data as HttpBinHeadersModel).headers.isNotEmpty(), "model must properly be serialized") + } + } \ No newline at end of file diff --git a/fuel/src/main/kotlin/fuel/core/Environment.kt b/fuel/src/main/kotlin/fuel/core/Environment.kt new file mode 100644 index 000000000..30ddd0af7 --- /dev/null +++ b/fuel/src/main/kotlin/fuel/core/Environment.kt @@ -0,0 +1,34 @@ +package fuel.core + +import java.util.concurrent.Executor + +/** + * Created by Kittinun Vantasin on 11/8/15. + */ + +interface Environment { + + var callbackExecutor: Executor + +} + +public fun createEnvironment(): Environment { + try { + return Class.forName("util.AndroidEnvironment").newInstance() as Environment + } catch(exception: ClassNotFoundException) { + return DefaultEnvironment() + } +} + +public class DefaultEnvironment : Environment { + + override var callbackExecutor: Executor = object : Executor { + + override fun execute(command: Runnable?) { + command?.run() + } + + } + +} + diff --git a/fuel/src/main/kotlin/fuel/core/Manager.kt b/fuel/src/main/kotlin/fuel/core/Manager.kt index 71a344472..1b3906917 100644 --- a/fuel/src/main/kotlin/fuel/core/Manager.kt +++ b/fuel/src/main/kotlin/fuel/core/Manager.kt @@ -2,7 +2,6 @@ package fuel.core import fuel.Fuel import fuel.toolbox.HttpClient -import fuel.util.DefaultExecutor import fuel.util.readWriteLazy import java.util.concurrent.Executor import java.util.concurrent.ExecutorService @@ -31,14 +30,7 @@ public class Manager { } //callback executor - public var callbackExecutor: Executor by readWriteLazy { - try { - val clazz = Class.forName("util.AndroidMainThreadExecutor") - return@readWriteLazy clazz.newInstance() as Executor - } catch(exception: ClassNotFoundException) { - return@readWriteLazy DefaultExecutor() - } - } + public var callbackExecutor: Executor by readWriteLazy { createEnvironment().callbackExecutor } companion object { diff --git a/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt b/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt deleted file mode 100644 index 58db3a397..000000000 --- a/fuel/src/main/kotlin/fuel/util/DefaultExecutor.kt +++ /dev/null @@ -1,15 +0,0 @@ -package fuel.util - -import java.util.concurrent.Executor - -/** - * Created by Yoav Sternberg on 11/2/15. - */ - -class DefaultExecutor : Executor { - - override fun execute(command: Runnable) { - command.run() - } - -} \ No newline at end of file diff --git a/fuel/src/test/kotlin/fuel/BaseTestCase.kt b/fuel/src/test/kotlin/fuel/BaseTestCase.kt index 2cc5d9117..0e4a321ca 100644 --- a/fuel/src/test/kotlin/fuel/BaseTestCase.kt +++ b/fuel/src/test/kotlin/fuel/BaseTestCase.kt @@ -12,7 +12,7 @@ abstract class BaseTestCase { val DEFAULT_TIMEOUT = 15L - var lock: CountDownLatch by Delegates.notNull() + lateinit var lock: CountDownLatch fun await(seconds: Long = DEFAULT_TIMEOUT) { lock.await(seconds, TimeUnit.SECONDS); diff --git a/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt b/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt index 9e19a09b8..1498c17b6 100644 --- a/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt @@ -22,29 +22,6 @@ class RequestHandlerTest : BaseTestCase() { Manager.instance.baseParams = listOf("key" to "value") } - //Model - data class HttpBinHeadersModel(var headers: MutableMap = hashMapOf()) - - //Deserializer -// class HttpBinHeadersDeserializer : ResponseDeserializable { -// -// override fun deserialize(content: String): HttpBinHeadersModel { -// val results = hashMapOf() -// -// val jsonHeaders = JSONObject(content).getJSONObject("headers") -// jsonHeaders.keys().asSequence().fold(results) { results, key -> -// results.put(key as String, jsonHeaders.getString(key)) -// results -// } -// -// val model = HttpBinHeadersModel() -// model.headers = results -// -// return model -// } -// -// } - @Before fun setUp() { lock = CountDownLatch(1) @@ -151,111 +128,6 @@ class RequestHandlerTest : BaseTestCase() { assertTrue(string.contains(paramKey) && string.contains(paramValue), "url query param should be sent along with url and present in response of httpbin.org") } -// @Test -// fun httpGetRequestJsonValid() { -// var req: Request? = null -// var res: Response? = null -// var data: Any? = null -// var err: FuelError? = null -// -// Fuel.get("/user-agent").responseJson(object : Handler { -// override fun success(request: Request, response: Response, value: JSONObject) { -// req = request -// res = response -// data = value -// -// lock.countDown() -// } -// -// override fun failure(request: Request, response: Response, error: FuelError) { -// println(error) -// } -// }) -// -// await() -// -// assertNotNull(req, "request should not be null") -// assertNotNull(res, "response should not be null") -// assertNull(err, "error should be null") -// assertNotNull(data, "data should not be null") -// assertTrue(data is JSONObject, "data should be JSONObject type") -// assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code should be ${HttpURLConnection.HTTP_OK}") -// } - -// @Test -// fun httpGetRequestJsonInvalid() { -// var req: Request? = null -// var res: Response? = null -// var data: Any? = null -// var err: FuelError? = null -// -// Fuel.get("/html").responseJson(object : Handler { -// override fun success(request: Request, response: Response, value: JSONObject) { -// } -// -// override fun failure(request: Request, response: Response, error: FuelError) { -// req = request -// res = response -// err = error -// -// lock.countDown() -// println(error) -// } -// }) -// -// await() -// -// assertNotNull(req, "request should not be null") -// assertNotNull(res, "response should not be null") -// assertNotNull(err, "error should not be null") -// assertNull(data, "data should be null") -// assertTrue(res?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code (${res?.httpStatusCode}) should be ${HttpURLConnection.HTTP_OK}") -// } - -// @Test -// fun httpGetRequestObject() { -// var req: Request? = null -// var res: Response? = null -// var data: Any? = null -// var err: FuelError? = null -// -// Fuel.get("/headers").responseObject(HttpBinHeadersDeserializer(), object : Handler { -// -// override fun success(request: Request, response: Response, value: HttpBinHeadersModel) { -// req = request -// res = response -// data = value -// -// lock.countDown() -// } -// -// override fun failure(request: Request, response: Response, error: FuelError) { -// } -// -// }) -// -// await() -// -// assertNotNull(req, "request should not be null") -// assertNotNull(res, "response should not be null") -// assertNull(err, "error should be null") -// assertNotNull(data, "data should not be null") -// assertTrue(data is HttpBinHeadersModel, "data should be HttpBinHeadersModel type") -// assertTrue((data as HttpBinHeadersModel).headers.isNotEmpty(), "model must properly be serialized") -// } - - //jsonObject -// public fun Request.responseJson(handler: (Request, Response, Either) -> Unit): Unit = -// response(jsonDeserializer(), handler) -// -// public fun Request.responseJson(handler: Handler): Unit = response(jsonDeserializer(), handler) -// -// public fun jsonDeserializer(): Deserializable { -// return object : Deserializable { -// override fun deserialize(response: Response): JSONObject { -// return JSONObject(String(response.data)) -// } -// } -// } + } \ No newline at end of file From 70900aec6941f872702b983961883d955fb6d1d1 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Wed, 11 Nov 2015 00:14:19 +0700 Subject: [PATCH 04/16] Fix tests by using robolectric --- fuel-android/build.gradle | 2 ++ fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt | 5 +++++ .../test/kotlin/fuel/android/RequestAndroidHandlerTest.kt | 4 ++-- gradle.properties | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fuel-android/build.gradle b/fuel-android/build.gradle index 4851ac84d..e59046e88 100644 --- a/fuel-android/build.gradle +++ b/fuel-android/build.gradle @@ -49,6 +49,7 @@ dependencies { compile project(':fuel') testCompile "junit:junit:$junit_version" + testCompile "org.robolectric:robolectric:$robolectric_version" } buildscript { @@ -58,6 +59,7 @@ buildscript { //test dependencies version junit_version = '4.12' + robolectric_version = '3.0' } repositories { diff --git a/fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt b/fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt index 5954891e8..d43a26f9f 100644 --- a/fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt +++ b/fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt @@ -1,5 +1,8 @@ package fuel.android +import org.junit.runner.RunWith +import org.robolectric.RobolectricGradleTestRunner +import org.robolectric.annotation.Config import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit @@ -7,6 +10,8 @@ import java.util.concurrent.TimeUnit * Created by Kittinun Vantasin on 11/9/15. */ +@RunWith(RobolectricGradleTestRunner::class) +@Config(constants = BuildConfig::class, sdk = intArrayOf(21)) abstract class BaseTestCase { val DEFAULT_TIMEOUT = 15L diff --git a/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt b/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt index 8fa6090c8..672021cc8 100644 --- a/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt +++ b/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt @@ -193,7 +193,7 @@ public class RequestAndroidHandlerTest : BaseTestCase() { assertNull(err, "error should be null") assertNotNull(data, "data should not be null") assertTrue(data is HttpBinHeadersModel, "data should be HttpBinHeadersModel type") - assertFalse((data as HttpBinHeadersModel).headers.isNotEmpty(), "model must properly be serialized") + assertFalse((data as HttpBinHeadersModel).headers.isEmpty(), "model must properly be serialized") } @Test @@ -225,7 +225,7 @@ public class RequestAndroidHandlerTest : BaseTestCase() { assertNull(err, "error should be null") assertNotNull(data, "data should not be null") assertTrue(data is HttpBinHeadersModel, "data should be HttpBinHeadersModel type") - assertFalse((data as HttpBinHeadersModel).headers.isNotEmpty(), "model must properly be serialized") + assertFalse((data as HttpBinHeadersModel).headers.isEmpty(), "model must properly be serialized") } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 1d3591c8a..2c1f15099 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,9 +10,9 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m -# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +org.gradle.parallel=true \ No newline at end of file From d6af1b8482792ef886cb93905edcb8a151737b66 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Wed, 11 Nov 2015 00:27:05 +0700 Subject: [PATCH 05/16] Clean up and bump kotlin version to 1.0.1103 --- fuel-android/build.gradle | 2 +- fuel/build.gradle | 2 +- fuel/src/main/kotlin/fuel/util/Base64.java | 2 +- fuel/src/test/kotlin/fuel/BaseTestCase.kt | 1 - fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt | 1 - fuel/src/test/kotlin/fuel/RequestDownloadTest.kt | 6 ++++-- fuel/src/test/kotlin/fuel/RequestHandlerTest.kt | 1 - fuel/src/test/kotlin/fuel/RequestHeaderTest.kt | 1 - fuel/src/test/kotlin/fuel/RequestObjectTest.kt | 1 - .../fuel/RequestPathStringConvertibleExtensionTest.kt | 6 ++++-- fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt | 1 - fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt | 6 ++++-- fuel/src/test/kotlin/fuel/RequestTest.kt | 1 - fuel/src/test/kotlin/fuel/RequestUploadTest.kt | 6 ++++-- fuel/src/test/kotlin/fuel/RequestValidationTest.kt | 1 - .../src/main/java/com/example/fuel/MainActivity.java | 2 +- sample/build.gradle | 2 +- 17 files changed, 21 insertions(+), 21 deletions(-) diff --git a/fuel-android/build.gradle b/fuel-android/build.gradle index e59046e88..61402ed26 100644 --- a/fuel-android/build.gradle +++ b/fuel-android/build.gradle @@ -55,7 +55,7 @@ dependencies { buildscript { ext { //dependencies version - kotlin_version = '1.0.0-beta-1038' + kotlin_version = '1.0.0-beta-1103' //test dependencies version junit_version = '4.12' diff --git a/fuel/build.gradle b/fuel/build.gradle index 89ad98724..88e1c8df1 100644 --- a/fuel/build.gradle +++ b/fuel/build.gradle @@ -18,7 +18,7 @@ dependencies { buildscript { ext { //dependencies version - kotlin_version = '1.0.0-beta-1038' + kotlin_version = '1.0.0-beta-1103' //test dependencies version junit_version = '4.12' diff --git a/fuel/src/main/kotlin/fuel/util/Base64.java b/fuel/src/main/kotlin/fuel/util/Base64.java index 92974d67c..1266cdc1f 100644 --- a/fuel/src/main/kotlin/fuel/util/Base64.java +++ b/fuel/src/main/kotlin/fuel/util/Base64.java @@ -621,7 +621,7 @@ public boolean process(byte[] input, int offset, int len, boolean finish) { ((input[p++] & 0xff) << 8) | (input[p++] & 0xff); tailLen = 0; - }; + } break; case 2: diff --git a/fuel/src/test/kotlin/fuel/BaseTestCase.kt b/fuel/src/test/kotlin/fuel/BaseTestCase.kt index 0e4a321ca..3e7488cd4 100644 --- a/fuel/src/test/kotlin/fuel/BaseTestCase.kt +++ b/fuel/src/test/kotlin/fuel/BaseTestCase.kt @@ -2,7 +2,6 @@ package fuel import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit -import kotlin.properties.Delegates /** * Created by Kittinun Vantasin on 5/21/15. diff --git a/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt b/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt index 2091b0639..f17370b5b 100644 --- a/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt @@ -5,7 +5,6 @@ import org.junit.Before import org.junit.Test import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt b/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt index 6544d3b68..395b52016 100644 --- a/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt @@ -1,13 +1,15 @@ package fuel -import fuel.core.* +import fuel.core.FuelError +import fuel.core.Manager +import fuel.core.Request +import fuel.core.Response import org.junit.Before import org.junit.Test import java.io.File import java.io.IOException import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt b/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt index 1498c17b6..d2f246acf 100644 --- a/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt @@ -5,7 +5,6 @@ import org.junit.Before import org.junit.Test import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt b/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt index d547ffed0..0b22f7dea 100644 --- a/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt @@ -5,7 +5,6 @@ import org.junit.Before import org.junit.Test import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestObjectTest.kt b/fuel/src/test/kotlin/fuel/RequestObjectTest.kt index d7d8b8842..3da3a08c2 100644 --- a/fuel/src/test/kotlin/fuel/RequestObjectTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestObjectTest.kt @@ -5,7 +5,6 @@ import org.junit.Before import org.junit.Test import java.io.Reader import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt b/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt index 04dd6e1b4..9f7dea409 100644 --- a/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt @@ -1,11 +1,13 @@ package fuel -import fuel.core.* +import fuel.core.FuelError +import fuel.core.Manager +import fuel.core.Request +import fuel.core.Response import org.junit.Before import org.junit.Test import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt b/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt index 5d9c31181..7d156a4a3 100644 --- a/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt @@ -6,7 +6,6 @@ import org.junit.Test import java.io.File import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt b/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt index 502d06b2c..9b688a159 100644 --- a/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt @@ -1,11 +1,13 @@ package fuel -import fuel.core.* +import fuel.core.FuelError +import fuel.core.Manager +import fuel.core.Request +import fuel.core.Response import org.junit.Before import org.junit.Test import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestTest.kt b/fuel/src/test/kotlin/fuel/RequestTest.kt index c819efd1f..4723952ac 100644 --- a/fuel/src/test/kotlin/fuel/RequestTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestTest.kt @@ -5,7 +5,6 @@ import org.junit.Before import org.junit.Test import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestUploadTest.kt b/fuel/src/test/kotlin/fuel/RequestUploadTest.kt index 3eec30973..83741cdec 100644 --- a/fuel/src/test/kotlin/fuel/RequestUploadTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestUploadTest.kt @@ -1,13 +1,15 @@ package fuel -import fuel.core.* +import fuel.core.FuelError +import fuel.core.Manager +import fuel.core.Request +import fuel.core.Response import org.junit.Before import org.junit.Test import java.io.File import java.io.FileNotFoundException import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/fuel/src/test/kotlin/fuel/RequestValidationTest.kt b/fuel/src/test/kotlin/fuel/RequestValidationTest.kt index 1b62e17f8..2821a635a 100644 --- a/fuel/src/test/kotlin/fuel/RequestValidationTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestValidationTest.kt @@ -4,7 +4,6 @@ import fuel.core.* import org.junit.Before import org.junit.Test import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executor import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue diff --git a/sample-java/src/main/java/com/example/fuel/MainActivity.java b/sample-java/src/main/java/com/example/fuel/MainActivity.java index 206cab8f3..5e57983e4 100644 --- a/sample-java/src/main/java/com/example/fuel/MainActivity.java +++ b/sample-java/src/main/java/com/example/fuel/MainActivity.java @@ -27,7 +27,7 @@ public class MainActivity extends AppCompatActivity { private static final String TAG = "Main"; - private List> params = new ArrayList>() {{ + private final List> params = new ArrayList>() {{ add(new Pair<>("foo1", "bar1")); add(new Pair<>("foo2", "bar2")); }}; diff --git a/sample/build.gradle b/sample/build.gradle index 706497b04..36ddd5a18 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -48,7 +48,7 @@ dependencies { buildscript { ext { android_support_version = '23.1.0' - kotlin_version = '1.0.0-beta-1038' + kotlin_version = '1.0.0-beta-1103' gson_version = '2.3.1' } From 219f9218e7b51d23e6442505b5c89ecc60cc7a2a Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Wed, 11 Nov 2015 01:14:38 +0700 Subject: [PATCH 06/16] Add support PUT to upload, fix #28 in this commit --- fuel/src/main/kotlin/fuel/Fuel.kt | 16 +-- fuel/src/main/kotlin/fuel/core/Manager.kt | 8 +- ...questPathStringConvertibleExtensionTest.kt | 65 ++++++++++- .../kotlin/fuel/RequestStringExtensionTest.kt | 101 +++++++++++++++++- .../src/test/kotlin/fuel/RequestUploadTest.kt | 36 ++++++- 5 files changed, 204 insertions(+), 22 deletions(-) diff --git a/fuel/src/main/kotlin/fuel/Fuel.kt b/fuel/src/main/kotlin/fuel/Fuel.kt index e1276f638..ee17411b7 100644 --- a/fuel/src/main/kotlin/fuel/Fuel.kt +++ b/fuel/src/main/kotlin/fuel/Fuel.kt @@ -78,13 +78,13 @@ public class Fuel { //upload @JvmStatic @JvmOverloads - public fun upload(path: String, parameters: List>? = null): Request { - return Manager.instance.upload(path, parameters) + public fun upload(path: String, method: Method = Method.POST, parameters: List>? = null): Request { + return Manager.instance.upload(path, method, parameters) } @JvmStatic @JvmOverloads - public fun upload(convertible: PathStringConvertible, parameters: List>? = null): Request { - return Manager.instance.upload(convertible, parameters) + public fun upload(convertible: PathStringConvertible, method: Method = Method.POST, parameters: List>? = null): Request { + return Manager.instance.upload(convertible, method, parameters) } //request @@ -156,11 +156,11 @@ public fun Fuel.PathStringConvertible.httpDownload(parameter: List>? = null): Request { - return Fuel.upload(this, parameter) +public fun String.httpUpload(method: Method = Method.POST, parameters: List>? = null): Request { + return Fuel.upload(this, method, parameters) } @JvmOverloads -public fun Fuel.PathStringConvertible.httpUpload(parameter: List>? = null): Request { - return Fuel.upload(this, parameter) +public fun Fuel.PathStringConvertible.httpUpload(method: Method = Method.POST, parameters: List>? = null): Request { + return Fuel.upload(this, method, parameters) } diff --git a/fuel/src/main/kotlin/fuel/core/Manager.kt b/fuel/src/main/kotlin/fuel/core/Manager.kt index 1b3906917..c442d20b2 100644 --- a/fuel/src/main/kotlin/fuel/core/Manager.kt +++ b/fuel/src/main/kotlin/fuel/core/Manager.kt @@ -93,9 +93,9 @@ public class Manager { return request } - fun upload(path: String, param: List>? = null): Request { + fun upload(path: String, method: Method = Method.POST, param: List>? = null): Request { val request = Encoding().apply { - httpMethod = Method.POST + httpMethod = method baseUrlString = basePath urlString = path parameters = if (param == null) baseParams else baseParams + param @@ -107,9 +107,9 @@ public class Manager { return request } - fun upload(convertible: Fuel.PathStringConvertible, param: List>? = null): Request { + fun upload(convertible: Fuel.PathStringConvertible, method: Method = Method.POST, param: List>? = null): Request { val request = Encoding().apply { - httpMethod = Method.POST + httpMethod = method baseUrlString = basePath urlString = convertible.path parameters = if (param == null) baseParams else baseParams + param diff --git a/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt b/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt index 9f7dea409..c61d81707 100644 --- a/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt @@ -6,6 +6,7 @@ import fuel.core.Request import fuel.core.Response import org.junit.Before import org.junit.Test +import java.io.File import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch import kotlin.test.assertNotNull @@ -26,7 +27,9 @@ class RequestPathStringConvertibleExtensionTest : BaseTestCase() { COOKIES("cookies"), POST("post"), PUT("put"), - DELETE("delete"); + DELETE("delete"), + DOWNLOAD("bytes/123456"), + UPLOAD("post"); override val path = "/$relativePath" } @@ -156,4 +159,64 @@ class RequestPathStringConvertibleExtensionTest : BaseTestCase() { assertTrue(string.contains("https"), "url should contain https to indicate usage of shared instance") } + @Test + fun httpUploadRequestWithSharedInstance() { + var request: Request? = null + var response: Response? = null + var data: Any? = null + var error: FuelError? = null + + HttpsBin.UPLOAD.httpUpload().source { request, url -> + val dir = System.getProperty("user.dir") + val currentDir = File(dir, "src/test/assets") + File(currentDir, "lorem_ipsum_long.tmp") + }.responseString { req, res, either -> + request = req + response = res + + val (err, d) = either + data = d + error = err + + lock.countDown() + } + + await() + + assertNotNull(request, "request should not be null") + assertNotNull(response, "response should not be null") + assertNull(error, "error should be null") + assertNotNull(data, "data should not be null") + assertTrue(response?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code should be ${HttpURLConnection.HTTP_OK}") + } + + @Test + fun httpDownloadRequestWithSharedInstance() { + var request: Request? = null + var response: Response? = null + var data: Any? = null + var error: FuelError? = null + + HttpsBin.DOWNLOAD.httpDownload().destination { response, url -> + File.createTempFile(123456.toString(), null) + }.responseString { req, res, either -> + request = req + response = res + + val (err, d) = either + data = d + error = err + + lock.countDown() + } + + await() + + assertNotNull(request, "request should not be null") + assertNotNull(response, "response should not be null") + assertNull(error, "error should be null") + assertNotNull(data, "data should not be null") + assertTrue(response?.httpStatusCode == HttpURLConnection.HTTP_OK, "http status code should be ${HttpURLConnection.HTTP_OK}") + } + } \ No newline at end of file diff --git a/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt b/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt index 9b688a159..ec56eaaf4 100644 --- a/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt @@ -1,11 +1,9 @@ package fuel -import fuel.core.FuelError -import fuel.core.Manager -import fuel.core.Request -import fuel.core.Response +import fuel.core.* import org.junit.Before import org.junit.Test +import java.io.File import java.net.HttpURLConnection import java.util.concurrent.CountDownLatch import kotlin.test.assertNotNull @@ -141,4 +139,99 @@ class RequestStringExtensionTest : BaseTestCase() { assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode" ) } + @Test + fun httpDownload() { + var request: Request? = null + var response: Response? = null + var data: Any? = null + var error: FuelError? = null + + val numberOfBytes = 32768L + + "/bytes/$numberOfBytes".httpDownload().destination { response, url -> + val f = File.createTempFile(numberOfBytes.toString(), null) + println(f.absolutePath) + f + }.responseString { req, res, either -> + request = req + response = res + val (err, d) = either + data = d + error = err + + lock.countDown() + } + + await() + + assertNotNull(request, "request should not be null") + assertNotNull(response, "response should not be null") + assertNull(error, "error should be null") + assertNotNull(data, "data should not be null") + val statusCode = HttpURLConnection.HTTP_OK + assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode") + } + + @Test + fun httpUploadWithPut() { + var request: Request? = null + var response: Response? = null + var data: Any? = null + var error: FuelError? = null + + "/put".httpUpload(Method.PUT).source { request, url -> + val dir = System.getProperty("user.dir") + val currentDir = File(dir, "src/test/assets") + File(currentDir, "lorem_ipsum_long.tmp") + }.responseString { req, res, either -> + request = req + response = res + val (err, d) = either + data = d + error = err + + lock.countDown() + } + + await() + + assertNotNull(request, "request should not be null") + assertNotNull(response, "response should not be null") + assertNull(error, "error should be null") + assertNotNull(data, "data should not be null") + val statusCode = HttpURLConnection.HTTP_OK + assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode") + } + + @Test + fun httpUploadWithPost() { + var request: Request? = null + var response: Response? = null + var data: Any? = null + var error: FuelError? = null + + "/post".httpUpload().source { request, url -> + val dir = System.getProperty("user.dir") + val currentDir = File(dir, "src/test/assets") + File(currentDir, "lorem_ipsum_long.tmp") + }.responseString { req, res, either -> + request = req + response = res + val (err, d) = either + data = d + error = err + + lock.countDown() + } + + await() + + assertNotNull(request, "request should not be null") + assertNotNull(response, "response should not be null") + assertNull(error, "error should be null") + assertNotNull(data, "data should not be null") + val statusCode = HttpURLConnection.HTTP_OK + assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode") + } + } \ No newline at end of file diff --git a/fuel/src/test/kotlin/fuel/RequestUploadTest.kt b/fuel/src/test/kotlin/fuel/RequestUploadTest.kt index 83741cdec..2da39d39f 100644 --- a/fuel/src/test/kotlin/fuel/RequestUploadTest.kt +++ b/fuel/src/test/kotlin/fuel/RequestUploadTest.kt @@ -1,9 +1,6 @@ package fuel -import fuel.core.FuelError -import fuel.core.Manager -import fuel.core.Request -import fuel.core.Response +import fuel.core.* import org.junit.Before import org.junit.Test import java.io.File @@ -37,7 +34,7 @@ class RequestUploadTest : BaseTestCase() { } @Test - fun httpUploadCase() { + fun httpUploadWithPostCase() { var request: Request? = null var response: Response? = null var data: Any? = null @@ -65,6 +62,35 @@ class RequestUploadTest : BaseTestCase() { assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode") } + @Test + fun httpUploadWithPutCase() { + var request: Request? = null + var response: Response? = null + var data: Any? = null + var error: FuelError? = null + + manager.upload("/put", Method.PUT).source { request, url -> + File(currentDir, "lorem_ipsum_long.tmp") + }.responseString { req, res, either -> + request = req + response = res + val (err, d) = either + data = d + error = err + + lock.countDown() + } + + await() + + assertNotNull(request, "request should not be null") + assertNotNull(response, "response should not be null") + assertNull(error, "error should be null") + assertNotNull(data, "data should not be null") + val statusCode = HttpURLConnection.HTTP_OK + assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode") + } + @Test fun httpUploadWithProgressValidCase() { var request: Request? = null From 8e09d06c5704ac54411095ed0bbbde5ad838600a Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Wed, 11 Nov 2015 01:27:23 +0700 Subject: [PATCH 07/16] Update README --- README.md | 12 ++++++++++-- fuel/src/main/kotlin/fuel/core/Request.kt | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4b5ab4173..f3ccf40cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fuel -[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1038-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel) +[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1103-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel) The easiest HTTP networking library in Kotlin for Android. @@ -26,7 +26,7 @@ buildscript { } dependencies { - compile 'fuel:fuel:0.57' + compile 'fuel:fuel:0.6' } ``` @@ -235,6 +235,14 @@ Fuel.upload("/post").source { request, url -> File.createTempFile("temp", ".tmp"); }.responseString { request, response, either -> +} + +//by default upload use Method.POST, unless it is specified as something else +Fuel.upload("/put", Method.PUT).source { request, url -> + File.createTempFile("temp", ".tmp"); +}.responseString { request, response, either -> + // calls to http://example.com/api/put with PUT + } ``` diff --git a/fuel/src/main/kotlin/fuel/core/Request.kt b/fuel/src/main/kotlin/fuel/core/Request.kt index 19523a1b2..38fc7cb6a 100644 --- a/fuel/src/main/kotlin/fuel/core/Request.kt +++ b/fuel/src/main/kotlin/fuel/core/Request.kt @@ -1,6 +1,9 @@ package fuel.core -import fuel.util.* +import fuel.util.Base64 +import fuel.util.copyTo +import fuel.util.readWriteLazy +import fuel.util.toHexString import java.io.* import java.net.URL import java.net.URLConnection From 8f0c60109c9512a4475d6628040347e8dbf4f610 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Wed, 11 Nov 2015 17:10:26 +0700 Subject: [PATCH 08/16] Standardize package name and ultimate clean up --- .gitignore | 1 + README.md | 2 +- build.gradle | 3 +-- fuel-android/build.gradle | 12 +++++++++++- .../kittinunf/fuel}/extension/Requests.kt | 10 ++++++++-- .../kittinunf/fuel}/util/AndroidEnvironment.kt | 4 ++-- .../fuel/android/RequestAndroidHandlerTest.kt | 11 ++++++++--- fuel/build.gradle | 12 ++++++++++-- fuel/src/main/AndroidManifest.xml | 6 ------ .../github/kittinunf}/fuel/util/Base64.java | 2 +- .../{ => com/github/kittinunf}/fuel/Fuel.kt | 8 ++++---- .../github/kittinunf}/fuel/core/Client.kt | 2 +- .../kittinunf}/fuel/core/Deserializable.kt | 2 +- .../github/kittinunf}/fuel/core/Either.kt | 2 +- .../github/kittinunf}/fuel/core/Encoding.kt | 6 +++--- .../github/kittinunf}/fuel/core/Environment.kt | 4 ++-- .../github/kittinunf}/fuel/core/FuelError.kt | 2 +- .../github/kittinunf}/fuel/core/Handler.kt | 2 +- .../kittinunf}/fuel/core/HttpException.kt | 2 +- .../github/kittinunf}/fuel/core/Manager.kt | 8 ++++---- .../github/kittinunf}/fuel/core/Method.kt | 2 +- .../github/kittinunf}/fuel/core/Request.kt | 18 +++++++++--------- .../github/kittinunf}/fuel/core/Response.kt | 2 +- .../kittinunf}/fuel/toolbox/HttpClient.kt | 18 +++++++++--------- .../github/kittinunf}/fuel/util/Delegates.kt | 2 +- .../kittinunf}/fuel/util/InputStreams.kt | 2 +- .../com/github/kittinunf/fuel/util/Longs.kt | 7 +++++++ fuel/src/main/kotlin/fuel/util/Longs.kt | 9 --------- .../github/kittinunf}/fuel/BaseTestCase.kt | 2 +- .../github/kittinunf}/fuel/EncodingTest.kt | 14 +++++++------- .../fuel/RequestAuthenticationTest.kt | 4 ++-- .../kittinunf}/fuel/RequestDownloadTest.kt | 10 +++++----- .../kittinunf}/fuel/RequestHandlerTest.kt | 4 ++-- .../kittinunf}/fuel/RequestHeaderTest.kt | 6 +++--- .../kittinunf}/fuel/RequestObjectTest.kt | 4 ++-- ...equestPathStringConvertibleExtensionTest.kt | 10 +++++----- .../fuel/RequestSharedInstanceTest.kt | 4 ++-- .../fuel/RequestStringExtensionTest.kt | 12 ++++++------ .../github/kittinunf}/fuel/RequestTest.kt | 4 ++-- .../kittinunf}/fuel/RequestUploadTest.kt | 4 ++-- .../kittinunf}/fuel/RequestValidationTest.kt | 4 ++-- .../java/com/example/fuel/MainActivity.java | 10 +++++----- .../kotlin/com/example/fuel/MainActivity.kt | 4 ++-- 43 files changed, 139 insertions(+), 118 deletions(-) rename fuel-android/src/main/kotlin/{ => com/github/kittinunf/fuel}/extension/Requests.kt (61%) rename fuel-android/src/main/kotlin/{ => com/github/kittinunf/fuel}/util/AndroidEnvironment.kt (82%) delete mode 100644 fuel/src/main/AndroidManifest.xml rename fuel/src/main/{kotlin => java/com/github/kittinunf}/fuel/util/Base64.java (99%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/Fuel.kt (96%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Client.kt (77%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Deserializable.kt (98%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Either.kt (97%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Encoding.kt (95%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Environment.kt (77%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/FuelError.kt (91%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Handler.kt (85%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/HttpException.kt (81%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Manager.kt (95%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Method.kt (83%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Request.kt (96%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/core/Response.kt (96%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/toolbox/HttpClient.kt (91%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/util/Delegates.kt (95%) rename fuel/src/main/kotlin/{ => com/github/kittinunf}/fuel/util/InputStreams.kt (92%) create mode 100644 fuel/src/main/kotlin/com/github/kittinunf/fuel/util/Longs.kt delete mode 100644 fuel/src/main/kotlin/fuel/util/Longs.kt rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/BaseTestCase.kt (90%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/EncodingTest.kt (75%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestAuthenticationTest.kt (97%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestDownloadTest.kt (95%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestHandlerTest.kt (98%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestHeaderTest.kt (93%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestObjectTest.kt (97%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestPathStringConvertibleExtensionTest.kt (96%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestSharedInstanceTest.kt (99%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestStringExtensionTest.kt (96%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestTest.kt (99%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestUploadTest.kt (98%) rename fuel/src/test/kotlin/{ => com/github/kittinunf}/fuel/RequestValidationTest.kt (97%) diff --git a/.gitignore b/.gitignore index 6ca64c002..b24a941f1 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ local.properties # Bintray install.gradle bintray.gradle +bintray_push # Android Studio .idea/ diff --git a/README.md b/README.md index f3ccf40cc..a5409fb65 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fuel -[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1103-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel) +[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1103-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel) [![Coverage Status](https://coveralls.io/repos/kittinunf/Fuel/badge.svg?branch=master&service=github)](https://coveralls.io/github/kittinunf/Fuel?branch=master) The easiest HTTP networking library in Kotlin for Android. diff --git a/build.gradle b/build.gradle index 41c056927..a1e13fa1f 100644 --- a/build.gradle +++ b/build.gradle @@ -8,8 +8,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:1.3.0' - classpath 'com.github.dcendents:android-maven-plugin:1.2' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' + classpath 'com.novoda:bintray-release:0.3.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/fuel-android/build.gradle b/fuel-android/build.gradle index 61402ed26..6bfa7f20f 100644 --- a/fuel-android/build.gradle +++ b/fuel-android/build.gradle @@ -1,6 +1,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' +apply plugin: 'com.novoda.bintray-release' + repositories { jcenter() } @@ -13,7 +15,7 @@ android { minSdkVersion 9 targetSdkVersion 23 versionCode 1 - versionName "0.57" + versionName "0.6" } sourceSets { @@ -71,3 +73,11 @@ buildscript { } } +publish { + groupId = '' + artifactId = '' + uploadName = '' + version = android.defaultConfig.versionName + desc = '' + website = 'https://github.com/kittinunf/Fuel' +} diff --git a/fuel-android/src/main/kotlin/extension/Requests.kt b/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/extension/Requests.kt similarity index 61% rename from fuel-android/src/main/kotlin/extension/Requests.kt rename to fuel-android/src/main/kotlin/com/github/kittinunf/fuel/extension/Requests.kt index e2f5c6ef2..597422f4c 100644 --- a/fuel-android/src/main/kotlin/extension/Requests.kt +++ b/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/extension/Requests.kt @@ -1,6 +1,12 @@ -package extension +package com.github.kittinunf.fuel.extension -import fuel.core.* +import com.github.kittinunf.fuel.core.Deserializable +import com.github.kittinunf.fuel.core.Either +import com.github.kittinunf.fuel.core.FuelError +import com.github.kittinunf.fuel.core.Handler +import com.github.kittinunf.fuel.core.Request +import com.github.kittinunf.fuel.core.Response +import com.github.kittinunf.fuel.core.response import org.json.JSONObject /** diff --git a/fuel-android/src/main/kotlin/util/AndroidEnvironment.kt b/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/util/AndroidEnvironment.kt similarity index 82% rename from fuel-android/src/main/kotlin/util/AndroidEnvironment.kt rename to fuel-android/src/main/kotlin/com/github/kittinunf/fuel/util/AndroidEnvironment.kt index 23bdae804..8b95ad93e 100644 --- a/fuel-android/src/main/kotlin/util/AndroidEnvironment.kt +++ b/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/util/AndroidEnvironment.kt @@ -1,8 +1,8 @@ -package util +package com.github.kittinunf.fuel.util import android.os.Handler import android.os.Looper -import fuel.core.Environment +import com.github.kittinunf.fuel.core.Environment import java.util.concurrent.Executor /** diff --git a/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt b/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt index 672021cc8..6d337261e 100644 --- a/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt +++ b/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt @@ -1,8 +1,13 @@ package fuel.android -import extension.responseJson -import fuel.Fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.FuelError +import com.github.kittinunf.fuel.core.Handler +import com.github.kittinunf.fuel.core.Manager +import com.github.kittinunf.fuel.core.Request +import com.github.kittinunf.fuel.core.Response +import com.github.kittinunf.fuel.core.ResponseDeserializable +import com.github.kittinunf.fuel.extension.responseJson +import com.github.kittinunf.fuel.Fuel import org.json.JSONObject import org.junit.Before import org.junit.Test diff --git a/fuel/build.gradle b/fuel/build.gradle index 88e1c8df1..477c6a814 100644 --- a/fuel/build.gradle +++ b/fuel/build.gradle @@ -1,5 +1,7 @@ apply plugin: 'kotlin' +apply plugin: 'com.novoda.bintray-release' + sourceSets { main.java.srcDirs += 'src/main/kotlin' test.java.srcDirs += 'src/test/kotlin' @@ -33,5 +35,11 @@ buildscript { } } -//apply from: '../gradle/install.gradle' -//apply from: '../gradle/bintray.gradle' +publish { + groupId = '' + artifactId = '' + uploadName = '' + version = '0.6' + desc = '' + website = 'https://github.com/kittinunf/Fuel' +} diff --git a/fuel/src/main/AndroidManifest.xml b/fuel/src/main/AndroidManifest.xml deleted file mode 100644 index b94c080e9..000000000 --- a/fuel/src/main/AndroidManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/fuel/src/main/kotlin/fuel/util/Base64.java b/fuel/src/main/java/com/github/kittinunf/fuel/util/Base64.java similarity index 99% rename from fuel/src/main/kotlin/fuel/util/Base64.java rename to fuel/src/main/java/com/github/kittinunf/fuel/util/Base64.java index 1266cdc1f..24e457e78 100644 --- a/fuel/src/main/kotlin/fuel/util/Base64.java +++ b/fuel/src/main/java/com/github/kittinunf/fuel/util/Base64.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package fuel.util; +package com.github.kittinunf.fuel.util; import java.io.UnsupportedEncodingException; diff --git a/fuel/src/main/kotlin/fuel/Fuel.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/Fuel.kt similarity index 96% rename from fuel/src/main/kotlin/fuel/Fuel.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/Fuel.kt index ee17411b7..812592ce6 100644 --- a/fuel/src/main/kotlin/fuel/Fuel.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/Fuel.kt @@ -1,8 +1,8 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.Manager -import fuel.core.Method -import fuel.core.Request +import com.github.kittinunf.fuel.core.Manager +import com.github.kittinunf.fuel.core.Method +import com.github.kittinunf.fuel.core.Request /** * Created by Kittinun Vantasin on 5/13/15. diff --git a/fuel/src/main/kotlin/fuel/core/Client.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Client.kt similarity index 77% rename from fuel/src/main/kotlin/fuel/core/Client.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Client.kt index 2c111b1d0..af49001e5 100644 --- a/fuel/src/main/kotlin/fuel/core/Client.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Client.kt @@ -1,4 +1,4 @@ -package fuel.core +package com.github.kittinunf.fuel.core /** * Created by Kittinun Vantasin on 5/14/15. diff --git a/fuel/src/main/kotlin/fuel/core/Deserializable.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Deserializable.kt similarity index 98% rename from fuel/src/main/kotlin/fuel/core/Deserializable.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Deserializable.kt index 8030fe4e3..49f4f6732 100644 --- a/fuel/src/main/kotlin/fuel/core/Deserializable.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Deserializable.kt @@ -1,4 +1,4 @@ -package fuel.core +package com.github.kittinunf.fuel.core import java.io.ByteArrayInputStream import java.io.InputStream diff --git a/fuel/src/main/kotlin/fuel/core/Either.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Either.kt similarity index 97% rename from fuel/src/main/kotlin/fuel/core/Either.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Either.kt index 2e5dd0b39..66a1a4a88 100644 --- a/fuel/src/main/kotlin/fuel/core/Either.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Either.kt @@ -1,4 +1,4 @@ -package fuel.core +package com.github.kittinunf.fuel.core /** * Created by Kittinun Vantasin on 5/15/15. diff --git a/fuel/src/main/kotlin/fuel/core/Encoding.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Encoding.kt similarity index 95% rename from fuel/src/main/kotlin/fuel/core/Encoding.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Encoding.kt index 8aa124088..9f9cb1fbd 100644 --- a/fuel/src/main/kotlin/fuel/core/Encoding.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Encoding.kt @@ -1,7 +1,7 @@ -package fuel.core +package com.github.kittinunf.fuel.core -import fuel.Fuel -import fuel.util.toHexString +import com.github.kittinunf.fuel.Fuel +import com.github.kittinunf.fuel.util.toHexString import java.net.URI import java.net.URL import java.net.URLEncoder diff --git a/fuel/src/main/kotlin/fuel/core/Environment.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Environment.kt similarity index 77% rename from fuel/src/main/kotlin/fuel/core/Environment.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Environment.kt index 30ddd0af7..49d8b4976 100644 --- a/fuel/src/main/kotlin/fuel/core/Environment.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Environment.kt @@ -1,4 +1,4 @@ -package fuel.core +package com.github.kittinunf.fuel.core import java.util.concurrent.Executor @@ -14,7 +14,7 @@ interface Environment { public fun createEnvironment(): Environment { try { - return Class.forName("util.AndroidEnvironment").newInstance() as Environment + return Class.forName("com.github.kittinunf.fuel.util.AndroidEnvironment").newInstance() as Environment } catch(exception: ClassNotFoundException) { return DefaultEnvironment() } diff --git a/fuel/src/main/kotlin/fuel/core/FuelError.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/FuelError.kt similarity index 91% rename from fuel/src/main/kotlin/fuel/core/FuelError.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/FuelError.kt index 5fd8a79a0..987fd0234 100644 --- a/fuel/src/main/kotlin/fuel/core/FuelError.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/FuelError.kt @@ -1,4 +1,4 @@ -package fuel.core +package com.github.kittinunf.fuel.core import kotlin.properties.Delegates diff --git a/fuel/src/main/kotlin/fuel/core/Handler.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Handler.kt similarity index 85% rename from fuel/src/main/kotlin/fuel/core/Handler.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Handler.kt index ba241fcaa..8dc05c2a3 100644 --- a/fuel/src/main/kotlin/fuel/core/Handler.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Handler.kt @@ -1,4 +1,4 @@ -package fuel.core +package com.github.kittinunf.fuel.core /** * Created by Kittinun Vantasin on 6/18/15. diff --git a/fuel/src/main/kotlin/fuel/core/HttpException.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/HttpException.kt similarity index 81% rename from fuel/src/main/kotlin/fuel/core/HttpException.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/HttpException.kt index 6e53b1ab1..4e97ed0eb 100644 --- a/fuel/src/main/kotlin/fuel/core/HttpException.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/HttpException.kt @@ -1,4 +1,4 @@ -package fuel.core +package com.github.kittinunf.fuel.core /** * Created by Kittinun Vantasin on 8/17/15. diff --git a/fuel/src/main/kotlin/fuel/core/Manager.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Manager.kt similarity index 95% rename from fuel/src/main/kotlin/fuel/core/Manager.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Manager.kt index c442d20b2..626cd5115 100644 --- a/fuel/src/main/kotlin/fuel/core/Manager.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Manager.kt @@ -1,8 +1,8 @@ -package fuel.core +package com.github.kittinunf.fuel.core -import fuel.Fuel -import fuel.toolbox.HttpClient -import fuel.util.readWriteLazy +import com.github.kittinunf.fuel.Fuel +import com.github.kittinunf.fuel.toolbox.HttpClient +import com.github.kittinunf.fuel.util.readWriteLazy import java.util.concurrent.Executor import java.util.concurrent.ExecutorService import java.util.concurrent.Executors diff --git a/fuel/src/main/kotlin/fuel/core/Method.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Method.kt similarity index 83% rename from fuel/src/main/kotlin/fuel/core/Method.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Method.kt index ca728df21..8a6a8cf3f 100644 --- a/fuel/src/main/kotlin/fuel/core/Method.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Method.kt @@ -1,4 +1,4 @@ -package fuel.core +package com.github.kittinunf.fuel.core /** * Created by Kittinun Vantasin on 5/13/15. diff --git a/fuel/src/main/kotlin/fuel/core/Request.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Request.kt similarity index 96% rename from fuel/src/main/kotlin/fuel/core/Request.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Request.kt index 38fc7cb6a..c5ab2100f 100644 --- a/fuel/src/main/kotlin/fuel/core/Request.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Request.kt @@ -1,9 +1,9 @@ -package fuel.core +package com.github.kittinunf.fuel.core -import fuel.util.Base64 -import fuel.util.copyTo -import fuel.util.readWriteLazy -import fuel.util.toHexString +import com.github.kittinunf.fuel.util.Base64 +import com.github.kittinunf.fuel.util.copyTo +import com.github.kittinunf.fuel.util.readWriteLazy +import com.github.kittinunf.fuel.util.toHexString import java.io.* import java.net.URL import java.net.URLConnection @@ -161,15 +161,15 @@ public class Request { //byte array public fun response(handler: (Request, Response, Either) -> Unit): Unit = - response(Request.byteArrayDeserializer(), handler) + response(byteArrayDeserializer(), handler) - public fun response(handler: Handler): Unit = response(Request.byteArrayDeserializer(), handler) + public fun response(handler: Handler): Unit = response(byteArrayDeserializer(), handler) //string public fun responseString(handler: (Request, Response, Either) -> Unit): Unit = - response(Request.stringDeserializer(), handler) + response(stringDeserializer(), handler) - public fun responseString(handler: Handler): Unit = response(Request.stringDeserializer(), handler) + public fun responseString(handler: Handler): Unit = response(stringDeserializer(), handler) //object public fun responseObject(deserializer: ResponseDeserializable, handler: (Request, Response, Either) -> Unit): Unit = response(deserializer, handler) diff --git a/fuel/src/main/kotlin/fuel/core/Response.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Response.kt similarity index 96% rename from fuel/src/main/kotlin/fuel/core/Response.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Response.kt index e3c577ab8..f2d71a188 100644 --- a/fuel/src/main/kotlin/fuel/core/Response.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Response.kt @@ -1,4 +1,4 @@ -package fuel.core +package com.github.kittinunf.fuel.core import java.net.URL import kotlin.properties.Delegates diff --git a/fuel/src/main/kotlin/fuel/toolbox/HttpClient.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/toolbox/HttpClient.kt similarity index 91% rename from fuel/src/main/kotlin/fuel/toolbox/HttpClient.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/toolbox/HttpClient.kt index 090528044..38d62f563 100644 --- a/fuel/src/main/kotlin/fuel/toolbox/HttpClient.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/toolbox/HttpClient.kt @@ -1,16 +1,13 @@ -package fuel.toolbox +package com.github.kittinunf.fuel.toolbox -import fuel.core.* +import com.github.kittinunf.fuel.core.* import java.io.BufferedOutputStream import java.io.IOException import java.net.HttpURLConnection import java.security.SecureRandom import java.security.cert.X509Certificate import java.util.zip.GZIPInputStream -import javax.net.ssl.HttpsURLConnection -import javax.net.ssl.SSLContext -import javax.net.ssl.SSLSocketFactory -import javax.net.ssl.X509TrustManager +import javax.net.ssl.* /** * Created by Kittinun Vantasin on 5/15/15. @@ -21,9 +18,12 @@ class HttpClient(val sslSocketFactory: SSLSocketFactory = defaultSocketFactory() override fun executeRequest(request: Request): Response { val connection = if (request.url.protocol.equals("https")) { val conn = request.url.openConnection() as HttpsURLConnection - conn.sslSocketFactory = sslSocketFactory - conn.setHostnameVerifier { s, SSLSession -> true } - conn + conn.apply { + this.sslSocketFactory = sslSocketFactory + hostnameVerifier = object : HostnameVerifier { + override fun verify(hostname: String?, session: SSLSession?) = true + } + } } else { request.url.openConnection() as HttpURLConnection } diff --git a/fuel/src/main/kotlin/fuel/util/Delegates.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/util/Delegates.kt similarity index 95% rename from fuel/src/main/kotlin/fuel/util/Delegates.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/util/Delegates.kt index 459cc3b76..49ce477f6 100644 --- a/fuel/src/main/kotlin/fuel/util/Delegates.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/util/Delegates.kt @@ -1,4 +1,4 @@ -package fuel.util +package com.github.kittinunf.fuel.util import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty diff --git a/fuel/src/main/kotlin/fuel/util/InputStreams.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/util/InputStreams.kt similarity index 92% rename from fuel/src/main/kotlin/fuel/util/InputStreams.kt rename to fuel/src/main/kotlin/com/github/kittinunf/fuel/util/InputStreams.kt index 564022e3a..9df0ab6de 100644 --- a/fuel/src/main/kotlin/fuel/util/InputStreams.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/util/InputStreams.kt @@ -1,4 +1,4 @@ -package fuel.util +package com.github.kittinunf.fuel.util import java.io.InputStream import java.io.OutputStream diff --git a/fuel/src/main/kotlin/com/github/kittinunf/fuel/util/Longs.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/util/Longs.kt new file mode 100644 index 000000000..16924cd69 --- /dev/null +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/util/Longs.kt @@ -0,0 +1,7 @@ +package com.github.kittinunf.fuel.util + +/** + * Created by Kittinun Vantasin on 6/18/15. + */ + +public fun Long.toHexString(): String = java.lang.Long.toHexString(this) diff --git a/fuel/src/main/kotlin/fuel/util/Longs.kt b/fuel/src/main/kotlin/fuel/util/Longs.kt deleted file mode 100644 index dd4f7f481..000000000 --- a/fuel/src/main/kotlin/fuel/util/Longs.kt +++ /dev/null @@ -1,9 +0,0 @@ -package fuel.util - -/** - * Created by Kittinun Vantasin on 6/18/15. - */ - -fun Long.toHexString(): String { - return java.lang.Long.toHexString(this) -} diff --git a/fuel/src/test/kotlin/fuel/BaseTestCase.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/BaseTestCase.kt similarity index 90% rename from fuel/src/test/kotlin/fuel/BaseTestCase.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/BaseTestCase.kt index 3e7488cd4..8206f389e 100644 --- a/fuel/src/test/kotlin/fuel/BaseTestCase.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/BaseTestCase.kt @@ -1,4 +1,4 @@ -package fuel +package com.github.kittinunf.fuel import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit diff --git a/fuel/src/test/kotlin/fuel/EncodingTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/EncodingTest.kt similarity index 75% rename from fuel/src/test/kotlin/fuel/EncodingTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/EncodingTest.kt index b1b426cf7..c854f1b25 100644 --- a/fuel/src/test/kotlin/fuel/EncodingTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/EncodingTest.kt @@ -1,7 +1,7 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.Encoding -import fuel.core.Method +import com.github.kittinunf.fuel.core.Encoding +import com.github.kittinunf.fuel.core.Method import org.junit.Before import org.junit.Test import java.util.concurrent.CountDownLatch @@ -27,7 +27,7 @@ public class EncodingTest : BaseTestCase() { parameters = listOf("a" to "b") }.request - assertTrue { "http://www.example.com/test?a=b" == request.url.toString() } + assertTrue { "http://www.example.com/test?a=b" == request.url.toString() } } @Test @@ -39,7 +39,7 @@ public class EncodingTest : BaseTestCase() { parameters = null }.request - assertTrue { "http://www.example.com/test" == request.url.toString() } + assertTrue { "http://www.example.com/test" == request.url.toString() } } @Test @@ -51,7 +51,7 @@ public class EncodingTest : BaseTestCase() { parameters = null }.request - assertTrue { "http://www.example.com/test" == request.url.toString() } + assertTrue { "http://www.example.com/test" == request.url.toString() } } @Test @@ -63,7 +63,7 @@ public class EncodingTest : BaseTestCase() { parameters = null }.request - assertTrue { "http://www.example.com/test?a=b" == request.url.toString() } + assertTrue { "http://www.example.com/test?a=b" == request.url.toString() } } } \ No newline at end of file diff --git a/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestAuthenticationTest.kt similarity index 97% rename from fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestAuthenticationTest.kt index f17370b5b..6d4298c5e 100644 --- a/fuel/src/test/kotlin/fuel/RequestAuthenticationTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestAuthenticationTest.kt @@ -1,6 +1,6 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.* import org.junit.Before import org.junit.Test import java.net.HttpURLConnection diff --git a/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestDownloadTest.kt similarity index 95% rename from fuel/src/test/kotlin/fuel/RequestDownloadTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestDownloadTest.kt index 395b52016..9c8b7b613 100644 --- a/fuel/src/test/kotlin/fuel/RequestDownloadTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestDownloadTest.kt @@ -1,9 +1,9 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.FuelError -import fuel.core.Manager -import fuel.core.Request -import fuel.core.Response +import com.github.kittinunf.fuel.core.FuelError +import com.github.kittinunf.fuel.core.Manager +import com.github.kittinunf.fuel.core.Request +import com.github.kittinunf.fuel.core.Response import org.junit.Before import org.junit.Test import java.io.File diff --git a/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestHandlerTest.kt similarity index 98% rename from fuel/src/test/kotlin/fuel/RequestHandlerTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestHandlerTest.kt index d2f246acf..19e438d86 100644 --- a/fuel/src/test/kotlin/fuel/RequestHandlerTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestHandlerTest.kt @@ -1,6 +1,6 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.* import org.junit.Before import org.junit.Test import java.net.HttpURLConnection diff --git a/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestHeaderTest.kt similarity index 93% rename from fuel/src/test/kotlin/fuel/RequestHeaderTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestHeaderTest.kt index 0b22f7dea..c36366ec8 100644 --- a/fuel/src/test/kotlin/fuel/RequestHeaderTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestHeaderTest.kt @@ -1,6 +1,6 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.* import org.junit.Before import org.junit.Test import java.net.HttpURLConnection @@ -55,7 +55,7 @@ class RequestHeaderTest : BaseTestCase() { assertNotNull(data, "data should not be null") val statusCode = HttpURLConnection.HTTP_OK - assertTrue(response?.httpStatusCode == statusCode, "http status code of valid request: $statusCode" ) + assertTrue(response?.httpStatusCode == statusCode, "http status code of valid request: $statusCode") val string = String(data as ByteArray) assertTrue(string.contains(headerKey) && string.contains(headerValue), "header should be sent along with request header and present in response of httpbin.org") diff --git a/fuel/src/test/kotlin/fuel/RequestObjectTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestObjectTest.kt similarity index 97% rename from fuel/src/test/kotlin/fuel/RequestObjectTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestObjectTest.kt index 3da3a08c2..68c504570 100644 --- a/fuel/src/test/kotlin/fuel/RequestObjectTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestObjectTest.kt @@ -1,6 +1,6 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.* import org.junit.Before import org.junit.Test import java.io.Reader diff --git a/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestPathStringConvertibleExtensionTest.kt similarity index 96% rename from fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestPathStringConvertibleExtensionTest.kt index c61d81707..a34ea6f6e 100644 --- a/fuel/src/test/kotlin/fuel/RequestPathStringConvertibleExtensionTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestPathStringConvertibleExtensionTest.kt @@ -1,9 +1,9 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.FuelError -import fuel.core.Manager -import fuel.core.Request -import fuel.core.Response +import com.github.kittinunf.fuel.core.FuelError +import com.github.kittinunf.fuel.core.Manager +import com.github.kittinunf.fuel.core.Request +import com.github.kittinunf.fuel.core.Response import org.junit.Before import org.junit.Test import java.io.File diff --git a/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestSharedInstanceTest.kt similarity index 99% rename from fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestSharedInstanceTest.kt index 7d156a4a3..92a81513b 100644 --- a/fuel/src/test/kotlin/fuel/RequestSharedInstanceTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestSharedInstanceTest.kt @@ -1,6 +1,6 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.* import org.junit.Before import org.junit.Test import java.io.File diff --git a/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestStringExtensionTest.kt similarity index 96% rename from fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestStringExtensionTest.kt index ec56eaaf4..80a61e01a 100644 --- a/fuel/src/test/kotlin/fuel/RequestStringExtensionTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestStringExtensionTest.kt @@ -1,6 +1,6 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.* import org.junit.Before import org.junit.Test import java.io.File @@ -52,7 +52,7 @@ class RequestStringExtensionTest : BaseTestCase() { assertNotNull(data, "data should not be null") val statusCode = HttpURLConnection.HTTP_OK - assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode" ) + assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode") } @Test @@ -80,7 +80,7 @@ class RequestStringExtensionTest : BaseTestCase() { assertNotNull(data, "data should not be null") val statusCode = HttpURLConnection.HTTP_OK - assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode" ) + assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode") } @Test @@ -108,7 +108,7 @@ class RequestStringExtensionTest : BaseTestCase() { assertNotNull(data, "data should not be null") val statusCode = HttpURLConnection.HTTP_OK - assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode" ) + assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode") } @Test @@ -136,7 +136,7 @@ class RequestStringExtensionTest : BaseTestCase() { assertNotNull(data, "data should not be null") val statusCode = HttpURLConnection.HTTP_OK - assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode" ) + assertTrue(response?.httpStatusCode == statusCode, "http status code should be $statusCode") } @Test diff --git a/fuel/src/test/kotlin/fuel/RequestTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestTest.kt similarity index 99% rename from fuel/src/test/kotlin/fuel/RequestTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestTest.kt index 4723952ac..9272ada79 100644 --- a/fuel/src/test/kotlin/fuel/RequestTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestTest.kt @@ -1,6 +1,6 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.* import org.junit.Before import org.junit.Test import java.net.HttpURLConnection diff --git a/fuel/src/test/kotlin/fuel/RequestUploadTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestUploadTest.kt similarity index 98% rename from fuel/src/test/kotlin/fuel/RequestUploadTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestUploadTest.kt index 2da39d39f..6e6ae3a0b 100644 --- a/fuel/src/test/kotlin/fuel/RequestUploadTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestUploadTest.kt @@ -1,6 +1,6 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.* import org.junit.Before import org.junit.Test import java.io.File diff --git a/fuel/src/test/kotlin/fuel/RequestValidationTest.kt b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestValidationTest.kt similarity index 97% rename from fuel/src/test/kotlin/fuel/RequestValidationTest.kt rename to fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestValidationTest.kt index 2821a635a..8692190f4 100644 --- a/fuel/src/test/kotlin/fuel/RequestValidationTest.kt +++ b/fuel/src/test/kotlin/com/github/kittinunf/fuel/RequestValidationTest.kt @@ -1,6 +1,6 @@ -package fuel +package com.github.kittinunf.fuel -import fuel.core.* +import com.github.kittinunf.fuel.core.* import org.junit.Before import org.junit.Test import java.util.concurrent.CountDownLatch diff --git a/sample-java/src/main/java/com/example/fuel/MainActivity.java b/sample-java/src/main/java/com/example/fuel/MainActivity.java index 5e57983e4..e33dab726 100644 --- a/sample-java/src/main/java/com/example/fuel/MainActivity.java +++ b/sample-java/src/main/java/com/example/fuel/MainActivity.java @@ -15,11 +15,11 @@ import java.util.ArrayList; import java.util.List; -import fuel.Fuel; -import fuel.core.FuelError; -import fuel.core.Handler; -import fuel.core.Request; -import fuel.core.Response; +import com.github.kittinunf.fuel.Fuel; +import com.github.kittinunf.fuel.core.FuelError; +import com.github.kittinunf.fuel.core.Handler; +import com.github.kittinunf.fuel.core.Request; +import com.github.kittinunf.fuel.core.Response; import kotlin.Pair; import kotlin.jvm.functions.Function2; diff --git a/sample/src/main/kotlin/com/example/fuel/MainActivity.kt b/sample/src/main/kotlin/com/example/fuel/MainActivity.kt index b5ac636cd..4aec28809 100644 --- a/sample/src/main/kotlin/com/example/fuel/MainActivity.kt +++ b/sample/src/main/kotlin/com/example/fuel/MainActivity.kt @@ -3,9 +3,9 @@ package com.example.fuel import android.os.Bundle import android.support.v7.app.AppCompatActivity import android.util.Log +import com.github.kittinunf.fuel.* +import com.github.kittinunf.fuel.core.* import com.google.gson.Gson -import fuel.* -import fuel.core.* import kotlinx.android.synthetic.activity_main.mainClearButton import kotlinx.android.synthetic.activity_main.mainGoButton import kotlinx.android.synthetic.activity_main.mainResultText From c5df6009a33a619dce72ea6db908b87b862befef Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Wed, 11 Nov 2015 19:02:20 +0700 Subject: [PATCH 09/16] Add publishing into fuel-android --- README.md | 2 +- fuel-android/build.gradle | 11 ++++++----- fuel/build.gradle | 11 ++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a5409fb65..f3ccf40cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fuel -[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1103-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel) [![Coverage Status](https://coveralls.io/repos/kittinunf/Fuel/badge.svg?branch=master&service=github)](https://coveralls.io/github/kittinunf/Fuel?branch=master) +[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1103-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel) The easiest HTTP networking library in Kotlin for Android. diff --git a/fuel-android/build.gradle b/fuel-android/build.gradle index 6bfa7f20f..4040109a5 100644 --- a/fuel-android/build.gradle +++ b/fuel-android/build.gradle @@ -74,10 +74,11 @@ buildscript { } publish { - groupId = '' - artifactId = '' - uploadName = '' - version = android.defaultConfig.versionName - desc = '' + artifactId = 'fuel-android' + autoPublish = false + desc = 'The easiest HTTP networking library for Android' + groupId = 'com.github.kittinunf.fuel' + publishVersion = android.defaultConfig.versionName + uploadName = 'Fuel-Android' website = 'https://github.com/kittinunf/Fuel' } diff --git a/fuel/build.gradle b/fuel/build.gradle index 477c6a814..e65d9e054 100644 --- a/fuel/build.gradle +++ b/fuel/build.gradle @@ -36,10 +36,11 @@ buildscript { } publish { - groupId = '' - artifactId = '' - uploadName = '' - version = '0.6' - desc = '' + artifactId = 'fuel' + autoPublish = false + desc = 'The easiest HTTP networking library for Kotlin' + groupId = 'com.github.kittinunf.fuel' + publishVersion = '0.6' + uploadName = 'Fuel' website = 'https://github.com/kittinunf/Fuel' } From f74f48d9decfc8ed98bcbd6e8c4680d7c5017bc6 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Wed, 11 Nov 2015 19:06:33 +0700 Subject: [PATCH 10/16] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3ccf40cc..44b6f2dbc 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ buildscript { } dependencies { - compile 'fuel:fuel:0.6' + compile 'com.github.kittinunf.fuel:fuel:0.6' //for JVM + compile 'com.github.kittinunf.fuel:fuel-android:0.6' //for Android } ``` From a2737eb76d138015c471f3256c12c977a7786d95 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Thu, 12 Nov 2015 00:52:08 +0700 Subject: [PATCH 11/16] Fix encoding problem a bit more --- .../com/github/kittinunf/fuel/core/Encoding.kt | 14 +++++++++----- .../main/kotlin/com/example/fuel/MainActivity.kt | 5 ++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Encoding.kt b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Encoding.kt index 9f9cb1fbd..eb8b0b880 100644 --- a/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Encoding.kt +++ b/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Encoding.kt @@ -2,6 +2,7 @@ package com.github.kittinunf.fuel.core import com.github.kittinunf.fuel.Fuel import com.github.kittinunf.fuel.util.toHexString +import java.net.MalformedURLException import java.net.URI import java.net.URL import java.net.URLEncoder @@ -58,11 +59,14 @@ public class Encoding : Fuel.RequestConvertible { override val request by lazy { encoder(httpMethod, urlString, parameters) } private fun createUrl(path: String): URL { - val pathUri = URI(path) - //give precedence to local path - if (baseUrlString == null || pathUri.scheme != null) return URL(path) - - return URL(baseUrlString + if (path.startsWith('/') or path.isEmpty()) path else '/' + path) + val url = try { + //give precedence to local path + URL(path) + } catch (e: MalformedURLException) { + URL(baseUrlString + if (path.startsWith('/') or path.isEmpty()) path else '/' + path) + } + val uri = URI(url.protocol, url.userInfo, url.host, url.port, url.path, url.query, url.ref) + return uri.toURL() } private fun encodeParameterInUrl(method: Method): Boolean { diff --git a/sample/src/main/kotlin/com/example/fuel/MainActivity.kt b/sample/src/main/kotlin/com/example/fuel/MainActivity.kt index 4aec28809..4c219b4a2 100644 --- a/sample/src/main/kotlin/com/example/fuel/MainActivity.kt +++ b/sample/src/main/kotlin/com/example/fuel/MainActivity.kt @@ -11,7 +11,6 @@ import kotlinx.android.synthetic.activity_main.mainGoButton import kotlinx.android.synthetic.activity_main.mainResultText import java.io.File import java.io.Reader -import java.net.URLEncoder public class MainActivity : AppCompatActivity() { @@ -127,8 +126,8 @@ public class MainActivity : AppCompatActivity() { } fun httpBasicAuthentication() { - val username = URLEncoder.encode("username", "UTF-8") - val password = URLEncoder.encode("1234567890", "UTF-8") + val username = "username" + val password = "P@s\$vv0R|)" Fuel.get("/basic-auth/$username/$password").authenticate(username, password).responseString { request, response, either -> Log.d(TAG, request.toString()) updateUI(response, either) From d96d4bf581f6359682c30dcb66e13a70eaa621a8 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Thu, 12 Nov 2015 20:14:08 +0700 Subject: [PATCH 12/16] Rename, finalize build and add jcenter push --- build.gradle | 4 ++++ fuel-android/build.gradle | 8 ++++---- fuel-android/src/main/AndroidManifest.xml | 2 +- .../fuel/{ => android}/extension/Requests.kt | 10 ++-------- .../fuel/{ => android}/util/AndroidEnvironment.kt | 2 +- .../github/kittinunf}/fuel/android/BaseTestCase.kt | 2 +- .../fuel/android/RequestAndroidHandlerTest.kt | 13 ++++--------- fuel/build.gradle | 4 ++-- gradle.properties | 4 +++- settings.gradle | 5 ++++- 10 files changed, 26 insertions(+), 28 deletions(-) rename fuel-android/src/main/kotlin/com/github/kittinunf/fuel/{ => android}/extension/Requests.kt (61%) rename fuel-android/src/main/kotlin/com/github/kittinunf/fuel/{ => android}/util/AndroidEnvironment.kt (90%) rename fuel-android/src/test/kotlin/{ => com/github/kittinunf}/fuel/android/BaseTestCase.kt (93%) rename fuel-android/src/test/kotlin/{ => com/github/kittinunf}/fuel/android/RequestAndroidHandlerTest.kt (95%) diff --git a/build.gradle b/build.gradle index a1e13fa1f..a94d70e89 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,10 @@ buildscript { } allprojects { + ext { + publishVersion = '0.6' + } + repositories { jcenter() } diff --git a/fuel-android/build.gradle b/fuel-android/build.gradle index 4040109a5..a47efa185 100644 --- a/fuel-android/build.gradle +++ b/fuel-android/build.gradle @@ -15,7 +15,7 @@ android { minSdkVersion 9 targetSdkVersion 23 versionCode 1 - versionName "0.6" + versionName parent.ext.publishVersion } sourceSets { @@ -76,9 +76,9 @@ buildscript { publish { artifactId = 'fuel-android' autoPublish = false - desc = 'The easiest HTTP networking library for Android' + desc = 'The easiest HTTP networking library in Kotlin for Android' groupId = 'com.github.kittinunf.fuel' - publishVersion = android.defaultConfig.versionName - uploadName = 'Fuel-Android' + publishVersion = parent.ext.publishVersion + uploadName = 'Fuel' website = 'https://github.com/kittinunf/Fuel' } diff --git a/fuel-android/src/main/AndroidManifest.xml b/fuel-android/src/main/AndroidManifest.xml index e8d13779b..4d6d9bc22 100644 --- a/fuel-android/src/main/AndroidManifest.xml +++ b/fuel-android/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - + diff --git a/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/extension/Requests.kt b/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/android/extension/Requests.kt similarity index 61% rename from fuel-android/src/main/kotlin/com/github/kittinunf/fuel/extension/Requests.kt rename to fuel-android/src/main/kotlin/com/github/kittinunf/fuel/android/extension/Requests.kt index 597422f4c..adcb106dd 100644 --- a/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/extension/Requests.kt +++ b/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/android/extension/Requests.kt @@ -1,12 +1,6 @@ -package com.github.kittinunf.fuel.extension +package com.github.kittinunf.fuel.android.extension -import com.github.kittinunf.fuel.core.Deserializable -import com.github.kittinunf.fuel.core.Either -import com.github.kittinunf.fuel.core.FuelError -import com.github.kittinunf.fuel.core.Handler -import com.github.kittinunf.fuel.core.Request -import com.github.kittinunf.fuel.core.Response -import com.github.kittinunf.fuel.core.response +import com.github.kittinunf.fuel.core.* import org.json.JSONObject /** diff --git a/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/util/AndroidEnvironment.kt b/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/android/util/AndroidEnvironment.kt similarity index 90% rename from fuel-android/src/main/kotlin/com/github/kittinunf/fuel/util/AndroidEnvironment.kt rename to fuel-android/src/main/kotlin/com/github/kittinunf/fuel/android/util/AndroidEnvironment.kt index 8b95ad93e..be82d768d 100644 --- a/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/util/AndroidEnvironment.kt +++ b/fuel-android/src/main/kotlin/com/github/kittinunf/fuel/android/util/AndroidEnvironment.kt @@ -1,4 +1,4 @@ -package com.github.kittinunf.fuel.util +package com.github.kittinunf.fuel.android.util import android.os.Handler import android.os.Looper diff --git a/fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt b/fuel-android/src/test/kotlin/com/github/kittinunf/fuel/android/BaseTestCase.kt similarity index 93% rename from fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt rename to fuel-android/src/test/kotlin/com/github/kittinunf/fuel/android/BaseTestCase.kt index d43a26f9f..fba5807f6 100644 --- a/fuel-android/src/test/kotlin/fuel/android/BaseTestCase.kt +++ b/fuel-android/src/test/kotlin/com/github/kittinunf/fuel/android/BaseTestCase.kt @@ -1,4 +1,4 @@ -package fuel.android +package com.github.kittinunf.fuel.android import org.junit.runner.RunWith import org.robolectric.RobolectricGradleTestRunner diff --git a/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt b/fuel-android/src/test/kotlin/com/github/kittinunf/fuel/android/RequestAndroidHandlerTest.kt similarity index 95% rename from fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt rename to fuel-android/src/test/kotlin/com/github/kittinunf/fuel/android/RequestAndroidHandlerTest.kt index 6d337261e..78bfa9421 100644 --- a/fuel-android/src/test/kotlin/fuel/android/RequestAndroidHandlerTest.kt +++ b/fuel-android/src/test/kotlin/com/github/kittinunf/fuel/android/RequestAndroidHandlerTest.kt @@ -1,13 +1,8 @@ -package fuel.android - -import com.github.kittinunf.fuel.core.FuelError -import com.github.kittinunf.fuel.core.Handler -import com.github.kittinunf.fuel.core.Manager -import com.github.kittinunf.fuel.core.Request -import com.github.kittinunf.fuel.core.Response -import com.github.kittinunf.fuel.core.ResponseDeserializable -import com.github.kittinunf.fuel.extension.responseJson +package com.github.kittinunf.fuel.android + import com.github.kittinunf.fuel.Fuel +import com.github.kittinunf.fuel.android.extension.responseJson +import com.github.kittinunf.fuel.core.* import org.json.JSONObject import org.junit.Before import org.junit.Test diff --git a/fuel/build.gradle b/fuel/build.gradle index e65d9e054..2f5217f03 100644 --- a/fuel/build.gradle +++ b/fuel/build.gradle @@ -38,9 +38,9 @@ buildscript { publish { artifactId = 'fuel' autoPublish = false - desc = 'The easiest HTTP networking library for Kotlin' + desc = 'The easiest HTTP networking library in Kotlin' groupId = 'com.github.kittinunf.fuel' - publishVersion = '0.6' + publishVersion = parent.ext.publishVersion uploadName = 'Fuel' website = 'https://github.com/kittinunf/Fuel' } diff --git a/gradle.properties b/gradle.properties index 2c1f15099..a43597000 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,4 +15,6 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -org.gradle.parallel=true \ No newline at end of file +org.gradle.parallel=true + +org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 8021c9191..e00fc33ed 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,4 @@ -include ':sample', ':fuel', ':sample-java', ':fuel-android' +include ':fuel', + ':fuel-android', + ':sample', + ':sample-java' From a07238f743e9e306bcbdfcf5fc2648cc270ed9e2 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Thu, 12 Nov 2015 20:18:53 +0700 Subject: [PATCH 13/16] Remove gradle javahome hard coded --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a43597000..24d66003e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,4 +17,4 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects org.gradle.parallel=true -org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home \ No newline at end of file +#org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home \ No newline at end of file From 24073f63610e4b9a37291fac56c8368fa971d1b2 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Mon, 16 Nov 2015 10:59:36 +0700 Subject: [PATCH 14/16] Remove gradle.properties, push to jcenter again --- .gitignore | 1 + fuel-android/build.gradle | 7 ++++--- fuel/build.gradle | 7 ++++--- gradle.properties | 20 -------------------- 4 files changed, 9 insertions(+), 26 deletions(-) delete mode 100644 gradle.properties diff --git a/.gitignore b/.gitignore index b24a941f1..94d3d61e5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ gen/ # Local configuration file (sdk path, etc) local.properties +gradle.properties # Eclipse project files .classpath diff --git a/fuel-android/build.gradle b/fuel-android/build.gradle index a47efa185..4923496c7 100644 --- a/fuel-android/build.gradle +++ b/fuel-android/build.gradle @@ -75,10 +75,11 @@ buildscript { publish { artifactId = 'fuel-android' - autoPublish = false - desc = 'The easiest HTTP networking library in Kotlin for Android' + autoPublish = true + desc = 'The easiest HTTP networking library in Kotlin/Android' groupId = 'com.github.kittinunf.fuel' + licences = ['MIT'] publishVersion = parent.ext.publishVersion - uploadName = 'Fuel' + uploadName = 'fuel' website = 'https://github.com/kittinunf/Fuel' } diff --git a/fuel/build.gradle b/fuel/build.gradle index 2f5217f03..52770f7dc 100644 --- a/fuel/build.gradle +++ b/fuel/build.gradle @@ -37,10 +37,11 @@ buildscript { publish { artifactId = 'fuel' - autoPublish = false - desc = 'The easiest HTTP networking library in Kotlin' + autoPublish = true + desc = 'The easiest HTTP networking library in Kotlin/Android' groupId = 'com.github.kittinunf.fuel' + licences = ['MIT'] publishVersion = parent.ext.publishVersion - uploadName = 'Fuel' + uploadName = 'fuel' website = 'https://github.com/kittinunf/Fuel' } diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 24d66003e..000000000 --- a/gradle.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html - -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m -org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 - -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -org.gradle.parallel=true - -#org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home \ No newline at end of file From f73de4ffd94498d4369f96f84f96a7062218ada9 Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Mon, 16 Nov 2015 11:21:31 +0700 Subject: [PATCH 15/16] Use uploadname as fuel-android --- fuel-android/build.gradle | 2 +- fuel/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fuel-android/build.gradle b/fuel-android/build.gradle index 4923496c7..9b697b54a 100644 --- a/fuel-android/build.gradle +++ b/fuel-android/build.gradle @@ -80,6 +80,6 @@ publish { groupId = 'com.github.kittinunf.fuel' licences = ['MIT'] publishVersion = parent.ext.publishVersion - uploadName = 'fuel' + uploadName = 'Fuel-Android' website = 'https://github.com/kittinunf/Fuel' } diff --git a/fuel/build.gradle b/fuel/build.gradle index 52770f7dc..395264039 100644 --- a/fuel/build.gradle +++ b/fuel/build.gradle @@ -42,6 +42,6 @@ publish { groupId = 'com.github.kittinunf.fuel' licences = ['MIT'] publishVersion = parent.ext.publishVersion - uploadName = 'fuel' + uploadName = 'Fuel-Android' website = 'https://github.com/kittinunf/Fuel' } From 5cda4e50eea2cf62481dc57daadafde833b084cf Mon Sep 17 00:00:00 2001 From: Kittinun Vantasin Date: Mon, 16 Nov 2015 11:26:58 +0700 Subject: [PATCH 16/16] Update badge to reflect with new repo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44b6f2dbc..e435017aa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fuel -[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1103-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel) +[ ![Kotlin](https://img.shields.io/badge/Kotlin-1.0.0--beta--1103-blue.svg)](http://kotlinlang.org) [ ![jcenter](https://api.bintray.com/packages/kittinunf/maven/Fuel-Android/images/download.svg) ](https://bintray.com/kittinunf/maven/Fuel-Android/_latestVersion) [![Build Status](https://travis-ci.org/kittinunf/Fuel.svg?branch=master)](https://travis-ci.org/kittinunf/Fuel) The easiest HTTP networking library in Kotlin for Android.