I can get the proper relationship between requests, but now the timer is

not correct
This commit is contained in:
Tienan Chen 2013-12-06 16:05:48 +08:00
parent c43a9494fd
commit 7a1b15147a
4 changed files with 32 additions and 5 deletions

View File

@ -330,7 +330,8 @@ public abstract class AbstractCodeGenerator implements IScriptGenerator,
return;
}
String respStr = new String(response).toLowerCase();
String responseWithProperCase = new String(response);
String respStr = responseWithProperCase.toLowerCase();
String respCode = parseResponseCode(respStr);
String contentType = parseContentType(respStr);
@ -347,7 +348,7 @@ public abstract class AbstractCodeGenerator implements IScriptGenerator,
if (contentType.toLowerCase().compareTo("text/html") == 0) {
doTidyCode(HttpTestCase.staticUrlDecode(header.url));
doParseHtmlContent(respStr, header.url);
doParseHtmlContent(responseWithProperCase, header.url);
if (cpRspToStdout)
doResponseForStdOut(HttpTestCase.staticUrlDecode(
header.url).trim());

View File

@ -218,11 +218,15 @@ public class Bench4qCodeGenerator extends AbstractCodeGenerator {
childAbsoluteUrl = element.absUrl("href");
}
System.out.println(childAbsoluteUrl);
int parentBatchId = this.getScriptAdapter()
.getParentBatchIdWithParentUrl(rootUrl);
if (parentBatchId == -1) {
continue;
}
this.getScriptAdapter()
.getChildrenUrls()
.add(ChildrenUrl.createChilldUrl(childAbsoluteUrl,
this.getScriptAdapter()
.getParentBatchIdWithParentUrl(rootUrl)));
parentBatchId));
}
}

View File

@ -19,13 +19,17 @@ public class TestDomGenerator extends TestRecordBase {
@Test
public void testDomParser() throws IOException {
this.getCodeGenerator()
.getScriptAdapter()
.insertUserBehaviorsToScenario(
createUserBehaviorModel(parentUrl));
this.getCodeGenerator().doParseHtmlContent(
FileUtils.readFileToString(new File(url.getPath())), parentUrl);
assertTrue(this.getCodeGenerator().getScriptAdapter().getChildrenUrls()
.size() == 8);
for (ChildrenUrl childrenUrl : this.getCodeGenerator()
.getScriptAdapter().getChildrenUrls()) {
assertTrue(childrenUrl.getParentBatchId() == -1);
assertTrue(childrenUrl.getParentBatchId() == 0);
}
}
@ -47,4 +51,21 @@ public class TestDomGenerator extends TestRecordBase {
assertTrue(childrenUrl.getParentBatchId() == 1);
}
}
@Test
public void testDomParserWithIncorrectParentUrl() throws IOException {
this.getAdpater().insertUserBehaviorsToScenario(
createUserBehaviorModel(parentUrl));
this.getAdpater().insertUserBehaviorsToScenario(
createUserBehaviorModel(independentUrl));
this.getCodeGenerator().doParseHtmlContent(
FileUtils.readFileToString(new File(this.url.getPath())),
parentUrl + "error");
assertTrue(this.getCodeGenerator().getScriptAdapter().getChildrenUrls()
.size() == 0);
}
public void testChildUrlWithNotProperCase() {
}
}

View File

@ -15,6 +15,7 @@ public abstract class TestRecordBase {
private Bench4qCodeGenerator codeGenerator;
protected static String parentUrl = "http://localhost:8080/Bench4QTestCase/testcase.html";
protected static String independentUrl = "www.baidu.com";
protected static String childrenUrl1 = "http://localhost:8080/Bench4QTestCase/script/agenttable.js";
protected IScriptAdapter getAdpater() {
return adapter;