// Path: core/src/main/java/io/appflate/restmock/RESTMockOptions.java
// public class RESTMockOptions {
//     private boolean useHttps;
//     private SSLSocketFactory socketFactory;
//     private X509TrustManager trustManager;
// 
//     private RESTMockOptions(final Builder builder) {
//         setUseHttps(builder.useHttps);
//         setSocketFactory(builder.socketFactory);
//         setTrustManager(builder.trustManager);
//     }
// 
//     public boolean isUseHttps() {
//         return useHttps;
//     }
// 
//     public void setUseHttps(final boolean useHttps) {
//         this.useHttps = useHttps;
//     }
// 
//     /**
//      * Returns the sslSocketFactory used by RESTMockServer. If you didn't specify your own with #setSSlSocketFactory(SSSLSocketFactory)
//      * method, then a default one will be created
//      * You can set this socket factory in your HTTP client in order to be able to perform proper SSL handshakes with mockwebserver
//      *
//      * @return SSLSocketFactory used by the RESTMockServer
//      */
//     public SSLSocketFactory getSocketFactory() {
//         return socketFactory;
//     }
// 
//     public void setSocketFactory(final SSLSocketFactory socketFactory) {
//         this.socketFactory = socketFactory;
//     }
// 
//     /**
//      * Returns the trustManager used in conjunction with sslSocketFactory. It is set up to trust the certificates produces by the
//      * sslSocketFactory returned in `getSocketFactory().
//      */
//     public X509TrustManager getTrustManager() {
//         return trustManager;
//     }
// 
//     public void setTrustManager(final X509TrustManager trustManager) {
//         this.trustManager = trustManager;
//     }
// 
//     public static final class Builder {
//         private boolean useHttps;
//         private SSLSocketFactory socketFactory;
//         private X509TrustManager trustManager;
// 
//         public Builder() {
//         }
// 
//         public Builder useHttps(final boolean val) {
//             useHttps = val;
//             return this;
//         }
// 
//         public Builder socketFactory(final SSLSocketFactory val) {
//             socketFactory = val;
//             return this;
//         }
// 
//         public Builder trustManager(final X509TrustManager val) {
//             trustManager = val;
//             return this;
//         }
// 
//         public RESTMockOptions build() {
//             return new RESTMockOptions(this);
//         }
//     }
// }
// 
// Path: core/src/main/java/io/appflate/restmock/RESTMockServerStarter.java
// public class RESTMockServerStarter {
// 
//     public static final int KEEP_ALIVE_TIME = 60;
// 
//     public static void startSync(final RESTMockFileParser mocksFileParser) {
//         startSync(mocksFileParser, null,
//             new RESTMockOptions.Builder().build());
//     }
// 
//     public static void startSync(final RESTMockFileParser mocksFileParser, RESTMockOptions options) {
//         startSync(mocksFileParser, null, options);
//     }
// 
//     public static void startSync(final RESTMockFileParser mocksFileParser, final RESTMockLogger logger) {
//         startSync(mocksFileParser, logger, new RESTMockOptions.Builder().build());
//     }
// 
//     public static void startSync(
//         final RESTMockFileParser mocksFileParser,
//         final RESTMockLogger logger,
//         final RESTMockOptions restMockOptions
//     ) {
//         // it has to be like that since Android prevents starting testServer on main Thread.
//         ThreadPoolExecutor threadPoolExecutor =
//             new ThreadPoolExecutor(1, 1, KEEP_ALIVE_TIME, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(1));
// 
//         threadPoolExecutor.execute(new Runnable() {
// 
//             @Override
//             public void run() {
//                 try {
//                     RESTMockServer.init(mocksFileParser, logger, restMockOptions);
//                 } catch (IOException e) {
//                     RESTMockServer.getLogger().error("Server start error", e);
//                     throw new RuntimeException(e);
//                 }
//             }
//         });
//         try {
//             threadPoolExecutor.shutdown();
//             if (!threadPoolExecutor.awaitTermination(KEEP_ALIVE_TIME, TimeUnit.SECONDS)) {
//                 throw new RuntimeException("mock server didn't manage to start within the given timeout (60 seconds)");
//             }
//         } catch (InterruptedException e) {
//             RESTMockServer.getLogger().error("Server start error", e);
//             throw new RuntimeException(e);
//         }
//     }
// 
//     private RESTMockServerStarter() {
//     }
// }


import android.os.Bundle;
import androidx.test.runner.AndroidJUnitRunner;
import io.appflate.restmock.RESTMockOptions;
import io.appflate.restmock.RESTMockServerStarter;
/*
 * 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.
 */

package io.appflate.restmock.android;


/**
 * Created by andrzejchm on 22/04/16.
 */
public class RESTMockTestRunner extends AndroidJUnitRunner {

    @Override
    public void onCreate(Bundle arguments) {
        super.onCreate(arguments);
        RESTMockServerStarter.startSync(new AndroidAssetsFileParser(getContext()), new AndroidLogger(),
// Path: core/src/main/java/io/appflate/restmock/RESTMockOptions.java
// public class RESTMockOptions {
//     private boolean useHttps;
//     private SSLSocketFactory socketFactory;
//     private X509TrustManager trustManager;
// 
//     private RESTMockOptions(final Builder builder) {
//         setUseHttps(builder.useHttps);
//         setSocketFactory(builder.socketFactory);
//         setTrustManager(builder.trustManager);
//     }
// 
//     public boolean isUseHttps() {
//         return useHttps;
//     }
// 
//     public void setUseHttps(final boolean useHttps) {
//         this.useHttps = useHttps;
//     }
// 
//     /**
//      * Returns the sslSocketFactory used by RESTMockServer. If you didn't specify your own with #setSSlSocketFactory(SSSLSocketFactory)
//      * method, then a default one will be created
//      * You can set this socket factory in your HTTP client in order to be able to perform proper SSL handshakes with mockwebserver
//      *
//      * @return SSLSocketFactory used by the RESTMockServer
//      */
//     public SSLSocketFactory getSocketFactory() {
//         return socketFactory;
//     }
// 
//     public void setSocketFactory(final SSLSocketFactory socketFactory) {
//         this.socketFactory = socketFactory;
//     }
// 
//     /**
//      * Returns the trustManager used in conjunction with sslSocketFactory. It is set up to trust the certificates produces by the
//      * sslSocketFactory returned in `getSocketFactory().
//      */
//     public X509TrustManager getTrustManager() {
//         return trustManager;
//     }
// 
//     public void setTrustManager(final X509TrustManager trustManager) {
//         this.trustManager = trustManager;
//     }
// 
//     public static final class Builder {
//         private boolean useHttps;
//         private SSLSocketFactory socketFactory;
//         private X509TrustManager trustManager;
// 
//         public Builder() {
//         }
// 
//         public Builder useHttps(final boolean val) {
//             useHttps = val;
//             return this;
//         }
// 
//         public Builder socketFactory(final SSLSocketFactory val) {
//             socketFactory = val;
//             return this;
//         }
// 
//         public Builder trustManager(final X509TrustManager val) {
//             trustManager = val;
//             return this;
//         }
// 
//         public RESTMockOptions build() {
//             return new RESTMockOptions(this);
//         }
//     }
// }
// 
// Path: core/src/main/java/io/appflate/restmock/RESTMockServerStarter.java
// public class RESTMockServerStarter {
// 
//     public static final int KEEP_ALIVE_TIME = 60;
// 
//     public static void startSync(final RESTMockFileParser mocksFileParser) {
//         startSync(mocksFileParser, null,
//             new RESTMockOptions.Builder().build());
//     }
// 
//     public static void startSync(final RESTMockFileParser mocksFileParser, RESTMockOptions options) {
//         startSync(mocksFileParser, null, options);
//     }
// 
//     public static void startSync(final RESTMockFileParser mocksFileParser, final RESTMockLogger logger) {
//         startSync(mocksFileParser, logger, new RESTMockOptions.Builder().build());
//     }
// 
//     public static void startSync(
//         final RESTMockFileParser mocksFileParser,
//         final RESTMockLogger logger,
//         final RESTMockOptions restMockOptions
//     ) {
//         // it has to be like that since Android prevents starting testServer on main Thread.
//         ThreadPoolExecutor threadPoolExecutor =
//             new ThreadPoolExecutor(1, 1, KEEP_ALIVE_TIME, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(1));
// 
//         threadPoolExecutor.execute(new Runnable() {
// 
//             @Override
//             public void run() {
//                 try {
//                     RESTMockServer.init(mocksFileParser, logger, restMockOptions);
//                 } catch (IOException e) {
//                     RESTMockServer.getLogger().error("Server start error", e);
//                     throw new RuntimeException(e);
//                 }
//             }
//         });
//         try {
//             threadPoolExecutor.shutdown();
//             if (!threadPoolExecutor.awaitTermination(KEEP_ALIVE_TIME, TimeUnit.SECONDS)) {
//                 throw new RuntimeException("mock server didn't manage to start within the given timeout (60 seconds)");
//             }
//         } catch (InterruptedException e) {
//             RESTMockServer.getLogger().error("Server start error", e);
//             throw new RuntimeException(e);
//         }
//     }
// 
//     private RESTMockServerStarter() {
//     }
// }


// Path: android/src/main/java/io/appflate/restmock/android/RESTMockTestRunner.java
import android.os.Bundle;
import androidx.test.runner.AndroidJUnitRunner;
import io.appflate.restmock.RESTMockOptions;
import io.appflate.restmock.RESTMockServerStarter;

/*
 * 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.
 */

package io.appflate.restmock.android;


/**
 * Created by andrzejchm on 22/04/16.
 */
public class RESTMockTestRunner extends AndroidJUnitRunner {

    @Override
    public void onCreate(Bundle arguments) {
        super.onCreate(arguments);
        RESTMockServerStarter.startSync(new AndroidAssetsFileParser(getContext()), new AndroidLogger(),
            new RESTMockOptions.Builder()