JMeter XML Schema的相对路径? [英] Relative path for JMeter XML Schema?

查看:169
本文介绍了JMeter XML Schema的相对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JMeter 2.6,并具有以下测试设置:

I'm using JMeter 2.6, and have the following setup for my test:

-
|-test.jmx
|-myschema.xsd

我已经设置了XML模式声明,并在文件名"字段中键入"myschema.xsd".不幸的是,这行不通:

I've set up an XML Schema Assertion, and typed "myschema.xsd" in the File Name field. Unfortunately, this doesn't work:

HTTP Request
Output schema : error: line=1 col=114 schema_reference.4:
Failed to read schema document 'myschema.xsd', because 
1) could not find the document; 
2) the document could not be read; 
3) the root element of the document is not <xsd:schema>.

我尝试向path中添加一些内容,包括${__P(user.dir)}(指向用户的home dir)和${__BeanShell(pwd())}(不返回任何内容).我通过给出绝对路径使它正常工作,但是该脚本应该由其他人使用,所以那不好.

I've tried adding several things to the path, including ${__P(user.dir)} (points to the home dir of the user) and ${__BeanShell(pwd())} (doesn't return anything). I got it working by giving the absolute path, but the script is supposed to be used by others, so that's no good.

我可以使它使用命令行中定义的属性值,但出于同样的原因,我也想避免使用它.

I could make it use a property value defined in the command line, but I'd like to avoid it as well, for the same reason.

在这种情况下如何正确地将断言指向架构?

推荐答案

摘要:最后,我使用了

Summary: in the end I've used http://path.to.schema/myschema.xsd as the File Name parameter in the Assertion.

说明::按照Alies Belik的建议,我发现用于设置架构的代码如下所示:

Explanation: following Alies Belik's advice, I've found that the code for setting up the schema looks something like this:

DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
...
parserFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdFileName);

其中xsdFileName是一个字符串(属性字符串实际上是一个常量,出于可读性考虑,我将其内联).

where xsdFileName is a string (the attribute string is actually a constant, I inlined it for readability).

例如此页面,该属性以字符串形式表示时为解释为URI-包括HTTP URL.由于已经有了可通过HTTP访问的架构,因此我选择了此解决方案.

According to e.g. this page, the attribute, when in the form a String, is interpreted as an URI - which includes HTTP URLs. Since I already have the schema accessible through HTTP, I've opted for this solution.

这篇关于JMeter XML Schema的相对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆