org.mozilla.zest.core.v1.ZestExpressionRegex类的使用及代码示例

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

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

ZestExpressionRegex介绍

[英]The Class ZestExpressionRegex.
[中]类ZestExpressionRegex。

代码示例

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

@Test
  public void testEvaluateAlone() {
    new ZestExpressionRegex();
  }
}

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

@Override
public ZestExpressionRegex deepCopy() {
  return new ZestExpressionRegex(
      this.getVariableName(), this.getRegex(), this.isCaseExact(), this.isInverse());
}

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

@Test
public void testIsInverse() {
  ZestExpressionRegex regex = new ZestExpressionRegex(ZestVariables.REQUEST_HEADER, "");
  ZestExpressionRegex copy = regex.deepCopy();
  copy.setInverse(true);
  regex.setInverse(false);
  assertTrue(copy.isInverse() && !regex.isInverse());
}

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

@Test
public void testDeepCopySameNoPointersRegex() {
  ZestExpressionRegex regex = new ZestExpressionRegex(ZestVariables.RESPONSE_HEADER, "PING");
  ZestExpressionRegex copy = regex.deepCopy();
  copy.setRegex("PONG");
  assertFalse(regex.getRegex().equals(copy.getRegex()));
}

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

@Test
public void testDeepCopySameNoPointersLocation() {
  ZestExpressionRegex regex = new ZestExpressionRegex(ZestVariables.RESPONSE_HEADER, "PING");
  ZestExpressionRegex copy = regex.deepCopy();
  copy.setVariableName(ZestVariables.RESPONSE_BODY);
  assertFalse(regex.getVariableName().equals(copy.getVariableName()));
}

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

@Test
public void testIsTrueNullHeader() {
  ZestResponse response = new ZestResponse(null, null, null, 0, 0);
  ZestExpressionRegex regex = new ZestExpressionRegex(ZestVariables.RESPONSE_HEADER, "");
  assertFalse(regex.isTrue(new TestRuntime(response)));
}

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

@Test
public void testDeepCopySameLocation() {
  ZestExpressionRegex regex = new ZestExpressionRegex(ZestVariables.RESPONSE_HEADER, "PING");
  ZestExpressionRegex copy = regex.deepCopy();
  assertTrue(regex.getVariableName().equals(copy.getVariableName()));
}

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

@Test
public void testDeepCopySameRegex() {
  ZestExpressionRegex regex = new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "PING");
  ZestExpressionRegex copy = regex.deepCopy();
  assertTrue(regex.getRegex().equals(copy.getRegex()));
}

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

@Test
public void shouldAllowToSetNullRegex() {
  // Given
  String nullRegex = null;
  ZestExpressionRegex regex = new ZestExpressionRegex("VarName", "");
  // When
  regex.setRegex(nullRegex);
  // Then
  assertTrue(regex.getRegex() == null);
}

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

@Test
public void testSetInverse() {
  ZestExpressionRegex regex =
      new ZestExpressionRegex(ZestVariables.RESPONSE_HEADER, "", false, false);
  regex.setInverse(true);
  assertTrue(regex.isInverse());
}

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

@Test
public void shouldEvaluateAlwaysToFalseWithNullRegex() {
  // Given
  String nullRegex = null;
  String varName = "VarName";
  ZestExpressionRegex expressionRegex = new ZestExpressionRegex(varName, nullRegex);
  for (String varValue : Arrays.asList("", "Some value", "A\nB", "$", ".")) {
    // When
    boolean evalution = expressionRegex.evaluate(createRuntime(varName, varValue));
    // Then
    assertFalse("String \"" + varValue + "\" evaludated to false.", evalution);
  }
}

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

ZestExpressionRegex regexExpr = (ZestExpressionRegex) element;
  System.out.print(
      "Regex: " + regexExpr.getVariableName() + " " + regexExpr.getRegex());
} else if (element instanceof ZestExpressionResponseTime) {
  ZestExpressionResponseTime timeExpr = (ZestExpressionResponseTime) element;

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

@Test
public void testIsLeaf() {
  ZestExpressionRegex regex = new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "");
  assertTrue(regex.isLeaf());
}

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

@Override
  public String toString() {
    String expression = (isInverse() ? "NOT " : "") + "REGEX: " + regex;
    return expression;
  }
}

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

@Test
public void testIsTrueHeader() {
  ZestResponse response =
      new ZestResponse(null, "123456header654321", "987654body456789", 200, 100);
  ZestExpressionRegex regexExpr =
      new ZestExpressionRegex(ZestVariables.RESPONSE_HEADER, "head");
  assertTrue(regexExpr.isTrue(new TestRuntime(response)));
}

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

@Test
public void shouldEvaluateAlwaysToTrueWithEmptyRegex() {
  // Given
  String emptyRegex = "";
  String varName = "VarName";
  ZestExpressionRegex expressionRegex = new ZestExpressionRegex(varName, emptyRegex);
  for (String varValue : Arrays.asList("", "Some value", "A\nB", "$", ".")) {
    // When
    boolean evalution = expressionRegex.evaluate(createRuntime(varName, varValue));
    // Then
    assertTrue("String \"" + varValue + "\" evaludated to false.", evalution);
  }
}

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

/**
 * Method testDeepConditionals1.
 *
 * @throws Exception
 */
@Test
public void testDeepConditionals1() throws Exception {
  ZestConditional zc1 = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestConditional zc2 = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  zc1.addIf(zc2);
  zc2.addIf(req1);
  zc1.addElse(req2);
  checkOrder(new ZestStatement[] {zc1, zc2, req1, req2, null});
}

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

@Test
public void testIsTrueBody() {
  ZestResponse response =
      new ZestResponse(null, "123456header654321", "987654body456789", 200, 100);
  ZestExpressionRegex regexExpr =
      new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "body");
  assertTrue(regexExpr.isTrue(new TestRuntime(response)));
}

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

/**
 * Method testDeepConditionals1.
 *
 * @throws Exception
 */
@Test
public void testDeepConditionals1() throws Exception {
  ZestConditional zc1 = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestConditional zc2 = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  zc1.addIf(zc2);
  zc2.addIf(req1);
  zc1.addElse(req2);
  checkOrder(new ZestStatement[] {zc1, zc2, req1, req2, null});
}

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

@Test
public void testIsTrueNullBody() {
  ZestResponse response = new ZestResponse(null, null, null, 0, 0);
  ZestExpressionRegex regexExpr = new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "");
  assertFalse(regexExpr.isTrue(new TestRuntime(response)));
}

相关文章