Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FIY695
jenkins
提交
bdf13dce
J
jenkins
项目概览
FIY695
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bdf13dce
编写于
6月 05, 2011
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added a hook to customize the XML parser behaviour.
上级
18496c54
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
93 addition
and
6 deletion
+93
-6
changelog.html
changelog.html
+3
-1
core/src/main/java/hudson/tasks/junit/SuiteResult.java
core/src/main/java/hudson/tasks/junit/SuiteResult.java
+15
-4
core/src/main/java/hudson/tasks/junit/XMLEntityResolver.java
core/src/main/java/hudson/tasks/junit/XMLEntityResolver.java
+17
-1
core/src/main/java/hudson/util/io/ParserConfigurator.java
core/src/main/java/hudson/util/io/ParserConfigurator.java
+58
-0
未找到文件。
changelog.html
浏览文件 @
bdf13dce
...
...
@@ -55,7 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div
id=
"trunk"
style=
"display:none"
>
<!--=TRUNK-BEGIN=-->
<ul
class=
image
>
<li
class=
>
<li
class=
rfe
>
Added a mechanism to control the XML parser behaviour
(
<a
href=
"https://github.com/jenkinsci/jenkins/pull/67"
>
pull request #67
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/tasks/junit/SuiteResult.java
浏览文件 @
bdf13dce
...
...
@@ -25,6 +25,7 @@ package hudson.tasks.junit;
import
hudson.tasks.test.TestObject
;
import
hudson.util.IOException2
;
import
hudson.util.io.ParserConfigurator
;
import
org.apache.commons.io.FileUtils
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
...
...
@@ -84,6 +85,18 @@ public final class SuiteResult implements Serializable {
this
.
file
=
null
;
}
/**
* Passed to {@link ParserConfigurator}.
* @since 1.416
*/
public
static
class
SuiteResultParserConfigurationContext
{
public
final
File
xmlReport
;
SuiteResultParserConfigurationContext
(
File
xmlReport
)
{
this
.
xmlReport
=
xmlReport
;
}
}
/**
* Parses the JUnit XML file into {@link SuiteResult}s.
* This method returns a collection, as a single XML may have multiple <testsuite>
...
...
@@ -94,10 +107,8 @@ public final class SuiteResult implements Serializable {
// parse into DOM
SAXReader
saxReader
=
new
SAXReader
();
// install EntityResolver for resolving DTDs, which are in files created by TestNG.
// (see https://hudson.dev.java.net/servlets/ReadMsg?listName=users&msgNo=5530)
XMLEntityResolver
resolver
=
new
XMLEntityResolver
();
saxReader
.
setEntityResolver
(
resolver
);
ParserConfigurator
.
applyConfiguration
(
saxReader
,
new
SuiteResultParserConfigurationContext
(
xmlReport
));
Document
result
=
saxReader
.
read
(
xmlReport
);
Element
root
=
result
.
getRootElement
();
...
...
core/src/main/java/hudson/tasks/junit/XMLEntityResolver.java
浏览文件 @
bdf13dce
...
...
@@ -23,6 +23,10 @@
*/
package
hudson.tasks.junit
;
import
hudson.Extension
;
import
hudson.tasks.junit.SuiteResult.SuiteResultParserConfigurationContext
;
import
hudson.util.io.ParserConfigurator
;
import
org.dom4j.io.SAXReader
;
import
org.xml.sax.EntityResolver
;
import
org.xml.sax.InputSource
;
import
org.xml.sax.SAXException
;
...
...
@@ -43,7 +47,8 @@ import java.util.logging.Logger;
*
* @author Mikael Carneholm
*/
class
XMLEntityResolver
implements
EntityResolver
{
@Extension
public
class
XMLEntityResolver
extends
ParserConfigurator
implements
EntityResolver
{
private
static
final
String
TESTNG_NAMESPACE
=
"http://testng.org/"
;
...
...
@@ -67,5 +72,16 @@ class XMLEntityResolver implements EntityResolver {
return
null
;
}
/**
* Install EntityResolver for resolving DTDs, which are in files created by TestNG.
* (see https://hudson.dev.java.net/servlets/ReadMsg?listName=users&msgNo=5530)
*/
@Override
public
void
configure
(
SAXReader
reader
,
Object
context
)
{
if
(
context
instanceof
SuiteResultParserConfigurationContext
)
{
reader
.
setEntityResolver
(
this
);
}
}
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
XMLEntityResolver
.
class
.
getName
());
}
\ No newline at end of file
core/src/main/java/hudson/util/io/ParserConfigurator.java
0 → 100644
浏览文件 @
bdf13dce
/*
* The MIT License
*
* Copyright (c) 2011, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
hudson.util.io
;
import
hudson.ExtensionList
;
import
hudson.ExtensionPoint
;
import
hudson.model.Hudson
;
import
org.dom4j.io.SAXReader
;
/**
* Configures XML parsers to be used in various context of Jenkins.
*
* @author Kohsuke Kawaguchi
* @since 1.416
*/
public
abstract
class
ParserConfigurator
implements
ExtensionPoint
{
/**
* Configures the given {@link SAXReader}
*
* @param context
* Object that represents the context in which the parser is used.
* It is up to the caller to decide what to pass in here.
*/
public
void
configure
(
SAXReader
reader
,
Object
context
)
{}
/**
* Returns all the registered {@link ParserConfigurator}s.
*/
public
static
ExtensionList
<
ParserConfigurator
>
all
()
{
return
Hudson
.
getInstance
().
getExtensionList
(
ParserConfigurator
.
class
);
}
public
static
void
applyConfiguration
(
SAXReader
reader
,
Object
context
)
{
for
(
ParserConfigurator
pc
:
all
())
pc
.
configure
(
reader
,
context
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录