Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
1774927d
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,发现更多精彩内容 >>
提交
1774927d
编写于
2月 08, 2012
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updating tests to work since these tests now require full-blown Jenkins
environment.
上级
19817fb7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
48 addition
and
32 deletion
+48
-32
test/src/test/java/hudson/model/RunTest.java
test/src/test/java/hudson/model/RunTest.java
+9
-6
test/src/test/java/hudson/model/SimpleJobTest.java
test/src/test/java/hudson/model/SimpleJobTest.java
+39
-26
未找到文件。
core
/src/test/java/hudson/model/RunTest.java
→
test
/src/test/java/hudson/model/RunTest.java
浏览文件 @
1774927d
...
...
@@ -24,16 +24,19 @@
package
hudson.model
;
import
junit.framework.TestCase
;
import
org.jvnet.hudson.test.HudsonTestCase
;
import
java.io.IOException
;
import
java.util.GregorianCalendar
;
import
java.util.List
;
/**
* @author Kohsuke Kawaguchi
*/
public
class
RunTest
extends
TestCase
{
private
List
<?
extends
Run
<?,?>.
Artifact
>
createArtifactList
(
String
...
paths
)
{
Run
<
FreeStyleProject
,
FreeStyleBuild
>
r
=
new
Run
<
FreeStyleProject
,
FreeStyleBuild
>(
null
,
new
GregorianCalendar
())
{};
public
class
RunTest
extends
HudsonTestCase
{
private
List
<?
extends
Run
<?,?>.
Artifact
>
createArtifactList
(
String
...
paths
)
throws
Exception
{
FreeStyleProject
prj
=
createFreeStyleProject
();
FreeStyleBuild
r
=
prj
.
scheduleBuild2
(
0
).
get
();
Run
<
FreeStyleProject
,
FreeStyleBuild
>.
ArtifactList
list
=
r
.
new
ArtifactList
();
for
(
String
p
:
paths
)
{
list
.
add
(
r
.
new
Artifact
(
p
,
p
,
p
,
String
.
valueOf
(
p
.
length
()),
"n"
+
list
.
size
()));
// Assuming all test inputs don't need urlencoding
...
...
@@ -42,21 +45,21 @@ public class RunTest extends TestCase {
return
list
;
}
public
void
testArtifactListDisambiguation1
()
{
public
void
testArtifactListDisambiguation1
()
throws
Exception
{
List
<?
extends
Run
<?,
?>.
Artifact
>
a
=
createArtifactList
(
"a/b/c.xml"
,
"d/f/g.xml"
,
"h/i/j.xml"
);
assertEquals
(
a
.
get
(
0
).
getDisplayPath
(),
"c.xml"
);
assertEquals
(
a
.
get
(
1
).
getDisplayPath
(),
"g.xml"
);
assertEquals
(
a
.
get
(
2
).
getDisplayPath
(),
"j.xml"
);
}
public
void
testArtifactListDisambiguation2
()
{
public
void
testArtifactListDisambiguation2
()
throws
Exception
{
List
<?
extends
Run
<?,
?>.
Artifact
>
a
=
createArtifactList
(
"a/b/c.xml"
,
"d/f/g.xml"
,
"h/i/g.xml"
);
assertEquals
(
a
.
get
(
0
).
getDisplayPath
(),
"c.xml"
);
assertEquals
(
a
.
get
(
1
).
getDisplayPath
(),
"f/g.xml"
);
assertEquals
(
a
.
get
(
2
).
getDisplayPath
(),
"i/g.xml"
);
}
public
void
testArtifactListDisambiguation3
()
{
public
void
testArtifactListDisambiguation3
()
throws
Exception
{
List
<?
extends
Run
<?,
?>.
Artifact
>
a
=
createArtifactList
(
"a.xml"
,
"a/a.xml"
);
assertEquals
(
a
.
get
(
0
).
getDisplayPath
(),
"a.xml"
);
assertEquals
(
a
.
get
(
1
).
getDisplayPath
(),
"a/a.xml"
);
...
...
core
/src/test/java/hudson/model/SimpleJobTest.java
→
test
/src/test/java/hudson/model/SimpleJobTest.java
浏览文件 @
1774927d
...
...
@@ -6,11 +6,13 @@ import java.util.TreeMap;
import
junit.framework.Assert
;
import
junit.framework.TestCase
;
import
org.jvnet.hudson.test.HudsonTestCase
;
import
org.mockito.Mockito
;
/**
* Unit test for {@link Job}.
*/
public
class
SimpleJobTest
extends
TestCase
{
public
class
SimpleJobTest
extends
Hudson
TestCase
{
public
void
testGetEstimatedDuration
()
throws
IOException
{
...
...
@@ -93,56 +95,67 @@ public class SimpleJobTest extends TestCase {
}
private
Job
createMockProject
(
final
SortedMap
<
Integer
,
TestBuild
>
runs
)
{
Job
project
=
new
Job
(
null
,
"name"
)
{
return
new
TestJob
(
runs
);
}
int
i
=
1
;
private
static
class
TestBuild
extends
Run
{
@Override
public
int
assignBuildNumber
()
throws
IOException
{
return
i
++;
public
TestBuild
(
Job
project
,
Result
result
,
long
duration
,
TestBuild
previousBuild
)
throws
IOException
{
super
(
project
);
this
.
result
=
result
;
this
.
duration
=
duration
;
this
.
previousBuild
=
previousBuild
;
}
@Override
public
SortedMap
<
Integer
,
?
extends
Run
>
_getRuns
(
)
{
return
runs
;
public
int
compareTo
(
Run
o
)
{
return
0
;
}
@Override
public
boolean
isBuildable
()
{
return
true
;
public
Result
getResult
()
{
return
result
;
}
@Override
protected
void
removeRun
(
Run
run
)
{
public
boolean
isBuilding
()
{
return
false
;
}
};
return
project
;
}
private
static
class
TestBuild
extends
Run
{
private
class
TestJob
extends
Job
implements
TopLevelItem
{
public
TestBuild
(
Job
project
,
Result
result
,
long
duration
,
TestBuild
previousBuild
)
throws
IOException
{
super
(
project
);
this
.
result
=
result
;
this
.
duration
=
duration
;
this
.
previousBuild
=
previousBuild
;
int
i
;
private
final
SortedMap
<
Integer
,
TestBuild
>
runs
;
public
TestJob
(
SortedMap
<
Integer
,
TestBuild
>
runs
)
{
super
(
SimpleJobTest
.
this
.
jenkins
,
"name"
);
this
.
runs
=
runs
;
i
=
1
;
}
@Override
public
int
compareTo
(
Run
o
)
{
return
0
;
public
int
assignBuildNumber
()
throws
IOException
{
return
i
++
;
}
@Override
public
Result
getResult
()
{
return
r
esult
;
public
SortedMap
<
Integer
,
?
extends
Run
>
_getRuns
()
{
return
r
uns
;
}
@Override
public
boolean
isBuild
ing
()
{
return
fals
e
;
public
boolean
isBuild
able
()
{
return
tru
e
;
}
@Override
protected
void
removeRun
(
Run
run
)
{
}
public
TopLevelItemDescriptor
getDescriptor
()
{
throw
new
AssertionError
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录