本文整理了Java中org.mozilla.zest.core.v1.ZestAssignString
类的一些代码示例,展示了ZestAssignString
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestAssignString
类的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestAssignString
类名称:ZestAssignString
[英]The Class ZestAssignString assigns a string (which can include other variables) to the specified variable.
[中]类ZestAssignString为指定的变量分配一个字符串(可以包含其他变量)。
代码示例来源:origin: mozilla/zest
@Override
public ZestAssignString deepCopy() {
ZestAssignString copy = new ZestAssignString(this.getVariableName(), this.string);
copy.setEnabled(this.isEnabled());
return copy;
}
代码示例来源:origin: mozilla/zest
@Test
public void testRecurse() throws Exception {
ZestAssignString ast = new ZestAssignString();
TestRuntime rt = new TestRuntime();
rt.setVariable("aaa", "aAa{{bbb}}AaA");
rt.setVariable("bbb", "bBb{{aaa}}CcC");
ast.setVariableName("c");
ast.setString("ddd{{bbb}}eee");
// Ignores recursing variables
assertEquals("dddbBbaAa{{bbb}}AaACcCeee", ast.assign(null, rt));
}
代码示例来源:origin: mozilla/zest
@Test
public void testSerialization() {
ZestAssignString assign = new ZestAssignString("var", "io;hjvd9740[w9u;sdz");
String str = ZestJSON.toString(assign);
ZestAssignString assign2 = (ZestAssignString) ZestJSON.fromString(str);
assertEquals(assign.getElementType(), assign2.getElementType());
assertEquals(assign.getVariableName(), assign2.getVariableName());
assertEquals(assign.getString(), assign2.getString());
}
}
代码示例来源:origin: mozilla/zest
/**
* Method testTokenReplacement.
*
* @throws Exception
*/
@Test
public void testAssign() throws Exception {
ZestScript script = new ZestScript();
ZestAssignString ast = new ZestAssignString();
String test1 = "fdsjik934785:P@O():*&K";
ast.setVariableName("aaa");
ast.setString(test1);
script.add(ast);
Set<String> vars = script.getVariableNames();
assertTrue(vars.contains("aaa"));
}
代码示例来源:origin: mozilla/zest
@Test
public void testDisable() throws Exception {
ZestScript script = new ZestScript();
ZestAssignString zaInit = new ZestAssignString("res", "");
ZestLoopString loop = new ZestLoopString("var", values);
ZestAssignString zaAppendVar = new ZestAssignString("res", "{{res}} {{var}}");
ZestAssignString zaAppendComma = new ZestAssignString("res", "{{res}},");
zaAppendVar.setEnabled(false);
runner.run(script, null);
assertEquals(",,,,,,,", runner.getVariable("res"));
zaAppendVar.setEnabled(true);
zaAppendComma.setEnabled(false);
runner.run(script, null);
assertEquals(" 1 2 3 4 5 6 7", runner.getVariable("res"));
zaAppendVar.setEnabled(true);
zaAppendComma.setEnabled(true);
loop.setEnabled(false);
代码示例来源:origin: mozilla/zest
/**
* Method testSimpleCase.
*
* @throws Exception
*/
@Test
public void testSimpleCase() throws Exception {
ZestAssignString ast = new ZestAssignString();
TestRuntime rt = new TestRuntime();
ZestResponse resp =
new ZestResponse(
null, "Header prefix12345postfix", "Body Prefix54321Postfix", 200, 0);
String test1 = "fdsjik934785:P@O():*&K";
ast.setVariableName("aaa");
ast.setString(test1);
assertEquals(test1, ast.assign(resp, rt));
}
代码示例来源:origin: mozilla/zest
/**
* Method testRegexes.
*
* @throws Exception
*/
@Test
public void testVariables() throws Exception {
ZestAssignString ast = new ZestAssignString();
TestRuntime rt = new TestRuntime();
// One level
rt.setVariable("aaa", "aAaAaAaA");
ast.setVariableName("a");
ast.setString("bbb{{aaa}}ccc");
assertEquals("bbbaAaAaAaAccc", ast.assign(null, rt));
// Two levels
rt = new TestRuntime();
rt.setVariable("aaa", "aAaAaAaA");
rt.setVariable("bbb", "bBb{{aaa}}CcC");
ast.setVariableName("c");
ast.setString("ddd{{bbb}}eee");
assertEquals("dddbBbaAaAaAaACcCeee", ast.assign(null, rt));
// Three levels
rt = new TestRuntime();
rt.setVariable("aaa", "aAaAaAaA");
rt.setVariable("bbb", "bBb{{aaa}}CcC");
rt.setVariable("ccc", "ddd{{bbb}}eee");
ast.setVariableName("c");
ast.setString("fFF{{ccc}}Hhh");
assertEquals("fFFdddbBbaAaAaAaACcCeeeHhh", ast.assign(null, rt));
}
内容来源于网络,如有侵权,请联系作者删除!