Opened on 05/27/2016 at 02:06:41 PM

Closed on 10/23/2018 at 10:42:09 AM

#4081 closed defect (fixed)

Fix failing MockWebRequestTest test for libadblockplus-android

Reported by: asmirnov Assignee: asmirnov
Priority: P3 Milestone:
Module: Libadblockplus-Android Keywords:
Cc: rjeschke Blocked By: #4031
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29345369/

Description

MockWebRequestTest test similar to https://hg.adblockplus.org/libadblockplus/file/tip/test/WebRequest.cpp.

It is failing with assert exception:

     [exec] junit.framework.ComparisonFailure: expected:<{["Foo":"Bar"]}> but was:<{[]}>
     [exec] 	at org.adblockplus.libadblockplus.tests.MockWebRequestTest.testSuccessfulRequest(MockWebRequestTest.java:118)
     [exec] 	at java.lang.reflect.Method.invokeNative(Native Method)
     [exec] 	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
     [exec] 	at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
     [exec] 	at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
     [exec] 	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)

The reason is (most likely) headers are not mapped from java code to c++ code even if mock webrequest impl with headers is used:

private class LocalMockWebRequest extends WebRequest {
        @Override
        public ServerResponse httpGET(String url, List<HeaderEntry> headers) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

            ServerResponse result = new ServerResponse();
            result.setStatus(ServerResponse.NsStatus.OK);
            result.setResponseStatus(123);
            result.setReponseHeaders(Arrays.asList(new HeaderEntry("Foo", "Bar")));

            result.setResponse(
                url + "\n" +
                headers.get(0).getKey() + "\n" +
                headers.get(0).getValue());
            return result;
        }
    }

and

@Override
    protected void setUp() throws Exception {
        super.setUp();

        jsEngine.setWebRequest(new LocalMockWebRequest());
    }

Attachments (0)

Change History (7)

comment:1 Changed on 05/27/2016 at 02:11:46 PM by asmirnov

  • Component changed from Unknown to Libadblockplus-Android

comment:2 Changed on 05/30/2016 at 11:24:09 AM by asmirnov

  • Owner changed from Anton to asmirnov

comment:3 Changed on 05/30/2016 at 11:39:48 AM by asmirnov

comment:4 Changed on 06/10/2016 at 10:42:05 AM by asmirnov

  • Status changed from new to reviewing

comment:5 Changed on 06/10/2016 at 10:50:06 AM by asmirnov

  • Review URL(s) modified (diff)

comment:6 Changed on 09/16/2016 at 10:26:52 AM by abpbot

comment:7 Changed on 10/23/2018 at 10:42:09 AM by asmirnov

  • Resolution set to fixed
  • Status changed from reviewing to closed

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from asmirnov.
 
Note: See TracTickets for help on using tickets.