update the test case and refactor

This commit is contained in:
coderfengyun 2014-03-19 16:31:46 +08:00
parent 4b5aa3cb58
commit 259042343e
6 changed files with 16 additions and 21 deletions

View File

@ -0,0 +1 @@
row1;10;11~row2;20;21~row3,30,31~

View File

@ -133,8 +133,7 @@ public class InstanceControler implements SessionObject {
public String getParam(String name) {
if (!(name.startsWith("<parameters") && name.endsWith("/>")))
return name;
ParameterizationParser p = new ParameterizationParser();
return p.parse(name, this);
return ParameterizationParser.parse(name, this);
}
public void saveRuntimeParam(String name, String value) {

View File

@ -148,11 +148,13 @@ public class Para_Table {
} else if (readBuff == this.splitChar) {
tempTableRow.AddCell(target.toString());
target.clear();
continue;
} else if (readBuff == this.lineChar) {
tempTableRow.AddCell(target.toString());
result.add(tempTableRow);
target.clear();
i++;
continue;
}
target.append(readBuff);
}

View File

@ -11,7 +11,7 @@ import org.xml.sax.InputSource;
public class ParameterizationParser {
public String parse(String text, InstanceControler insCon) {
public static String parse(String text, InstanceControler insCon) {
// Pattern pattern = Pattern.compile("<parameter className=""/>");
String result = "";
try {
@ -46,8 +46,8 @@ public class ParameterizationParser {
return result;
}
private String getCurrentPackageFullName() {
return this.getClass().getName()
.substring(0, this.getClass().getName().lastIndexOf('.'));
private static String getCurrentPackageFullName() {
return ParameterizationParser.class.getName().substring(0,
ParameterizationParser.class.getName().lastIndexOf('.'));
}
}

View File

@ -1,26 +1,20 @@
package org.bench4q.agent.test.parameterization;
import static org.junit.Assert.*;
import org.bench4q.agent.parameterization.impl.InstanceControler;
import org.bench4q.share.helper.TestHelper;
import org.junit.Test;
public class TEST_UserName {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
// Para_UserNameAndPassword pp = new Para_UserNameAndPassword();
// UUID temp = java.util.UUID.randomUUID();
// pp.getUserName(temp);
@Test
public void testGetParam() throws Exception {
InstanceControler ic = new InstanceControler();
String userName = ic
.getParam("!parameters class=\"Para_UserNameAndPassword\" method=\"getUserName\" args=\"\" !!");
String passwordName = ic
.getParam("<parameters class=\"Para_UserNameAndPassword\" method=\"getPassword\" args=\"\" />");
System.out.print(userName);
System.out.print("\t");
.getParam("<parameters class=\"Para_Table\" method=\"getTableColumnValue\" args=\"file,ScenarioParameters\\param1.txt,0,sequence,;,~,2\" />");
System.out.println(passwordName);
// pp.unreg(temp);
// ic.releaseAll();
assertNotNull(passwordName);
TestHelper.invokePrivate(ic, "releaseAll", null, null);
}
}

View File

@ -18,8 +18,7 @@ public class Test_ParameterizationParser {
@Test
public void testParse() {
ParameterizationParser parameterParser = new ParameterizationParser();
String result = parameterParser.parse(
String result = ParameterizationParser.parse(
"<parameter class=\"Para_IteratorNumber\" method=\"getIteratorNumber\""
+ " type=\"crossThread\"/>", new InstanceControler());
System.out.println(result);