@Test
public void testProcessURL() throws Exception {

  HttpURLConnection connection = createNiceMock(HttpURLConnection.class);
  AppCookieManager appCookieManager = createNiceMock(AppCookieManager.class);
  URLStreamProvider urlStreamProvider = createMockBuilder(URLStreamProvider.class).
      withConstructor(Integer.TYPE, Integer.TYPE, String.class, String.class, String.class).
      withArgs(1000, 1000, "path", "password", "type").
      addMockedMethod("getAppCookieManager").
      addMockedMethod("getConnection", String.class).
      createMock();
  expect(urlStreamProvider.getAppCookieManager()).andReturn(appCookieManager).anyTimes();
  expect(urlStreamProvider.getConnection("spec")).andReturn(connection);
  Map<String, List<String>> headerMap = new HashMap<String, List<String>>();
  headerMap.put("Header1", Collections.singletonList("value"));
  headerMap.put("Cookie", Collections.singletonList("FOO=bar"));
  expect(appCookieManager.getCachedAppCookie("spec")).andReturn("APPCOOKIE=abcdef");
  connection.setConnectTimeout(1000);
  connection.setReadTimeout(1000);
  connection.setRequestMethod("GET");
  connection.setRequestProperty("Header1", "value");
  connection.setRequestProperty("Cookie", "FOO=bar; APPCOOKIE=abcdef");
  replay(urlStreamProvider, connection, appCookieManager);
  Assert.assertEquals(connection, urlStreamProvider.processURL("spec", "GET", (String) null, headerMap));
  verify(urlStreamProvider, connection, appCookieManager);
}