public void testShouldAllowSpecificUrlsToBeProxied() throws IOException {
    DoNotUseProxyPac pac = new DoNotUseProxyPac();

    pac.mapHost("www.google.com").toProxy("http://localhost:8080");
    String config = captureOutput(pac);

    assertTrue(
        config,
        config.contains(
            "if (shExpMatch(host, 'www.google.com')) {"
                + " return 'PROXY http://localhost:8080'; "
                + "}"));
  }
  public void testShouldConvertAProxyPacProperly() throws JSONException {
    DoNotUseProxyPac pac = new DoNotUseProxyPac();
    pac.map("*/selenium/*").toProxy("http://localhost:8080/selenium-server");
    pac.map("/[a-zA-Z]{4}.microsoft.com/").toProxy("http://localhost:1010/selenium-server/");
    pac.map("/flibble*").toNoProxy();
    pac.mapHost("www.google.com").toProxy("http://fishy.com/");
    pac.mapHost("seleniumhq.org").toNoProxy();
    pac.defaults().toNoProxy();

    String json = new BeanToJsonConverter().convert(pac);
    JSONObject converted = new JSONObject(json);

    assertEquals(
        "http://localhost:8080/selenium-server",
        converted.getJSONObject("proxiedUrls").get("*/selenium/*"));
    assertEquals(
        "http://localhost:1010/selenium-server/",
        converted.getJSONObject("proxiedRegexUrls").get("/[a-zA-Z]{4}.microsoft.com/"));
    assertEquals("/flibble*", converted.getJSONArray("directUrls").get(0));
    assertEquals("seleniumhq.org", converted.getJSONArray("directHosts").get(0));
    assertEquals(
        "http://fishy.com/", converted.getJSONObject("proxiedHosts").get("www.google.com"));
    assertEquals("'DIRECT'", converted.get("defaultProxy"));
  }