Commit 37321658 37321658e8f68fecc605c1719d7955fc4811dcc0 by Christian Gerdes

- Fixed null ref errors on empty json/xml body

- Added PassIfNotFound to XPathExtractionRule
1 parent 34618ddb
......@@ -87,6 +87,8 @@ namespace WebTest.WebService.Plugin.ResultTab
try
{
this.dom = dom;
if (dom.DocumentElement != null)
{
XmlNode xNode = dom.DocumentElement;
// Load the XML into the TreeView.
......@@ -106,6 +108,7 @@ namespace WebTest.WebService.Plugin.ResultTab
treeView.Nodes.Add(treeNode);
treeNode.Collapse();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
......
......@@ -52,6 +52,11 @@ namespace WebTest.WebService.Plugin.Runtime
set { randomMatch = value; }
}
[DisplayName("Pass if not found")]
[Description("If set to true, this rule will pass the request even if no match is found.")]
[DefaultValue(false)]
public bool passIfNotFound { get; set; }
/// <summary>
/// The Extract method. The parameter e contains the Web test context.
/// </summary>
......@@ -62,11 +67,7 @@ namespace WebTest.WebService.Plugin.Runtime
try
{
ContentHandler contentHandler = ContentHandlerFactory.GetHandler(e.Response.ContentType);
if (contentHandler == null)
{
return;
}
if (contentHandler != null) {
if (contentHandler.IsBinary)
{
contentHandler.MessageBytes = e.Response.BodyBytes;
......@@ -114,12 +115,14 @@ namespace WebTest.WebService.Plugin.Runtime
return;
}
}
}
catch (Exception ex)
{
e.Message = ex.Message;
}
e.Success = false;
e.Success = passIfNotFound;
e.Message += " (XPath not found)";
return;
}
}
......