本文整理了Java中org.mozilla.zest.core.v1.ZestExpressionURL
类的一些代码示例,展示了ZestExpressionURL
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestExpressionURL
类的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestExpressionURL
类名称:ZestExpressionURL
[英]The Class ZestExpressionURL.
[中]ZestExpressionURL类。
代码示例来源:origin: mozilla/zest
@Override
public ZestExpressionURL deepCopy() {
ZestExpressionURL copy = new ZestExpressionURL();
List<String> copyIncludeRegex = new ArrayList<>(includeRegexes);
List<String> copyExcludeRegex = new ArrayList<>(excludeRegexes);
copy.setIncludeRegexes(copyIncludeRegex);
copy.setExcludeRegexes(copyExcludeRegex);
copy.setInverse(isInverse());
return copy;
}
代码示例来源:origin: mozilla/zest
/**
* Instantiates a new zest expression url.
*
* @param includeRegexes the include regexes
* @param excludeRegexes the exclude regexes
*/
public ZestExpressionURL(List<String> includeRegexes, List<String> excludeRegexes) {
this.setIncludeRegexes(includeRegexes);
this.setExcludeRegexes(excludeRegexes);
}
代码示例来源: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 testDeepCopyNoPointer() {
ZestExpressionURL urlExpr = new ZestExpressionURL(includeStrings, excludeStrings);
ZestExpressionURL copy = urlExpr.deepCopy();
urlExpr.setExcludeRegexes(null);
urlExpr.setIncludeRegexes(null);
for (int i = 0; i < includeSize; i++) {
String obtained = copy.getIncludeRegexes().get(i);
String msg = "INCLUDE: " + i;
assertTrue(msg, includeStrings.get(i).equals(obtained));
}
for (int i = 0; i < excludeSize; i++) {
String obtained = copy.getExcludeRegexes().get(i);
String msg = "EXCLUDE: " + i;
assertTrue(msg, excludeStrings.get(i).equals(obtained));
}
}
代码示例来源:origin: mozilla/zest
@Test
public void testDeepCopy() {
ZestExpressionURL urlExpr = new ZestExpressionURL(includeStrings, excludeStrings);
urlExpr.setInverse(true);
ZestExpressionURL copy = urlExpr.deepCopy();
assertEquals(copy.isInverse(), urlExpr.isInverse());
for (int i = 0; i < includeSize; i++) {
String obtained = copy.getIncludeRegexes().get(i);
String expected = includeStrings.get(i);
String msg = "INCLUDE: expected " + expected + " instead of " + obtained;
assertTrue(msg, expected.equals(obtained));
}
for (int i = 0; i < excludeSize; i++) {
String obtained = copy.getExcludeRegexes().get(i);
String expected = excludeStrings.get(i);
String msg = "EXCLUDE: expected " + expected + " instead of " + obtained;
assertTrue(msg, expected.equals(obtained));
}
}
代码示例来源:origin: mozilla/zest
@Test
public void testGetExcludeRegexes() {
ZestExpressionURL urlExpr = new ZestExpressionURL();
urlExpr.setExcludeRegexes(excludeStrings);
urlExpr.setIncludeRegexes(includeStrings);
List<String> excludeRegex = urlExpr.getExcludeRegexes();
for (int i = 0; i < excludeSize; i++) {
String obtained = excludeRegex.get(i);
String expected = excludeStrings.get(i);
String msg = "EXCLUDE: expected " + expected + " instead of " + obtained;
assertTrue(msg, expected.equals(obtained));
}
}
代码示例来源:origin: mozilla/zest
@Test
public void testGetIncludeRegexes() {
ZestExpressionURL urlExpr = new ZestExpressionURL();
urlExpr.setExcludeRegexes(excludeStrings);
urlExpr.setIncludeRegexes(includeStrings);
List<String> includeRegex = urlExpr.getIncludeRegexes();
for (int i = 0; i < includeSize; i++) {
String obtained = includeRegex.get(i);
String expected = includeStrings.get(i);
String msg = "INCLUDE: expected " + expected + " instead of " + obtained;
assertTrue(msg, expected.equals(obtained));
}
}
代码示例来源:origin: mozilla/zest
@Test
public void testZestExpressionURLListOfStringListOfString() {
ZestExpressionURL urlExpr = new ZestExpressionURL(includeStrings, excludeStrings);
for (int i = 0; i < includeSize; i++) {
String obtained = urlExpr.getIncludeRegexes().get(i);
String expected = "PING" + i;
String msg = "INCLUDE Expected " + expected + " instead of" + obtained;
assertTrue(msg, expected.equals(obtained));
}
for (int i = 0; i < excludeSize; i++) {
String obtained = urlExpr.getExcludeRegexes().get(i);
String expected = "PONG" + i;
String msg = "EXCLUDE Expected " + expected + " instead of" + obtained;
assertTrue(msg, expected.equals(obtained));
}
}
代码示例来源:origin: mozilla/zest
LinkedList<String> excludeRegex = new LinkedList<>();
excludeRegex.add("");
ZestExpressionURL url = new ZestExpressionURL(includeRegex, excludeRegex);
url.setInverse(true);
time.setGreaterThan(true);
ZestExpression genericExp =
代码示例来源: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
@Override
public String toString() {
StringBuilder expression = new StringBuilder(150);
if (isInverse()) {
expression.append("NOT ");
}
expression.append("URL: ACCEPT:");
for (String s : includeRegexes) {
expression.append(' ').append(s);
}
expression.append(", EXCLUDE:");
for (String s : excludeRegexes) {
expression.append(' ').append(s);
}
return expression.toString();
}
}
代码示例来源:origin: mozilla/zest
@Override
public boolean isTrue(ZestRuntime runtime) {
ZestRequest req = runtime.getLastRequest();
if (req == null) {
return false;
}
String url = req.getUrl().toString();
boolean inc = false;
if (this.includePatterns == null) {
this.initPatterns();
}
for (Pattern pattern : includePatterns) {
if (pattern.matcher(url).find()) {
inc = true;
break;
}
}
if (!inc) {
// Not explicitly included
return false;
}
for (Pattern pattern : excludePatterns) {
if (pattern.matcher(url).find()) {
// explicitly excluded
return false;
}
}
// Included and not excluded
return true;
}
代码示例来源: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();
}
}
内容来源于网络,如有侵权,请联系作者删除!