本文整理了Java中org.mozilla.zest.core.v1.ZestExpressionProtocol
类的一些代码示例,展示了ZestExpressionProtocol
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestExpressionProtocol
类的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestExpressionProtocol
类名称:ZestExpressionProtocol
[英]A ZestExpression that checks if the ZestRuntime#getLastRequest() has a given protocol (for example, HTTPS).
The check is done in a case-insensitive manner. The expression returns false if no protocol was set (that is, null).
[中]一种ZestExpression,用于检查ZestRuntime#getLastRequest()是否具有给定的协议(例如HTTPS)。
检查是以不区分大小写的方式进行的。如果未设置协议,则表达式返回false(即null)。
代码示例来源:origin: mozilla/zest
@Test
public void shouldDeepCopy() {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol("https");
protocolExpression.setInverse(true);
// When
ZestExpressionProtocol copyProtocolExpression = protocolExpression.deepCopy();
// Then
assertTrue(copyProtocolExpression != protocolExpression);
assertEquals(copyProtocolExpression.getProtocol(), protocolExpression.getProtocol());
assertEquals(copyProtocolExpression.isInverse(), protocolExpression.isInverse());
}
代码示例来源:origin: mozilla/zest
@Override
public ZestExpressionProtocol deepCopy() {
return new ZestExpressionProtocol(protocol, isInverse());
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldEvaluateToFalseIfNoRequest() throws Exception {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol("http");
// When
boolean result = protocolExpression.evaluate(new TestRuntime());
// Then
assertFalse(result);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldSerialiseAndDeserialise() {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol("http");
// When
String serialisation = ZestJSON.toString(protocolExpression);
ZestExpressionProtocol deserialisedProtocolExpression =
(ZestExpressionProtocol) ZestJSON.fromString(serialisation);
// Then
assertTrue(deserialisedProtocolExpression != protocolExpression);
assertEquals(
deserialisedProtocolExpression.getProtocol(), protocolExpression.getProtocol());
assertEquals(deserialisedProtocolExpression.isInverse(), protocolExpression.isInverse());
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldSetProtocol() {
// Given
String protocol = "http";
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol();
// When
protocolExpression.setProtocol(protocol);
// Then
assertEquals(protocol, protocolExpression.getProtocol());
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldSetInverse() {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol();
// When
protocolExpression.setInverse(true);
// Then
assertTrue(protocolExpression.isInverse());
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldEvaluateToTrueIfInverseAndNotSameProtocol() throws Exception {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol("https");
protocolExpression.setInverse(true);
ZestRequest request = createRequest("http://localhost/");
// When
boolean result = protocolExpression.evaluate(new TestRuntime(request));
// Then
assertTrue(result);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldNotHaveProtocolByDefault() {
// Given / When
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol();
// Then
assertTrue(protocolExpression.getProtocol() == null);
}
代码示例来源:origin: mozilla/zest
@Override
public String toString() {
return (isInverse() ? "NOT " : "") + "Protocol: " + protocol;
}
}
代码示例来源:origin: mozilla/zest
} else if (element instanceof ZestExpressionProtocol) {
ZestExpressionProtocol lengthExpr = (ZestExpressionProtocol) element;
System.out.print("Protocol: " + lengthExpr.getProtocol());
代码示例来源:origin: mozilla/zest
@Test
public void shouldEvaluateToTrueIfSameProtocol() throws Exception {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol("http");
ZestRequest request = createRequest("http://localhost/");
// When
boolean result = protocolExpression.evaluate(new TestRuntime(request));
// Then
assertTrue(result);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldEvaluateToFalseIfInverseAndSameProtocol() throws Exception {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol("http");
protocolExpression.setInverse(true);
ZestRequest request = createRequest("http://localhost/");
// When
boolean result = protocolExpression.evaluate(new TestRuntime(request));
// Then
assertFalse(result);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldNotBeInversedByDefault() {
// Given / When
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol();
// Then
assertFalse(protocolExpression.isInverse());
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldEvaluateToFalseIfRequestButNoUrl() throws Exception {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol("http");
ZestRequest request = createRequest();
// When
boolean result = protocolExpression.evaluate(new TestRuntime(request));
// Then
assertFalse(result);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldEvaluateToFalseIfNoProtocolSet() throws Exception {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol();
ZestRequest request = createRequest("http://localhost/");
// When
boolean result = protocolExpression.evaluate(new TestRuntime(request));
// Then
assertFalse(result);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldEvaluateToTrueIfSameProtocolWithDifferenceCase() throws Exception {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol("HTTP");
ZestRequest request = createRequest("http://localhost/");
// When
boolean result = protocolExpression.evaluate(new TestRuntime(request));
// Then
assertTrue(result);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldEvaluateToFalseIfNotSameProtocol() throws Exception {
// Given
ZestExpressionProtocol protocolExpression = new ZestExpressionProtocol("https");
ZestRequest request = createRequest("http://localhost/");
// When
boolean result = protocolExpression.evaluate(new TestRuntime(request));
// Then
assertFalse(result);
}
内容来源于网络,如有侵权,请联系作者删除!