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

x33g5p2x  于2022-02-05 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(80)

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

ZestVariables.replaceInString介绍

暂无

代码示例

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

@Override
public String replaceVariablesInString(String str, boolean urlEncode) {
  return this.variables.replaceInString(str, urlEncode);
}

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

public String replaceInString(String str, boolean urlEncode) {
    List<String> prev = new ArrayList<String>();
    return this.replaceInString(str, urlEncode, prev);
  }
}

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

@Override
public String replaceVariablesInString(String str, boolean urlEncode) {
  return vars.replaceInString(str, urlEncode);
}

代码示例来源: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

return this.replaceInString(str, urlEncode, previous);

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

@Test
public void shouldReturnNullStringIfReplacingVariablesInNullString() throws Exception {
  // Given
  ZestVariables zestVars = new ZestVariables();
  // When
  String finalString = zestVars.replaceInString(null, false);
  // Then
  assertTrue(finalString == null);
}

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

@Test
public void shouldReplaceVariablesInVariablesInString() throws Exception {
  // Given
  ZestVariables zestVars = new ZestVariables();
  zestVars.setVariable("Var1", "-1 < " + token(zestVars, "Var2"));
  zestVars.setVariable("Var2", token(zestVars, "Var3"));
  zestVars.setVariable("Var3", "1");
  String string = token(zestVars, "Var1") + " <= " + token(zestVars, "Var3");
  // When
  String finalString = zestVars.replaceInString(string, false);
  // Then
  assertTrue("-1 < 1 <= 1".equals(finalString));
}

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

@Test
public void shouldReplaceVariablesInString() throws Exception {
  // Given
  ZestVariables zestVars = new ZestVariables();
  zestVars.setVariable("Var1", "0");
  zestVars.setVariable(null, "1");
  zestVars.setVariable("Var3", null);
  String string =
      token(zestVars, "Var1")
          + " < "
          + token(zestVars, null)
          + " != ["
          + token(zestVars, "Var3")
          + "]";
  // When
  String finalString = zestVars.replaceInString(string, false);
  // Then
  assertTrue("0 < 1 != []".equals(finalString));
}

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

@Test
public void shouldReplaceEncodedVariablesInString() throws Exception {
  // Given
  ZestVariables zestVars = new ZestVariables();
  zestVars.setVariable("Var%", "0");
  zestVars.setVariable(null, "1");
  zestVars.setVariable("Var&", null);
  String string =
      urlencoded(token(zestVars, "Var%"))
          + " < "
          + token(zestVars, null)
          + " != ["
          + urlencoded(token(zestVars, "Var&"))
          + "]";
  boolean encode = true;
  // When
  String finalString = zestVars.replaceInString(string, encode);
  // Then
  assertTrue("0 < 1 != []".equals(finalString));
}

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

result = this.variables.replaceInString(zr.getValue(), false);
debug(stmt.getIndex() + " Return " + result);
return null;

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

@Test
public void shouldReplaceLoopingVariablesInVariablesInString() throws Exception {
  // Given
  ZestVariables zestVars = new ZestVariables();
  zestVars.setVariable("Var1", "No Loop: " + token(zestVars, "Var2"));
  zestVars.setVariable("Var2", "[" + token(zestVars, "Var3") + "]");
  zestVars.setVariable("Var3", token(zestVars, "Var2"));
  String string = token(zestVars, "Var1") + " | " + token(zestVars, "Var3");
  // When
  String finalString = zestVars.replaceInString(string, false);
  // Then
  assertTrue(
      ("No Loop: [" + token(zestVars, "Var2") + "] | " + token(zestVars, "Var2"))
          .equals(finalString));
}

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

@Test
public void shouldReplaceVariablesInEncodedVariablesInString() throws Exception {
  // Given
  ZestVariables zestVars = new ZestVariables();
  zestVars.setVariable("Var%", "-1 < " + token(zestVars, "Var&"));
  zestVars.setVariable("Var&", urlencoded(token(zestVars, "Var?")));
  zestVars.setVariable("Var?", "1");
  String string =
      urlencoded(token(zestVars, "Var%")) + " <= " + urlencoded(token(zestVars, "Var?"));
  boolean encode = true;
  // When
  String finalString = zestVars.replaceInString(string, encode);
  // Then
  assertTrue("-1 < 1 <= 1".equals(finalString));
}

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

@Test
public void shouldReplaceLoopingVariablesInEncodedVariablesInString() throws Exception {
  // Given
  ZestVariables zestVars = new ZestVariables();
  zestVars.setVariable("Var1", "No Loop: " + token(zestVars, "Var2"));
  zestVars.setVariable("Var2", "[" + token(zestVars, "Var3") + "]");
  zestVars.setVariable("Var3", token(zestVars, "Var2"));
  String string =
      urlencoded(token(zestVars, "Var1")) + " | " + urlencoded(token(zestVars, "Var3"));
  boolean encode = true;
  // When
  String finalString = zestVars.replaceInString(string, encode);
  // Then
  assertTrue(
      ("No Loop: ["
              + token(zestVars, "Var2")
              + "] | "
              + urlencoded(token(zestVars, "Var3")))
          .equals(finalString));
}

相关文章