HTTP Server for Android Instrumentation tests

Related tags

Networking RESTMock
Overview

RESTMock

Android Arsenal Circle CI

REST API mocking made easy.

RESTMock is a library working on top of Square's okhttp/MockWebServer. It allows you to specify Hamcrest matchers to match HTTP requests and specify what response to return. It is as easy as:

RESTMockServer.whenGET(pathContains("users/andrzejchm"))
            .thenReturnFile(200, "users/andrzejchm.json");

Article

Table of contents

Setup

Here are the basic rules to set up RESTMock for Android

Step 1: Repository

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Step 2: Dependencies

Add the dependency

dependencies {
	androidTestImplementation 'com.github.andrzejchm.RESTMock:android:${LATEST_VERSION}' // see "Releases" tab for latest version
}

Step 3: Start the server

It's good to start server before the tested application starts, there are few methods:

a) RESTMockTestRunner

To make it simple you can just use the predefined RESTMockTestRunner in your UI tests. It extends AndroidJUnitRunner:

defaultConfig {
		...
    	testInstrumentationRunner 'io.appflate.restmock.android.RESTMockTestRunner'
    }
b) RESTMockServerStarter

If you have your custom test runner and you can't extend RESTMockTestRunner, you can always just call the RESTMockServerStarter. Actually RESTMockTestRunner is doing exactly the same thing:

public class MyAppTestRunner extends AndroidJUnitRunner {
	...
	@Override
	public void onCreate(Bundle arguments) {
		super.onCreate(arguments);
		RESTMockServerStarter.startSync(new AndroidAssetsFileParser(getContext()),new AndroidLogger());
		...
	}
	...
}

Step 4: Specify Mocks

a) Files

By default, the RESTMockTestRunner uses AndroidAssetsFileParser as a mocks file parser, which reads the files from the assets folder. To make them visible for the RESTMock you have to put them in the correct folder in your project, for example:

.../src/androidTest/assets/users/defunkt.json

This can be accessed like this:

RESTMockServer.whenGET(pathContains("users/defunkt"))
            .thenReturnFile(200, "users/defunkt.json");
b) Strings

If the response You wish to return is simple, you can just specify a string:

RESTMockServer.whenGET(pathContains("users/defunkt"))
            .thenReturnString(200, "{}");
c) MockResponse

If you wish to have a greater control over the response, you can pass the MockResponse

RESTMockServer.whenGET(pathContains("users/defunkt")).thenReturn(new MockResponse().setBody("").setResponseCode(401).addHeader("Header","Value"));
c) MockAnswer

You can always build dynamic MockResponses by using the RecordedRequest object

RESTMockServer.whenGET(pathContains("users/defunkt")).thenAnswer(new MockAnswer() {

            @Override
            public MockResponse answer(RecordedRequest request) {
                    return new MockResponse()
                            .setBody(request.getHeaders().get("header1"))
                            .setResponseCode(200);
            }
        });

Step 5: Request Matchers

You can either use some of the predefined matchers from RequestMatchers util class, or create your own. remember to extend from RequestMatcher

Step 6: Specify API Endpoint

The most important step, in order for your app to communicate with the testServer, you have to specify it as an endpoint for all your API calls. For that, you can use the RESTMockServer.getUrl(). If you use Retrofit, it is as easy as:

RestAdapter adapter = new RestAdapter.Builder()
                .baseUrl(RESTMockServer.getUrl())
                ...
                .build();

take a look at #68 for better reference

HTTPS

By default, RESTMockServer will serve responses using Http. In order to use HTTPS, during initialization you have to pass RESTMockOptions object with useHttps set to true:

RESTMockServerStarter.startSync(new AndroidAssetsFileParser(getContext()),new AndroidLogger(), new RESTMockOptions.Builder().useHttps(true).build());

there is a possibility to set up your own SSLSocketFactory and TrustManager, if you do not specify those, then default ones will be created for you. You can easly retrieve them with RESTMockServer.getSSLSocketFactory() and RESTMockServer.getTrustManager() to be able to build your client that will accept the default certificate:

new OkHttpClient.Builder().sslSocketFactory(RESTMockServer.getSSLSocketFactory(), RESTMockServer.getTrustManager()).build();

A sample how to use https with RESTMock in android tests can be found in androidsample gradle module within this repository.

Response chains

You can chain different responses for a single request matcher, all the thenReturn*() methods accept varags parameter with response, or you can call those methods multiple times on a single matcher, examples:

RESTMockServer.whenGET(pathEndsWith(path))
                .thenReturnString("a single call")
                .thenReturnEmpty(200)
                .thenReturnFile("jsonFile.json");

or

RESTMockServer.whenGET(pathEndsWith(path))
                .thenReturnString("a single call", "answer no 2", "answer no 3");

Response body delays

Delaying responses is accomplished with the delayBody(TimeUnit timeUnit, long delay) and delayHeaders(TimeUnit timeUnit, long delay) method. Delays can be specified in chain, just like chaining responses:

RESTMockServer.whenGET(pathEndsWith(path))
                .thenReturnString("a single call")
                .delayBody(TimeUnit.SECONDS, 5)
                .delayBody(TimeUnit.SECONDS, 10)
                .delayBody(TimeUnit.SECONDS, 15);

or

RESTMockServer.whenGET(pathEndsWith(path))
                .thenReturnString("a single call")
                .delayBody(TimeUnit.SECONDS, 5, 10, 15);

Which will result in 1st response body being delayed by 5 seconds, 2nd response by 10 seconds and 3rd, 4th, 5th... by 15 seconds.

Response header delays

Mechanics of the responseHeader(...) method are the same as those in responseBody(...). The only difference is that response headers are being delivered with a delay. This comes handy if your app is acting on response headers, which would've been delivered immediately if you used the delayBody(...) method.

Interleaving delays with responses

Check out this example:

RESTMockServer.whenGET(pathEndsWith(path))
                .thenReturnString("1st call")
                .delay(TimeUnit.SECONDS, 5)
                .thenReturnString("2nd call")
                .delay(TimeUnit.SECONDS, 10)
                .delay(TimeUnit.SECONDS, 15)
                .thenReturnString("3rd call")
                .delay(TimeUnit.SECONDS, 20, 30, 40)

this will result in 1st call being delayed by 5 seconds, 2nd call delayed by 10 seconds, 3rd call delayed by 15 seconds, another one by 20 seconds, and another by 30 seconds, and then every consecutive response with 40 seconds delay

Request verification

It is possible to verify which requests were called and how many times thanks to RequestsVerifier. All you have to do is call one of these:

//cheks if the GET request was invoked exactly 2 times
RequestsVerifier.verifyGET(pathEndsWith("users")).exactly(2);

//cheks if the GET request was invoked at least 3 times
RequestsVerifier.verifyGET(pathEndsWith("users")).atLeast(3);

//cheks if the GET request was invoked exactly 1 time
RequestsVerifier.verifyGET(pathEndsWith("users")).invoked();

//cheks if the GET request was never invoked
RequestsVerifier.verifyGET(pathEndsWith("users")).never();

Additionaly, you can manualy inspect requests received by RESTMockServer. All you have to do is to obtain them trough:

//gets 5 most recent requests received. (ordered from oldest to newest)
RequestsVerifier.takeLast(5);

//gets 5 oldest requests received. (ordered from oldest to newest)
RequestsVerifier.takeFirst(5);

//gets all GET requests.  (ordered from oldest to newest)
RequestsVerifier.takeAllMatching(isGET());

Logging

RESTMock supports logging events. You just have to provide the RESTMock with the implementation of RESTMockLogger. For Android there is an AndroidLogger implemented already. All you have to do is use the RESTMockTestRunner or call

RESTMockServerStarter.startSync(new AndroidAssetsFileParser(getContext()),new AndroidLogger(), new RESTMockOptions());

or

RESTMockServer.enableLogging(RESTMockLogger)
RESTMockServer.disableLogging()

Android Sample Project

You can check out the sample Android app with tests here

Donation

If you think the library is awesome and want to buy me a beer, you can do so by sending some...

  • Ethereum ETH here: 0xf7354a0F7B34A380f6d68a2661bE465C10D6AEd7
  • Bitcoin BTC here: 12bU3BMibFqbBBymaftXTDnoHojFymD7a6
  • NEO NEO or GAS here: AX1ovzRN2N28WJrtehjYXjwtHSvcqva6Ri

License

Copyright (C) 2016 Appflate.io

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Update to latest OkHttp 3.12.1

    Update to latest OkHttp 3.12.1

    First off thanks for adding HTTPS support!

    When switching to use that today I hit this OkHttp bug: https://github.com/square/okhttp/issues/4183. I see that it got fixed in OkHttp 3.12.0: https://github.com/square/okhttp/pull/4373 I'd like to have that update here as well so I can switch to HTTPS.

    opened by tir38 8
  • Feature/query parameters

    Feature/query parameters

    Adds two methods: hasQueryParameters() and hasQueryParameters(AbstractMap.SimpleEntry<String, String> params...). The latter version checks whether the request has exactly the query parameters specified, whereas the former checks whether there are any parameters given at all.

    opened by jwir3 7
  • Add the ability to remove a mock using Matcher<RecordedRequest>

    Add the ability to remove a mock using Matcher

    There's two change here:

    Added an overload to removeMatchableCall that takes a parameter Matcher<RecordedRequest>

    whenRequested, now will remove the previously mock using the removeMatchableCall that takes requesteMatcher as a parameter.

    This PR is linked to #86

    opened by wellavelino 6
  • add new predefined matcher to check whether URL's path exactly matches another path

    add new predefined matcher to check whether URL's path exactly matches another path

    One more predefined matcher is being added to exactly compare two URL paths. Might be useful for the case when you need to distinguish paths like foo/bar/qwe and foo/bar or foo/bar/qwe and bar/qwe when startWith or endWith matchers are not helpful.

    Unit tests also added to cover new matcher.

    opened by int02h 5
  • Upgrading to OkHttp 4.0.0

    Upgrading to OkHttp 4.0.0

    I've upgraded my app to OkHttp 4.0.0 and I am no longer able to run RestMock tests. The app crashes with this error:

    java.lang.NoSuchMethodError: No static method initializeInstanceForTests()V in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in /data/app/???-Erfx_-ETp-Rrby47elr7mg==/base.apk!classes34.dex)
        at okhttp3.mockwebserver.MockWebServer.<clinit>(MockWebServer.java:105)
        at io.appflate.restmock.RESTMockServer.init(RESTMockServer.java:70)
        at io.appflate.restmock.RESTMockServerStarter$1.run(RESTMockServerStarter.java:56)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
    
    enhancement 
    opened by bizzguy 5
  • Allow multiple matchings for requests

    Allow multiple matchings for requests

    Hi!

    We've been using WireMock for a while now on our app, and we're happy with it. But it's sometimes too heavy for Android development, and this library seems like an awesome lightweight replacement for it. Congratulations!

    There's just one feature missing that stops us from adopting it, and it's having multiple matchings for a given request. For example having a very specific matching and a default fallback:

    /api/login -> login_error_response.json
    /api/login?user=me&pass=123 -> login_success_response.json
    

    In this case the first matching would also match the second request, and RESTMock will return a MORE_THAN_ONE_RESPONSE_ERROR.

    In WireMock the user can specify a priority value, and it will pick the highest one (the lower number means more priority). In my example, I would set a priority 2 for the default error, and priority 1 for the success case.

    Another approach would be to just pick the last one added. Both solutions are not mutually exclusive, although I think the one with priorities is more robust.

    What do you think about having this feature? I think it could be implemented as a withPriority(int) method on MatchableCall.

    enhancement 
    opened by Sloy 5
  • Unable to get RESTMock to work with external libraries of RESTapi

    Unable to get RESTMock to work with external libraries of RESTapi

    Hi, first of all I really admire the simplicity.

    but somehow I find it difficult to implement in my project. so my project consist of multiple libraries in which consist of multiple api call from each Library.

    I've followed all the guide given but still unable to mock the rest data (the RESTMock doesn't intercept the API call)

    defaultConfig {
    testInstrumentationRunner 'io.appflate.restmock.android.RESTMockTestRunner'
    }
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
        androidTestCompile 'com.android.support.test:runner:0.5'
        androidTestCompile 'com.android.support.test:rules:0.5'
        androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
        androidTestCompile ('com.github.andrzejchm.RESTMock:android:0.2.2') {
            exclude module: 'okhttp'
        } 
    

    exclude because of some conflict of versioning.

    In my test:

    public class SomeTest {
    
    @Rule
        public ActivityTestRule<LauncherActivity> mActivityTestRule = new
                ActivityTestRule<>(LauncherActivity.class);
    
    @Before
        public void startUp() {
            RESTMockServer.reset();
            retrofit = new Retrofit.Builder()
                    .baseUrl(RESTMockServer.getUrl())
                    .build();
        }
    
    @Test
        public void someTest() {
            RESTMockServer.whenPOST(RequestMatchers.pathContains("customer/password_reset"))
                    .thenReturnEmpty(200);
    // do something here and there
    }
    
    @After
        public void tearDown() throws Exception {
            HelperTool.clearApplicationData(context);
        }
    
    }
    

    Above are some part of the code, I'm using espresso as you can notice in my gradle. when I run the code, the logcat still showing me that it points to my backend server. instead of RESTMockServer.getUrl()

    Is there anything I missed here? Sorry still new in this

    opened by syariffudinzo 5
  • Delay not working

    Delay not working

    Hello, I've got a little issue with the delay method :

    The code

    Here is the code, in a jUnit test:

            RESTMockServer.whenRequested(pathContains(BernardAPI.LOGOUT))
                    .thenReturnString(200, "test response")
                    .delay(TimeUnit.SECONDS, 30);
            
            RESTMockServer.enableLogging(new RESTMockLogger() {
                @Override
                public void log(String message) {
                    String m = message;
                }
    
                @Override
                public void error(String errorMessage) {
                    String m = errorMessage;
                }
    
                @Override
                public void error(String errorMessage, Throwable exception) {
                    String m = errorMessage;
                }
            });
    
            Boolean result = bernardWebService.logout();
    

    I run it on debug mode and I have breakpoints in each of the RESTMockLogger methods.

    Expected behavior

    When I run bernardWebService.logout(), it triggers a HTTP Request on a logout URL, catched by RESTMockServer. As I defined a delay of 30 seconds, I expect the Mock webserver to wait 30 seconds before sending a response (and I hope to get a timeout to test this case).

    Actual behavior

    When bernardWebService.logout() is triggered, I get into RESTMockLogger.log with this message:

    -> New Request:	GET /api/logout HTTP/1.1
    

    About a second later, I'm back in my RESTMockLogger.log method with this message:

    <- Response:	HTTP/1.1 200 OK
    

    As you can see, no delay is applied.

    I tried with days and milliseconds unit. I tried to call the delay method before and after calling thenReturnString, it still doesn't work.

    enhancement 
    opened by maximelebastard 5
  • Add a file parser for parsing from the local file system.

    Add a file parser for parsing from the local file system.

    When using Roboelectric (or other unit testing framework for Android that does not set up a "real" Android environment), it's necessary to retrieve files based on the local file system of the machine on which the tests are run, rather than the virtual file system expected by the Android operating system. This is due to the fact that, when running these types of tests, most of the Android system is really just a set of mocks. As such, without this file parser, the "assets", "res", and other system-level file system paths are not set up and linked correctly, as the system calls that would normally provide this information are mocked.

    opened by jwir3 5
  • ConcurrentModificationException when resetting the server

    ConcurrentModificationException when resetting the server

    Hi! We've been using restmock for a while now, and we're often getting this Exception in many of our builds while running Android UI tests.

    We suspect it's happening when we reset the matched requests before a new test, and at the same time there are is request from the previous test still running, because Android shares the process between tests.

    More specifically, this happens when we invoke RestMockServer.reset() after a test, and at the same time the method getMatchedRequests() is iterating the matchableCalls list because some background thread made a request after the test already ended.

    We try to avoid this by using IdlingResources to make Espresso wait for our background tasks, but having almost 300 tests the probability of leaking some request is quite high.

    I can think of an easy solution by replacing the matchableCalls type from LinkedList to CopyOnWriteArrayList. This might cause the leaked request to not find a matched call and return an http 500 error , but that should be OK since the original test already finished, and I believe that's the currently expected behaviour. It's not a silver bullet solution to flaky tests, but it should help us quite a lot.

    What do you think? Is it OK if I open a Pull Request? Or do you think there may be a better approach?

    Here's the full stacktrace and some logs of the crash:

    D/RESTMock(10912): -> New Request:	GET /api/1/dictionary/professional-level HTTP/1.1
    D/RESTMock(10912): ## Removing all responses
    I/MockWebServer(10912): MockWebServer[39702] done accepting connections: Socket closed
    I/MicrophoneInputStream( 2161): mic_close gzi@1f273041
    I/HotwordRecognitionRnr( 2161): Hotword detection finished
    I/HotwordRecognitionRnr( 2161): Stopping hotword detection.
    I/System.out(10912): path: /api/1/dictionary/professional-level
    --------- beginning of crash
    E/AndroidRuntime(10912): FATAL EXCEPTION: OkHttp Http2Connection
    E/AndroidRuntime(10912): Process: net.infojobs.mobile.android.debug, PID: 10912
    E/AndroidRuntime(10912): java.util.ConcurrentModificationException
    E/AndroidRuntime(10912): 	at java.util.LinkedList$LinkIterator.next(LinkedList.java:124)
    E/AndroidRuntime(10912): 	at io.appflate.restmock.MatchableCallsRequestDispatcher.getMatchedRequests(MatchableCallsRequestDispatcher.java:96)
    E/AndroidRuntime(10912): 	at io.appflate.restmock.MatchableCallsRequestDispatcher.dispatch(MatchableCallsRequestDispatcher.java:41)
    E/AndroidRuntime(10912): 	at okhttp3.mockwebserver.MockWebServer$Http2SocketHandler.onStream(MockWebServer.java:942)
    E/AndroidRuntime(10912): 	at okhttp3.internal.http2.Http2Connection$ReaderRunnable$1.execute(Http2Connection.java:673)
    E/AndroidRuntime(10912): 	at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    E/AndroidRuntime(10912): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    E/AndroidRuntime(10912): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    E/AndroidRuntime(10912): 	at java.lang.Thread.run(Thread.java:818)
    W/ActivityManager( 1489): Error in app net.infojobs.mobile.android.debug running instrumentation ComponentInfo{net.infojobs.mobile.android.debug.test/com.infojobs.app.testutil.InfojobsTestRunner}:
    W/ActivityManager( 1489):   java.util.ConcurrentModificationException
    W/ActivityManager( 1489):   java.util.ConcurrentModificationException
    D/AndroidRuntime(10900): Shutting down VM
    
    enhancement 
    opened by Sloy 4
  • VerifyError: Cannot inherit from final class

    VerifyError: Cannot inherit from final class

    Kotlin version: 1.1.0 RESTMock Version: 0.2.1

    Hi

    I'm trying to use your library in Kotlin with JUnit robolectric tests and getting following exception:

    Exception in thread "pool-3-thread-1" java.lang.VerifyError: Cannot inherit from final class
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
    	at org.robolectric.internal.bytecode.SandboxClassLoader.maybeInstrumentClass(SandboxClassLoader.java:138)
    	at org.robolectric.internal.bytecode.SandboxClassLoader.findClass(SandboxClassLoader.java:101)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    	at io.appflate.restmock.RESTMockServer.init(RESTMockServer.java:54)
    	at io.appflate.restmock.RESTMockServerStarter$1.run(RESTMockServerStarter.java:44)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    

    This exception seems to be thrown within RESTMockServer.init() method, when new MockWebServer object is trying to be created. It's also kinda weird because everything works well in instrumented android tests. I created a sample kotlin project with your library here where this problem exists, so I would be very grateful if you could take a look on this in your spare time. As you will see, I included there all stuff from your robolectric sample.

    Have you ever met similar problem while working on your library?

    bug 
    opened by bartoszwilk 4
  • Any chance RESTMock can be moved off of Jitpack?

    Any chance RESTMock can be moved off of Jitpack?

    Hello,

    I love this library and have been using it for a long time. Is there any chance the artifacts can be hosted somewhere more stable than jitpack? It's been down for most of the day and our CI builds get stuck when it's down. Thanks!

    https://github.com/jitpack/jitpack.io/issues/5239

    opened by bartchro 0
  • converting android sample project to Kotlin gives ClassNotFoundException

    converting android sample project to Kotlin gives ClassNotFoundException

    When I convert MainActivityTest.java to kotlin, it gives below error:

    $ adb shell am instrument -w -r -e notPackage org.bouncycastle.pqc.crypto.qtesla   -e debug false -e class 'io.appflate.restmock.androidsample.tests.MainActivityTest' io.appflate.restmock.androidsample.test/io.appflate.restmock.androidsample.CustomTestRunner
    Connected to process 8637 on device 'lge-nexus_5x-024c6d7f5e96d337'.
    
    Started running tests
    
    
    java.lang.ClassNotFoundException: io.appflate.restmock.androidsample.tests.MainActivityTest
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:400)
    at androidx.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:72)
    at androidx.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104)
    at androidx.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:793)
    at androidx.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:547)
    at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:390)
    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "io.appflate.restmock.androidsample.tests.MainActivityTest" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/io.appflate.restmock.androidsample.test-1/base.apk", zip file "/data/app/io.appflate.restmock.androidsample-2/base.apk"],nativeLibraryDirectories=[/data/app/io.appflate.restmock.androidsample.test-1/lib/arm64, /data/app/io.appflate.restmock.androidsample-2/lib/arm64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 8 more
    
    Tests ran to completion.
    
    opened by JimClermonts 4
  • Crash with proguard

    Crash with proguard

    Hi, the REST-Mock crashes when proguard obfuscation is applied and HTTPS is enabled. Here is the stacktrace: 2020-05-08 14:19:07.799 13382-13475/xxx E/AndroidRuntime: FATAL EXCEPTION: pool-10-thread-1 Process: xxx, PID: 13382 java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.security.PublicKey.getAlgorithm()' on a null object reference at java.security.KeyStore$PrivateKeyEntry.(KeyStore.java:576) at java.security.KeyStore$PrivateKeyEntry.(KeyStore.java:526) at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:485) at java.security.KeyStore.getEntry(KeyStore.java:1560) at com.android.org.conscrypt.KeyManagerImpl.(KeyManagerImpl.java:72) at com.android.org.conscrypt.KeyManagerFactoryImpl.engineGetKeyManagers(KeyManagerFactoryImpl.java:115) at javax.net.ssl.KeyManagerFactory.getKeyManagers(KeyManagerFactory.java:305)

    According to this article the reason may be, that a deprecated version of spongycastle code to generate a self signed certificate is used: http://quabr.com:8182/59848764/how-to-fix-proguard-removes-java-security-code

    Regards Benjamin

    bug 
    opened by bmesing 1
  • Proxying feature

    Proxying feature

    Add a proxying feature which allows unmatched requests to be forwarded to the actual server. This would allow us to use RESTMock for developing new REST services without the implementation of the REST endpoint on the actual server.

    See WireMock for more information: http://wiremock.org/docs/proxying/

    enhancement 
    opened by multiholle 1
Releases(0.4.4)
Owner
Andrzej Chmielewski
Mobile development enthusiast (iOS, Android, Flutter) with some backend skills (Node, Typescript)
Andrzej Chmielewski
LiteHttp is a simple, intelligent and flexible HTTP framework for Android. With LiteHttp you can make HTTP request with only one line of code! It could convert a java model to the parameter and rander the response JSON as a java model intelligently.

Android network framework: LiteHttp Tags : litehttp2.x-tutorials Website : http://litesuits.com QQgroup : 42960650 , 47357508 Android网络通信为啥子选 lite-htt

马天宇 829 Dec 29, 2022
Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads.

AndroidAsync AndroidAsync is a low level network protocol library. If you are looking for an easy to use, higher level, Android aware, http request li

Koushik Dutta 7.3k Jan 2, 2023
Monitoring water tanker level using NodeMCU ESP8266 and HC-SR04P Ultrasonic Sensor and broadcasting it using a simple HTTP server inside NodeMCU ESP8266 and show data in an Android App

WaterLevel Preface This project aims to finding a tanker water level using NodeMCU with ESP8266 core and HC-SR04P Ultrasonic sensor and broadcasting i

YaMiN 12 Dec 20, 2022
Square’s meticulous HTTP client for the JVM, Android, and GraalVM.

OkHttp See the project website for documentation and APIs. HTTP is the way modern applications network. It’s how we exchange data & media. Doing HTTP

Square 43.4k Jan 5, 2023
A type-safe HTTP client for Android and the JVM

Retrofit A type-safe HTTP client for Android and Java. For more information please see the website. Download Download the latest JAR or grab from Mave

Square 41k Jan 5, 2023
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀

Fast Android Networking Library About Fast Android Networking Library Fast Android Networking Library is a powerful library for doing any type of netw

AMIT SHEKHAR 5.5k Dec 27, 2022
The easiest HTTP networking library for Kotlin/Android

Fuel The easiest HTTP networking library for Kotlin/Android. You are looking at the documentation for 2.x.y.. If you are looking for the documentation

Kittinun Vantasin 4.3k Jan 8, 2023
An android asynchronous http client built on top of HttpURLConnection.

Versions 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 Version 1.0.6 Description An android asynchronous http client based on HttpURLConnection. Updates U

David 15 Mar 29, 2020
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀

Fast Android Networking Library About Fast Android Networking Library Fast Android Networking Library is a powerful library for doing any type of netw

AMIT SHEKHAR 5.5k Jan 3, 2023
Arkhota is a web (HTTP/S) brute forcer for Android.

Arkhota is a web (HTTP/S) brute forcer for Android.

ALW1EZ 51 Dec 29, 2022
Pluto is a on-device debugger for Android applications, which helps in inspection of HTTP requests/responses, capture Crashes and ANRs and manipulating application data on-the-go.

Pluto Pluto is a on-device debugger for Android applications, which helps in inspection of HTTP requests/responses, capture Crashes and ANRs and manip

Mocklets 8 Aug 22, 2022
Volley is an HTTP library that makes networking for Android apps easier and, most importantly, faster.

Volley Volley is an HTTP library that makes networking for Android apps easier and, most importantly, faster. For more information about Volley and ho

Google 3.3k Jan 1, 2023
Ktorfit - a HTTP client/Kotlin Symbol Processor for Kotlin Multiplatform (Js, Jvm, Android, iOS, Linux) using KSP and Ktor clients inspired by Retrofit

Ktorfit is a HTTP client/Kotlin Symbol Processor for Kotlin Multiplatform (Js, Jvm, Android, iOS, Linux) using KSP and Ktor clients inspired by Retrofit

Jens Klingenberg 637 Dec 25, 2022
Asynchronous Http and WebSocket Client library for Java

Async Http Client Follow @AsyncHttpClient on Twitter. The AsyncHttpClient (AHC) library allows Java applications to easily execute HTTP requests and a

AsyncHttpClient 6k Jan 8, 2023
Multiplatform coroutine-based HTTP client wrapper for Kotlin

networkinkt This is a lightweight HTTP client for Kotlin. It relies on coroutines on both JS & JVM platforms. Here is a simple GET request: val text =

Egor Zhdan 31 Jul 27, 2022
HttpMocker is a simple HTTP mocking library written in Kotlin to quickly and easily handle offline modes in your apps

HttpMocker HttpMocker is a very lightweight Kotlin library that allows to mock HTTP calls relying on either OkHttp or the Ktor client libraries. It ca

David Blanc 174 Nov 28, 2022
Kotlin HTTP requests library. Similar to Python requests.

khttp khttp is a simple library for HTTP requests in Kotlin. It functions similarly to Python's requests module. import khttp.get fun main(args: Arra

Anna Clemens 466 Dec 20, 2022
Kotlin DSL http client

Introduction Kotlin DSL http client Features ?? Developers Experience-driven library without verbosity. ?? Native way to use http client in Kotlin. ??

Sergei Rybalkin 461 Dec 13, 2022
Java HTTP Request Library

Http Request A simple convenience library for using a HttpURLConnection to make requests and access the response. This library is available under the

Kevin Sawicki 3.3k Jan 6, 2023