Search in sources :

Example 1 with DefaultWXHttpAdapter

use of com.taobao.weex.adapter.DefaultWXHttpAdapter in project weex-example by KalicyZhou.

the class WXStreamModuleTest method testFetchRequestHttpbinCallback.

@Test
public void testFetchRequestHttpbinCallback() throws Exception {
    WXStreamModule streamModule = createModule(new DefaultWXHttpAdapter());
    JSCallback progress = mock(JSCallback.class);
    JSCallback finish = mock(JSCallback.class);
    System.out.print("request start " + System.currentTimeMillis());
    streamModule.fetch("{method: 'POST',url: 'http://httpbin.org/post',type:'json'}", finish, progress);
    verify(progress, timeout(10 * 1000).atLeastOnce()).invokeAndKeepAlive(anyMapOf(String.class, Object.class));
    verify(finish, timeout(10 * 1000).times(1)).invoke(anyMapOf(String.class, Object.class));
    System.out.print("\nrequest finish" + System.currentTimeMillis());
}
Also used : DefaultWXHttpAdapter(com.taobao.weex.adapter.DefaultWXHttpAdapter) JSCallback(com.taobao.weex.bridge.JSCallback) Test(org.junit.Test) WXSDKInstanceTest(com.taobao.weex.WXSDKInstanceTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with DefaultWXHttpAdapter

use of com.taobao.weex.adapter.DefaultWXHttpAdapter in project incubator-weex by apache.

the class WXStreamModuleTest method testFetchRequestHttpbinCallback.

@Test
public void testFetchRequestHttpbinCallback() throws Exception {
    WXStreamModule streamModule = createModule(new DefaultWXHttpAdapter());
    JSCallback progress = mock(JSCallback.class);
    JSCallback finish = mock(JSCallback.class);
    System.out.print("request start " + System.currentTimeMillis());
    streamModule.fetch(JSON.parseObject("{method: 'POST',url: 'http://httpbin.org/post',type:'json'}"), finish, progress);
    verify(progress, timeout(10 * 1000).atLeastOnce()).invokeAndKeepAlive(anyMapOf(String.class, Object.class));
    verify(finish, timeout(10 * 1000).times(1)).invoke(anyMapOf(String.class, Object.class));
    System.out.print("\nrequest finish" + System.currentTimeMillis());
}
Also used : DefaultWXHttpAdapter(com.taobao.weex.adapter.DefaultWXHttpAdapter) JSCallback(com.taobao.weex.bridge.JSCallback) WXSDKInstanceTest(com.taobao.weex.WXSDKInstanceTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)2 DefaultWXHttpAdapter (com.taobao.weex.adapter.DefaultWXHttpAdapter)2 JSCallback (com.taobao.weex.bridge.JSCallback)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2