本文整理了Java中org.mozilla.zest.core.v1.ZestResponse.<init>()
方法的一些代码示例,展示了ZestResponse.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestResponse.<init>()
方法的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestResponse
类名称:ZestResponse
方法名:<init>
[英]Instantiates a new zest response.
[中]实例化一个新的热情响应。
代码示例来源:origin: mozilla/zest
@Override
public ZestResponse deepCopy() {
ZestResponse zr =
new ZestResponse(
this.url, this.headers, this.body, this.statusCode, this.responseTimeInMs);
return zr;
}
代码示例来源:origin: mozilla/zest
private ZestResponse makeZestResponse(String pageContent) {
String html = String.format(htmlScaffold, pageContent);
String notRelevantHeader = "Header not relevant";
URL notRelevantUrl = null;
return new ZestResponse(notRelevantUrl, notRelevantHeader, html, 200, 0);
}
}
代码示例来源:origin: mozilla/zest
private static ZestResponse createResponse(int statusCode) throws Exception {
return new ZestResponse(new URL("http://localhost/"), "", "", statusCode, 0);
}
}
代码示例来源:origin: mozilla/zest
@Test
public void testSimpleCaseExact() throws Exception {
ZestExpressionRegex regex =
new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "test123", true, false);
ZestAssertion ze = new ZestAssertion(regex);
assertTrue(ze.isValid(new TestRuntime(new ZestResponse(null, "", "aaaatest123", 200, 0))));
assertFalse(ze.isValid(new TestRuntime(new ZestResponse(null, "", "aaaaTest123", 200, 0))));
}
代码示例来源:origin: mozilla/zest
@Test
public void testSimpleCaseIgnore() throws Exception {
ZestExpressionRegex regex =
new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "test123", false, false);
ZestAssertion ze = new ZestAssertion(regex);
assertTrue(ze.isValid(new TestRuntime(new ZestResponse(null, "", "aaaatest123", 200, 0))));
assertTrue(ze.isValid(new TestRuntime(new ZestResponse(null, "", "aaaaTest123", 200, 0))));
}
代码示例来源:origin: mozilla/zest
@Test
public void testIsTrueExcludePattern() {
try {
ZestResponse response =
new ZestResponse(new URL("http://www.PONG19874.com"), "", "", 200, 100);
ZestExpressionURL urlExpr = new ZestExpressionURL(includeStrings, excludeStrings);
assertFalse(urlExpr.isTrue(new TestRuntime(response)));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: mozilla/zest
/**
* Method testSimpleIncRegex.
*
* @throws Exception
*/
@Test
public void testSimpleIncRegex() throws Exception {
ZestExpressionRegex regex = new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "test123");
ZestAssertion ze = new ZestAssertion(regex);
assertTrue(ze.isValid(new TestRuntime(new ZestResponse(null, "", "aaaatest123", 200, 0))));
}
代码示例来源:origin: mozilla/zest
/**
* Method testSimpleIncInvRegex.
*
* @throws Exception
*/
@Test
public void testSimpleIncInvRegex() throws Exception {
ZestExpressionRegex regex =
new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "test123", false, true);
ZestAssertion ze = new ZestAssertion(regex);
assertFalse(ze.isValid(new TestRuntime(new ZestResponse(null, "", "aaaatest123", 200, 0))));
}
代码示例来源:origin: mozilla/zest
/**
* Method testSimpleExcRegex.
*
* @throws Exception
*/
@Test
public void testSimpleExcRegex() throws Exception {
ZestExpressionRegex regex = new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "test123");
ZestAssertion ze = new ZestAssertion(regex);
assertFalse(ze.isValid(new TestRuntime(new ZestResponse(null, "", "aaaatst123", 200, 0))));
}
代码示例来源:origin: mozilla/zest
/**
* Method testSimpleExcInvRegex.
*
* @throws Exception
*/
@Test
public void testSimpleExcInvRegex() throws Exception {
ZestExpressionRegex regex =
new ZestExpressionRegex(ZestVariables.RESPONSE_BODY, "test123", false, true);
ZestAssertion ze = new ZestAssertion(regex);
assertTrue(ze.isValid(new TestRuntime(new ZestResponse(null, "", "aaaatst123", 200, 0))));
}
}
代码示例来源:origin: mozilla/zest
public void testIsTrueDeepCopyDifferentGreaterThan() {
ZestExpressionResponseTime timeExpr = new ZestExpressionResponseTime(1000);
ZestExpressionResponseTime copy = timeExpr.deepCopy();
timeExpr.setGreaterThan(false);
ZestRuntime runtime = new TestRuntime(new ZestResponse(null, "", "", 100, 10));
assertTrue(timeExpr.isTrue(runtime) && !copy.isTrue(runtime));
}
}
代码示例来源: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
@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)));
}
代码示例来源:origin: mozilla/zest
/**
* Method testSimpleJsScript.
*
* @throws Exception
*/
@Test
public void testSimpleJsScript() throws Exception {
ZestActionInvoke inv = new ZestActionInvoke();
inv.setVariableName("test");
inv.setScript(
ZestActionInvokeUnitTest.class.getResource("/data/simple-script.js").getPath());
TestRuntime rt = new TestRuntime();
ZestResponse resp =
new ZestResponse(
null, "Header prefix12345postfix", "Body Prefix54321Postfix", 200, 0);
String result = inv.invoke(resp, rt);
assertEquals("abcde", result);
}
代码示例来源: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 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 testIsTrueNullBody() {
ZestResponse resp = new ZestResponse(null, null, null, 0, 0);
ZestExpressionLength length = new ZestExpressionLength("response.body", 100, 100);
assertFalse(length.isTrue(new TestRuntime(resp)));
}
}
代码示例来源:origin: mozilla/zest
@Test
public void testIsTrueGreaterThan() {
ZestExpressionResponseTime timeExpr = new ZestExpressionResponseTime(0);
timeExpr.setGreaterThan(true);
ZestResponse response = new ZestResponse(null, "", "", 200, 100);
assertTrue(timeExpr.isTrue(new TestRuntime(response)));
}
代码示例来源:origin: mozilla/zest
@Test
public void testEvaluate() {
ZestExpressionResponseTime timeExpr = new ZestExpressionResponseTime(1000);
timeExpr.setGreaterThan(false);
ZestResponse response = new ZestResponse(null, "", "", 100, 10);
assertTrue(timeExpr.evaluate(new TestRuntime(response)));
}
代码示例来源:origin: mozilla/zest
@Test
public void testEvaluateGreaterThanIsInverse() {
ZestExpressionResponseTime timeExpTime = new ZestExpressionResponseTime(1000);
ZestResponse response = new ZestResponse(null, "", "", 200, 1000);
timeExpTime.setInverse(true);
timeExpTime.setGreaterThan(true);
assertTrue(timeExpTime.evaluate(new TestRuntime(response)));
}
内容来源于网络,如有侵权,请联系作者删除!