Search in sources :

Example 1 with MockInterceptor

use of okhttp3.mock.MockInterceptor in project em-stitching-api by hmcts.

the class DocumentTaskResourceIntTest method initTest.

@Before
public void initTest() {
    documentTask = createEntity();
    MockInterceptor mockInterceptor = (MockInterceptor) okHttpClient.interceptors().get(0);
    mockInterceptor.reset();
}
Also used : MockInterceptor(okhttp3.mock.MockInterceptor) Before(org.junit.Before)

Example 2 with MockInterceptor

use of okhttp3.mock.MockInterceptor in project java-sdk by dapr.

the class DaprHttpClientTest method setUp.

@Before
public void setUp() throws Exception {
    mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
    okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) MockInterceptor(okhttp3.mock.MockInterceptor) Before(org.junit.Before)

Example 3 with MockInterceptor

use of okhttp3.mock.MockInterceptor in project java-sdk by dapr.

the class DaprHttpClientTest method setUp.

@Before
public void setUp() {
    mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
    okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) MockInterceptor(okhttp3.mock.MockInterceptor) Before(org.junit.Before)

Example 4 with MockInterceptor

use of okhttp3.mock.MockInterceptor in project java-sdk by dapr.

the class DaprPreviewClientHttpTest method setUp.

@Before
public void setUp() {
    mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
    okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
    daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
    daprPreviewClientHttp = new DaprClientHttp(daprHttp);
}
Also used : OkHttpClient(okhttp3.OkHttpClient) MockInterceptor(okhttp3.mock.MockInterceptor) Before(org.junit.Before)

Example 5 with MockInterceptor

use of okhttp3.mock.MockInterceptor in project struts by apache.

the class XmlConfigurationProviderInterceptorsTest method testBasicInterceptors.

public void testBasicInterceptors() throws ConfigurationException {
    final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-interceptors-basic.xml";
    ConfigurationProvider provider = buildConfigurationProvider(filename);
    // setup expectations
    // the test interceptor with a parameter
    Map<String, String> params = new HashMap<>();
    params.put("foo", "expectedFoo");
    InterceptorConfig paramsInterceptor = new InterceptorConfig.Builder("test", MockInterceptor.class.getName()).addParams(params).build();
    // the default interceptor stack
    InterceptorStackConfig defaultStack = new InterceptorStackConfig.Builder("defaultStack").addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap<String, String>()))).addInterceptor(new InterceptorMapping("test", objectFactory.buildInterceptor(mockInterceptor, params))).build();
    // the derivative interceptor stack
    InterceptorStackConfig derivativeStack = new InterceptorStackConfig.Builder("derivativeStack").addInterceptor(new InterceptorMapping("noop", objectFactory.buildInterceptor(noopInterceptor, new HashMap<String, String>()))).addInterceptor(new InterceptorMapping("test", objectFactory.buildInterceptor(mockInterceptor, params))).addInterceptor(new InterceptorMapping("logging", objectFactory.buildInterceptor(loggingInterceptor, new HashMap<String, String>()))).build();
    // execute the configuration
    provider.init(configuration);
    provider.loadPackages();
    PackageConfig pkg = configuration.getPackageConfig("default");
    Map interceptorConfigs = pkg.getInterceptorConfigs();
    // assertions for size
    assertEquals(5, interceptorConfigs.size());
    // assertions for interceptors
    assertEquals(noopInterceptor, interceptorConfigs.get("noop"));
    assertEquals(loggingInterceptor, interceptorConfigs.get("logging"));
    assertEquals(paramsInterceptor, interceptorConfigs.get("test"));
    // assertions for interceptor stacks
    assertEquals(defaultStack, interceptorConfigs.get("defaultStack"));
    assertEquals(derivativeStack, interceptorConfigs.get("derivativeStack"));
}
Also used : HashMap(java.util.HashMap) ConfigurationProvider(com.opensymphony.xwork2.config.ConfigurationProvider) StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) InterceptorConfig(com.opensymphony.xwork2.config.entities.InterceptorConfig) PackageConfig(com.opensymphony.xwork2.config.entities.PackageConfig) InterceptorStackConfig(com.opensymphony.xwork2.config.entities.InterceptorStackConfig) MockInterceptor(com.opensymphony.xwork2.mock.MockInterceptor) InterceptorMapping(com.opensymphony.xwork2.config.entities.InterceptorMapping) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

MockInterceptor (okhttp3.mock.MockInterceptor)13 Before (org.junit.Before)9 MockInterceptor (com.opensymphony.xwork2.mock.MockInterceptor)7 OkHttpClient (okhttp3.OkHttpClient)5 ActionProxy (com.opensymphony.xwork2.ActionProxy)4 lombok.val (lombok.val)4 Test (org.junit.jupiter.api.Test)4 InterceptorMapping (com.opensymphony.xwork2.config.entities.InterceptorMapping)3 HttpUrl (okhttp3.HttpUrl)3 Builder (okhttp3.HttpUrl.Builder)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 RequestInterceptor (feign.RequestInterceptor)2 RequestTemplate (feign.RequestTemplate)2 ArrayList (java.util.ArrayList)2 MockResponse (okhttp3.mockwebserver.MockResponse)2 JsonCodecV2 (org.eclipse.emfcloud.modelserver.emf.common.codecs.JsonCodecV2)2 Test (org.junit.Test)2 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)1 InterceptorConfig (com.opensymphony.xwork2.config.entities.InterceptorConfig)1 InterceptorStackConfig (com.opensymphony.xwork2.config.entities.InterceptorStackConfig)1