OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 result.setResponse( | 52 result.setResponse( |
53 url + "\n" + | 53 url + "\n" + |
54 headers.get(0).getKey() + "\n" + | 54 headers.get(0).getKey() + "\n" + |
55 headers.get(0).getValue()); | 55 headers.get(0).getValue()); |
56 return result; | 56 return result; |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 @Override | 60 @Override |
61 protected void setUp() throws Exception | 61 protected WebRequest createWebRequest() |
62 { | 62 { |
63 super.setUp(); | 63 return new LocalMockWebRequest(); |
64 | |
65 jsEngine.setWebRequest(new LocalMockWebRequest()); | |
66 } | 64 } |
67 | 65 |
68 @Test | 66 @Test |
69 public void testBadCall() | 67 public void testBadCall() |
70 { | 68 { |
71 try | 69 try |
72 { | 70 { |
73 jsEngine.evaluate("_webRequest.GET()"); | 71 jsEngine.evaluate("_webRequest.GET()"); |
74 fail(); | 72 fail(); |
75 } | 73 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 138 |
141 assertEquals( | 139 assertEquals( |
142 ServerResponse.NsStatus.OK.getStatusCode(), | 140 ServerResponse.NsStatus.OK.getStatusCode(), |
143 jsEngine.evaluate("foo.status").asLong()); | 141 jsEngine.evaluate("foo.status").asLong()); |
144 assertEquals("http://example.com/\nX\nY", jsEngine.evaluate("foo.responseTex
t").asString()); | 142 assertEquals("http://example.com/\nX\nY", jsEngine.evaluate("foo.responseTex
t").asString()); |
145 assertEquals("{\"Foo\":\"Bar\"}", | 143 assertEquals("{\"Foo\":\"Bar\"}", |
146 jsEngine.evaluate("JSON.stringify(foo.responseHeaders)").asString()); | 144 jsEngine.evaluate("JSON.stringify(foo.responseHeaders)").asString()); |
147 } | 145 } |
148 | 146 |
149 } | 147 } |
OLD | NEW |