Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
b9c2148d
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
b9c2148d
编写于
1月 12, 2018
作者:
M
mike cirioli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-48463] Added a unit test that validates jenkins xml v1.0 configs
are silently migrated to xml v1.1 as they are persisted
上级
24a1852f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
23 deletion
+32
-23
core/src/test/java/hudson/XmlFileTest.java
core/src/test/java/hudson/XmlFileTest.java
+1
-23
test/src/test/java/hudson/XMLFileTest.java
test/src/test/java/hudson/XMLFileTest.java
+22
-0
test/src/test/resources/hudson/XMLFileTest/silentlyMigrateConfigsTest/config.xml
.../hudson/XMLFileTest/silentlyMigrateConfigsTest/config.xml
+9
-0
未找到文件。
core/src/test/java/hudson/XmlFileTest.java
浏览文件 @
b9c2148d
...
...
@@ -7,7 +7,6 @@ import java.io.IOException;
import
java.net.URL
;
import
jenkins.model.Jenkins
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
...
...
@@ -44,28 +43,7 @@ public class XmlFileTest {
assertThat
(
n
.
getMode
().
toString
(),
is
(
"NORMAL"
));
}
}
@Test
@Ignore
//TODO: find a way to complete this test
public
void
xml1_0ConfigMigrateTo1_1Test
()
throws
IOException
{
URL
configUrl
=
getClass
().
getResource
(
"/hudson/config_1_0.xml"
);
File
configFile
=
new
File
(
configUrl
.
getFile
());
XStream2
xs
=
new
XStream2
();
xs
.
alias
(
"hudson"
,
Jenkins
.
class
);
XmlFile
xmlFile
=
new
XmlFile
(
xs
,
configFile
);
if
(
xmlFile
.
exists
())
{
Node
n
=
(
Node
)
xmlFile
.
read
();
assertThat
(
n
.
getNumExecutors
(),
is
(
2
));
assertThat
(
n
.
getMode
().
toString
(),
is
(
"NORMAL"
));
// this fails, because configFile.getParent() returns null....how do i fix?
n
.
save
();
// Now verify that the node is showing <?xml version='1.1'> tag
}
}
@Test
public
void
canReadXmlWithControlCharsTest
()
throws
IOException
{
URL
configUrl
=
getClass
().
getResource
(
"/hudson/confg_1_1_with_special_chars.xml"
);
...
...
test/src/test/java/hudson/XMLFileTest.java
浏览文件 @
b9c2148d
package
hudson
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileReader
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.JenkinsRule
;
...
...
@@ -20,4 +23,23 @@ public class XMLFileTest {
assertThat
(
j
.
jenkins
.
getLabelString
(),
is
(
"LESS_TERMCAP_mb=\u001B[01;31m"
));
}
/**
*
* This test validates that xml v1.0 configs silently get migrated to xml v1.1 when they are persisted
*
*/
@Test
@LocalData
public
void
silentlyMigrateConfigsTest
()
throws
Exception
{
j
.
jenkins
.
save
();
// verify that we did indeed load our test config.xml
assertThat
(
j
.
jenkins
.
getLabelString
(),
is
(
"LESS_TERMCAP_mb=\u001B[01;31m"
));
//verify that the persisted top level config.xml is v1.1
File
configFile
=
new
File
(
j
.
jenkins
.
getRootPath
().
getRemote
()
+
File
.
separator
+
"config.xml"
);
assertThat
(
configFile
.
exists
(),
is
(
true
));
BufferedReader
config
=
new
BufferedReader
(
new
FileReader
(
configFile
));
assertThat
(
config
.
readLine
(),
is
(
"<?xml version='1.1' encoding='UTF-8'?>"
));
config
.
close
();
}
}
test/src/test/resources/hudson/XMLFileTest/silentlyMigrateConfigsTest/config.xml
0 → 100644
浏览文件 @
b9c2148d
<?xml version='1.0' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors/>
<version>
1.480.1
</version>
<numExecutors>
2
</numExecutors>
<mode>
NORMAL
</mode>
<label>
LESS_TERMCAP_mb=

[01;31m
</label>
<!-- Yeah, we deleted a lot of this ... fine for testing. -->
</hudson>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录