| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.net.urlconnection; | 5 package org.chromium.net.urlconnection; |
| 6 | 6 |
| 7 import android.os.Build; | 7 import android.os.Build; |
| 8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
| 9 | 9 |
| 10 import org.chromium.base.annotations.SuppressFBWarnings; |
| 10 import org.chromium.base.test.util.Feature; | 11 import org.chromium.base.test.util.Feature; |
| 11 import org.chromium.net.CronetTestActivity; | 12 import org.chromium.net.CronetTestActivity; |
| 12 import org.chromium.net.CronetTestBase; | 13 import org.chromium.net.CronetTestBase; |
| 13 import org.chromium.net.MockUrlRequestJobFactory; | 14 import org.chromium.net.MockUrlRequestJobFactory; |
| 14 import org.chromium.net.NativeTestServer; | 15 import org.chromium.net.NativeTestServer; |
| 15 import org.chromium.net.UrlRequestContextConfig; | 16 import org.chromium.net.UrlRequestContextConfig; |
| 16 import org.chromium.net.UrlRequestException; | 17 import org.chromium.net.UrlRequestException; |
| 17 | 18 |
| 18 import java.io.ByteArrayOutputStream; | 19 import java.io.ByteArrayOutputStream; |
| 19 import java.io.FileNotFoundException; | 20 import java.io.FileNotFoundException; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 urlConnection.connect(); | 162 urlConnection.connect(); |
| 162 fail(); | 163 fail(); |
| 163 } catch (java.net.UnknownHostException e) { | 164 } catch (java.net.UnknownHostException e) { |
| 164 // Expected. | 165 // Expected. |
| 165 } catch (UrlRequestException e) { | 166 } catch (UrlRequestException e) { |
| 166 // Expected. | 167 // Expected. |
| 167 } | 168 } |
| 168 checkExceptionsAreThrown(urlConnection); | 169 checkExceptionsAreThrown(urlConnection); |
| 169 } | 170 } |
| 170 | 171 |
| 172 @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") |
| 171 @SmallTest | 173 @SmallTest |
| 172 @Feature({"Cronet"}) | 174 @Feature({"Cronet"}) |
| 173 @CompareDefaultWithCronet | 175 @CompareDefaultWithCronet |
| 174 public void testBadScheme() throws Exception { | 176 public void testBadScheme() throws Exception { |
| 175 try { | 177 try { |
| 176 URL url = new URL("flying://goat"); | 178 URL url = new URL("flying://goat"); |
| 177 fail(); | 179 fail(); |
| 178 } catch (MalformedURLException e) { | 180 } catch (MalformedURLException e) { |
| 179 // Expected. | 181 // Expected. |
| 180 } | 182 } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 try { | 427 try { |
| 426 values.add("v3"); | 428 values.add("v3"); |
| 427 fail(); | 429 fail(); |
| 428 } catch (UnsupportedOperationException e) { | 430 } catch (UnsupportedOperationException e) { |
| 429 // Expected. | 431 // Expected. |
| 430 } | 432 } |
| 431 | 433 |
| 432 connection.disconnect(); | 434 connection.disconnect(); |
| 433 } | 435 } |
| 434 | 436 |
| 437 @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") |
| 435 @SmallTest | 438 @SmallTest |
| 436 @Feature({"Cronet"}) | 439 @Feature({"Cronet"}) |
| 437 @CompareDefaultWithCronet | 440 @CompareDefaultWithCronet |
| 438 public void testInputStreamBatchReadBoundaryConditions() throws Exception { | 441 public void testInputStreamBatchReadBoundaryConditions() throws Exception { |
| 439 String testInputString = "this is a very important header"; | 442 String testInputString = "this is a very important header"; |
| 440 byte[] testInputBytes = testInputString.getBytes(); | 443 byte[] testInputBytes = testInputString.getBytes(); |
| 441 URL url = new URL(NativeTestServer.getEchoHeaderURL("foo")); | 444 URL url = new URL(NativeTestServer.getEchoHeaderURL("foo")); |
| 442 HttpURLConnection urlConnection = | 445 HttpURLConnection urlConnection = |
| 443 (HttpURLConnection) url.openConnection(); | 446 (HttpURLConnection) url.openConnection(); |
| 444 urlConnection.addRequestProperty("foo", testInputString); | 447 urlConnection.addRequestProperty("foo", testInputString); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 String headerName) { | 949 String headerName) { |
| 947 Pattern pattern = Pattern.compile(headerName + ":\\s(.*)\\r\\n"); | 950 Pattern pattern = Pattern.compile(headerName + ":\\s(.*)\\r\\n"); |
| 948 Matcher matcher = pattern.matcher(allHeaders); | 951 Matcher matcher = pattern.matcher(allHeaders); |
| 949 List<String> headerValues = new ArrayList<String>(); | 952 List<String> headerValues = new ArrayList<String>(); |
| 950 while (matcher.find()) { | 953 while (matcher.find()) { |
| 951 headerValues.add(matcher.group(1)); | 954 headerValues.add(matcher.group(1)); |
| 952 } | 955 } |
| 953 return headerValues; | 956 return headerValues; |
| 954 } | 957 } |
| 955 } | 958 } |
| OLD | NEW |