Skip to content

Commit

Permalink
Merge pull request #27 from speekha/develop
Browse files Browse the repository at this point in the history
Publish 1.1.3
  • Loading branch information
speekha authored Jul 2, 2019
2 parents 3ff270c + 5eff168 commit 8da4a13
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 149 deletions.
28 changes: 17 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ commands:
- source-
- checkout
- restore_cache:
key: gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "demo/build.gradle" }}-{{ checksum "mocker/build.gradle" }}-{{ checksum "jackson-adapter/build.gradle" }}-{{ checksum "gson-adapter/build.gradle" }}-{{ checksum "moshi-adapter/build.gradle" }}-{{ checksum "custom-adapter/build.gradle" }}
keys:
- jars-{{ checksum "build.gradle" }}-{{ checksum "demo/build.gradle" }}-{{ checksum "mocker/build.gradle" }}-{{ checksum "jackson-adapter/build.gradle" }}-{{ checksum "gson-adapter/build.gradle" }}-{{ checksum "moshi-adapter/build.gradle" }}-{{ checksum "custom-adapter/build.gradle" }}
- gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- restore_cache:
keys:
- build-mocker-{{ .Branch }}-{{ .Revision }}
Expand All @@ -41,9 +41,9 @@ jobs:
- source-{{ .Branch }}-{{ .Revision }}
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "demo/build.gradle" }}-{{ checksum "mocker/build.gradle" }}-{{ checksum "jackson-adapter/build.gradle" }}-{{ checksum "gson-adapter/build.gradle" }}-{{ checksum "moshi-adapter/build.gradle" }}-{{ checksum "custom-adapter/build.gradle" }}
- restore_cache:
key: gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
keys:
- jars-{{ checksum "build.gradle" }}-{{ checksum "demo/build.gradle" }}-{{ checksum "mocker/build.gradle" }}-{{ checksum "jackson-adapter/build.gradle" }}-{{ checksum "gson-adapter/build.gradle" }}-{{ checksum "moshi-adapter/build.gradle" }}-{{ checksum "custom-adapter/build.gradle" }}
- gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies --stacktrace
Expand Down Expand Up @@ -115,9 +115,9 @@ jobs:
- source-
- checkout
- restore_cache:
key: gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "demo/build.gradle" }}-{{ checksum "mocker/build.gradle" }}-{{ checksum "jackson-adapter/build.gradle" }}-{{ checksum "gson-adapter/build.gradle" }}-{{ checksum "moshi-adapter/build.gradle" }}-{{ checksum "custom-adapter/build.gradle" }}
keys:
- jars-{{ checksum "build.gradle" }}-{{ checksum "demo/build.gradle" }}-{{ checksum "mocker/build.gradle" }}-{{ checksum "jackson-adapter/build.gradle" }}-{{ checksum "gson-adapter/build.gradle" }}-{{ checksum "moshi-adapter/build.gradle" }}-{{ checksum "custom-adapter/build.gradle" }}
- gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- restore_cache:
keys:
- build-mocker-{{ .Branch }}-{{ .Revision }}
Expand Down Expand Up @@ -209,13 +209,18 @@ jobs:
destination: reports
- store_test_results:
path: tests/build/test-results
- save_cache:
key: build-{{ .Branch }}-{{ .Revision }}
paths:
- "."
publish_snapshot:
docker:
- image: circleci/android:api-28
steps:
- restore_cache:
key: build-{{ .Branch }}-{{ .Revision }}
- checkout
- restore_cache:
key: gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- run:
name: Publish
command: ./publishSnapshot.sh ${BINTRAY_USER} ${BINTRAY_APIKEY}
Expand All @@ -225,7 +230,8 @@ jobs:
steps:
- restore_cache:
key: build-{{ .Branch }}-{{ .Revision }}
- checkout
- restore_cache:
key: gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- run:
name: Publish
command: ./publish.sh ${BINTRAY_USER} ${BINTRAY_APIKEY}
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ configuration files instead. The interceptor will also allow to record scenarios
## Current Version

```gradle
httpmocker_version = '1.1.2'
httpmocker_version = '1.1.3'
```

## Gradle
Expand Down Expand Up @@ -43,6 +43,8 @@ repositories {

### Dependencies

#### Adding HttpMocker

This library contains two parts: a core module handling the mock logic, and an additional adapter to parse the scenario
files for static mocks. Currently, there are four possible options that are provided for parsing, based on three of the
most commonly used libraries for JSON parsing (Jackson, Gson, Moshi) and a custom implementation (no third party dependency),
Expand All @@ -52,26 +54,32 @@ your classpath, like Jackson and GSON). If you choose one of these options, all

```gradle
// Parses JSON scenarios using Jackson
implementation "fr.speekha.httpmocker:jackson-adapter:1.1.2"
implementation "fr.speekha.httpmocker:jackson-adapter:1.1.3"
// Parses JSON scenarios using Gson
implementation "fr.speekha.httpmocker:gson-adapter:1.1.2"
implementation "fr.speekha.httpmocker:gson-adapter:1.1.3"
// Parses JSON scenarios using Moshi
implementation "fr.speekha.httpmocker:moshi-adapter:1.1.2"
implementation "fr.speekha.httpmocker:moshi-adapter:1.1.3"
// Parses JSON scenarios using a custom JSON parser
implementation "fr.speekha.httpmocker:custom-adapter:1.1.2"
implementation "fr.speekha.httpmocker:custom-adapter:1.1.3"
```

If none of those options suits your needs or if you would prefer to only use dynamic mocks, you can add
the main dependency to your project (using static mocks will require that you provide your own implementation
of the `Mapper` class):

```gradle
implementation "fr.speekha.httpmocker:mocker:1.1.2"
implementation "fr.speekha.httpmocker:mocker:1.1.3"
```

#### External dependencies

* HttpMocker is a mocking library for OkHttp connections, so it depends on OkHttp 3.14.2.
* It also depends on the SLF4J API for logging.
* JSON parsers depend on their respective external libraries: Jackson 2.9.9, Gson 2.8.5 or Moshi 1.8.0

### Proguard rules

Since Jackson and Gson use some type of introspection or annotation processing to parse JSON streams, it
Expand Down Expand Up @@ -101,8 +109,7 @@ it will need to find scenarios to mock the HTTP calls. Dynamic mocks imply that
provide the response for each request programmatically, which allows you to define stateful
responses (identical calls could lead to different answers based on what the user did in between
these calls). The response can be provided by implementing the `RequestCallback` interface or
simply provide a lambda function to do the computation. Several callbacks can be added to the
interceptor.
simply provide a lambda function to do the computation.

Another option is to use static mocks. Static mocks are scenarios stored as static files. Here is
an example for an Android app using static mocks, with a few more options:
Expand Down Expand Up @@ -133,6 +140,10 @@ specific modules so you can choose one based on the JSON library you already use
the risk for duplicate libraries serving the same purpose in your app. An implementation based on
a custom JSON parser that does not use any dependencies is also available.

Static and dynamic scenarios can be used together. Several dynamic callbacks can be added to the
interceptor, but only one static configuration is allowed. Dynamic callbacks will be used first to
find a suitable mock, and if none is found, the static configuration will be tested next.

If you choose the mixed mode, requests that can not be answered by a predefined scenario will
actually be executed. Hence the mixed mode: responses can come from a scenario file (or dynamic
mock) or from an actual HTTP call.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ buildscript {
allprojects {

ext {
httpmock_version = '1.1.2'
httpmock_version = '1.1.3'
}

group 'fr.speekha.httpmocker'
Expand Down
6 changes: 0 additions & 6 deletions custom-adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@

apply plugin: 'kotlin'

test {
options {
useJUnitPlatform()
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

Expand Down
3 changes: 1 addition & 2 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ android {
}
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
minifyEnabled false
}
release {
minifyEnabled true
Expand Down
2 changes: 2 additions & 0 deletions gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ext {
coroutines_version = '1.2.1'
support_version = '28.0.0'
jackson_version = '2.9.9'
gson_version = '2.8.5'
moshi_version = '1.8.0'
okhttp_version = '3.14.2'
retrofit_version = '2.6.0'
dokka_version = '0.9.18'
Expand Down
8 changes: 1 addition & 7 deletions gson-adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@

apply plugin: 'kotlin'

test {
options {
useJUnitPlatform()
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

api project(':mocker')

api 'com.google.code.gson:gson:2.8.5'
api "com.google.code.gson:gson:$gson_version"
}

apply from: '../gradle/dokka.gradle'
Expand Down
6 changes: 0 additions & 6 deletions jackson-adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@

apply plugin: 'kotlin'

test {
options {
useJUnitPlatform()
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

Expand Down
6 changes: 0 additions & 6 deletions mocker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@

apply plugin: 'kotlin'

test {
options {
useJUnitPlatform()
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
Expand Down
Loading

0 comments on commit 8da4a13

Please sign in to comment.