gpt4 book ai didi

org.mozilla.zest.core.v1.ZestRequest.setUrl()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 09:35:27 26 4
gpt4 key购买 nike

本文整理了Java中org.mozilla.zest.core.v1.ZestRequest.setUrl()方法的一些代码示例,展示了ZestRequest.setUrl()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestRequest.setUrl()方法的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestRequest
类名称:ZestRequest
方法名:setUrl

ZestRequest.setUrl介绍

[英]Sets the url.
[中]设置url。

代码示例

代码示例来源:origin: mozilla/zest

@Override
public void setPrefix(String oldPrefix, String newPrefix) throws MalformedURLException {
  if (this.getUrl() != null && this.getUrl().toString().startsWith(oldPrefix)) {
    String urlStr = newPrefix + getUrl().toString().substring(oldPrefix.length());
    this.setUrl(new URL(urlStr));
  } else {
    throw new IllegalArgumentException(
        "Request url " + getUrl() + " does not start with " + oldPrefix);
  }
}

代码示例来源:origin: mozilla/zest

/**
 * Replace tokens.
 *
 * @param tokens the tokens
 */
public void replaceTokens(ZestVariables tokens) {
  if (this.urlToken != null) {
    this.setUrlToken(tokens.replaceInString(this.urlToken, true));
    try {
      this.setUrl(new URL(this.getUrlToken()));
    } catch (MalformedURLException e) {
      // Ignore
    }
  } else if (this.url != null) {
    try {
      this.setUrl(new URL(tokens.replaceInString(this.url.toString(), true)));
    } catch (MalformedURLException e) {
      // Ignore
    }
  }
  this.setMethod(tokens.replaceInString(this.getMethod(), false));
  this.setHeaders(tokens.replaceInString(this.getHeaders(), false));
  this.setData(tokens.replaceInString(this.getData(), false));
  for (ZestCookie cookie : this.cookies) {
    cookie.setDomain(tokens.replaceInString(cookie.getDomain(), false));
    cookie.setName(tokens.replaceInString(cookie.getName(), false));
    cookie.setValue(tokens.replaceInString(cookie.getValue(), false));
    cookie.setPath(tokens.replaceInString(cookie.getPath(), false));
  }
}

代码示例来源:origin: mozilla/zest

request.setUrl(url);
String urlToken = "http://{{host}}/";
request.setUrlToken(urlToken);

代码示例来源:origin: mozilla/zest

private static ZestRequest createRequest(String url) throws Exception {
    ZestRequest request = createRequest();
    request.setUrl(new URL(url));
    return request;
  }
}

代码示例来源:origin: mozilla/zest

@Override
public ZestRequest deepCopy() {
  ZestRequest zr = new ZestRequest(this.getIndex());
  zr.setUrl(this.url);
  zr.setUrlToken(this.urlToken);
  zr.setData(this.data);
  zr.setMethod(this.method);
  zr.setHeaders(this.headers);
  zr.setFollowRedirects(this.followRedirects);
  zr.setTimestamp(this.timestamp);
  if (this.getResponse() != null) {
    zr.setResponse(this.getResponse().deepCopy());
  }
  for (ZestAssertion zt : this.getAssertions()) {
    zr.addAssertion((ZestAssertion) zt.deepCopy());
  }
  for (ZestCookie cookie : this.cookies) {
    zr.addCookie(
        new ZestCookie(
            cookie.getDomain(),
            cookie.getName(),
            cookie.getValue(),
            cookie.getPath(),
            cookie.getExpiryDate(),
            cookie.isSecure()));
  }
  zr.setEnabled(this.isEnabled());
  return zr;
}

代码示例来源:origin: mozilla/zest

@Test
public void testIsTrueFalse() {
  ZestExpressionURL urlExpr = new ZestExpressionURL();
  urlExpr.setIncludeRegexes(includeStrings);
  urlExpr.setExcludeRegexes(excludeStrings);
  try {
    ZestRequest request = new ZestRequest();
    request.setUrl(new URL("http://www.PONG1.com"));
    assertFalse(urlExpr.isTrue(new TestRuntime(request)));
  } catch (MalformedURLException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: mozilla/zest

@Test
public void testIsTrueDifferentURL() {
  ZestExpressionURL urlExpr = new ZestExpressionURL();
  urlExpr.setIncludeRegexes(includeStrings);
  urlExpr.setExcludeRegexes(excludeStrings);
  try {
    ZestRequest request = new ZestRequest();
    request.setUrl(new URL("http://www.asdf.com"));
    assertFalse(urlExpr.isTrue(new TestRuntime(request)));
  } catch (MalformedURLException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: mozilla/zest

@Test
public void testIsTrue() {
  ZestExpressionURL urlExpr = new ZestExpressionURL();
  urlExpr.setIncludeRegexes(includeStrings);
  urlExpr.setExcludeRegexes(excludeStrings);
  try {
    ZestRequest request = new ZestRequest();
    request.setUrl(new URL("http://www.PING1.com"));
    assertTrue(urlExpr.isTrue(new TestRuntime(request)));
  } catch (MalformedURLException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: mozilla/zest

String method = "POST";
request.setMethod(method);
request.setUrl(url);
String headers =
    "User-Agent: xyz\r\n"

代码示例来源:origin: mozilla/zest

request.setMethod("GET");
request.setHeaders(requestH);
request.setUrl(new URL("http://localhost:8080/bodgeit/"));

代码示例来源:origin: mozilla/zest

ZestRequest req = new ZestRequest();
req.setUrl(new URL("http://www.example.com/app/{{token1}}"));
req.setHeaders("Set-Cookie: test={{token2}}");
req.setData("test={{token3}}&user=12{{token3}}34");

代码示例来源:origin: mozilla/zest

ZestRequest req = new ZestRequest();
req.setUrl(new URL("http://www.example.com/app/{{token1}}"));
req.setHeaders("Set-Cookie: test={{token2}}");
req.setData("test={{token3}}&user=12{{token3}}34");

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com