Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
0a53e45d
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
0a53e45d
编写于
7月 20, 2013
作者:
O
Olivier Lamy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
prepare test suite for mvn 3.1.x
上级
10522f20
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
259 deletion
+9
-259
test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
+9
-1
test/src/test/java/hudson/maven/Maven3BuildTest.java
test/src/test/java/hudson/maven/Maven3BuildTest.java
+0
-258
未找到文件。
test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
浏览文件 @
0a53e45d
...
...
@@ -545,7 +545,15 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
MavenInstallation
m3
=
new
MavenInstallation
(
"apache-maven-3.0.1"
,
mvn
.
getHome
(),
NO_PROPERTIES
);
jenkins
.
getDescriptorByType
(
Maven
.
DescriptorImpl
.
class
).
setInstallations
(
m3
);
return
m3
;
}
}
protected
MavenInstallation
configureMaven31
()
throws
Exception
{
MavenInstallation
mvn
=
configureDefaultMaven
(
"apache-maven-3.1.0"
,
MavenInstallation
.
MAVEN_30
);
MavenInstallation
m3
=
new
MavenInstallation
(
"apache-maven-3.1.0"
,
mvn
.
getHome
(),
NO_PROPERTIES
);
jenkins
.
getDescriptorByType
(
Maven
.
DescriptorImpl
.
class
).
setInstallations
(
m3
);
return
m3
;
}
/**
* Locates Maven2 and configure that as the only Maven in the system.
...
...
test/src/test/java/hudson/maven/Maven3BuildTest.java
已删除
100755 → 0
浏览文件 @
10522f20
package
hudson.maven
;
/*
* Olivier Lamy
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import
hudson.Launcher
;
import
hudson.model.*
;
import
hudson.tasks.Maven.MavenInstallation
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.io.IOException
;
import
hudson.tasks.test.AbstractTestResultAction
;
import
hudson.tasks.test.TestResultProjectAction
;
import
org.apache.commons.io.FileUtils
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.Email
;
import
org.jvnet.hudson.test.ExtractResourceSCM
;
import
org.jvnet.hudson.test.HudsonTestCase
;
/**
* @author Olivier Lamy
*/
public
class
Maven3BuildTest
extends
HudsonTestCase
{
public
void
testSimpleMaven3Build
()
throws
Exception
{
MavenModuleSet
m
=
createMavenProject
();
MavenInstallation
mavenInstallation
=
configureMaven3
();
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"maven3-project.zip"
)));
m
.
setGoals
(
"clean install"
);
MavenModuleSetBuild
b
=
buildAndAssertSuccess
(
m
);
assertTrue
(
MavenUtil
.
maven3orLater
(
b
.
getMavenVersionUsed
()
)
);
}
public
void
testSimpleMaven3BuildRedeployPublisher
()
throws
Exception
{
MavenModuleSet
m
=
createMavenProject
();
MavenInstallation
mavenInstallation
=
configureMaven3
();
m
.
setMaven
(
mavenInstallation
.
getName
()
);
File
repo
=
createTmpDir
();
FileUtils
.
cleanDirectory
(
repo
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
getPublishersList
().
add
(
new
RedeployPublisher
(
""
,
repo
.
toURI
().
toString
(),
true
,
false
));
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"maven3-project.zip"
)));
m
.
setGoals
(
"clean install"
);
MavenModuleSetBuild
b
=
buildAndAssertSuccess
(
m
);
assertTrue
(
MavenUtil
.
maven3orLater
(
b
.
getMavenVersionUsed
()
)
);
File
artifactDir
=
new
File
(
repo
,
"com/mycompany/app/my-app/1.7-SNAPSHOT/"
);
String
[]
files
=
artifactDir
.
list
(
new
FilenameFilter
()
{
public
boolean
accept
(
File
dir
,
String
name
)
{
System
.
out
.
println
(
"file name : "
+
name
);
return
name
.
endsWith
(
".jar"
);
}
});
assertTrue
(
"SNAPSHOT exist"
,!
files
[
0
].
contains
(
"SNAPSHOT"
));
assertTrue
(
"file not ended with -1.jar"
,
files
[
0
].
endsWith
(
"-1.jar"
));
}
public
void
testSiteBuildWithForkedMojo
()
throws
Exception
{
MavenModuleSet
m
=
createMavenProject
();
MavenInstallation
mavenInstallation
=
configureMaven3
();
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"maven3-project.zip"
)));
m
.
setGoals
(
"clean site"
);
MavenModuleSetBuild
b
=
buildAndAssertSuccess
(
m
);
assertTrue
(
MavenUtil
.
maven3orLater
(
b
.
getMavenVersionUsed
()
)
);
}
@Bug
(
value
=
8395
)
public
void
testMaven3BuildWrongScope
()
throws
Exception
{
File
pom
=
new
File
(
this
.
getClass
().
getResource
(
"test-pom-8395.xml"
).
toURI
());
MavenModuleSet
m
=
createMavenProject
();
MavenInstallation
mavenInstallation
=
configureMaven3
();
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setRootPOM
(
pom
.
getAbsolutePath
());
m
.
setGoals
(
"clean validate"
);
MavenModuleSetBuild
mmsb
=
m
.
scheduleBuild2
(
0
).
get
();
assertBuildStatus
(
Result
.
FAILURE
,
mmsb
);
System
.
out
.
println
(
"mmsb.getProject().getModules "
+
mmsb
.
getProject
().
getModules
()
);
assertTrue
(
mmsb
.
getProject
().
getModules
().
isEmpty
());
}
@Bug
(
value
=
8390
)
public
void
testMaven3BuildWrongInheritence
()
throws
Exception
{
MavenModuleSet
m
=
createMavenProject
();
MavenInstallation
mavenInstallation
=
configureMaven3
();
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"incorrect-inheritence-testcase.zip"
)));
m
.
setGoals
(
"clean validate"
);
MavenModuleSetBuild
mmsb
=
m
.
scheduleBuild2
(
0
).
get
();
assertBuildStatus
(
Result
.
FAILURE
,
mmsb
);
System
.
out
.
println
(
"mmsb.getProject().getModules "
+
mmsb
.
getProject
().
getModules
()
);
assertTrue
(
mmsb
.
getProject
().
getModules
().
isEmpty
());
}
@Bug
(
value
=
8445
)
public
void
testMavenSeveralModulesInDirectory
()
throws
Exception
{
MavenModuleSet
m
=
createMavenProject
();
MavenInstallation
mavenInstallation
=
configureMaven3
();
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"several-modules-in-directory.zip"
)));
m
.
setGoals
(
"clean validate"
);
MavenModuleSetBuild
mmsb
=
buildAndAssertSuccess
(
m
);
assertFalse
(
mmsb
.
getProject
().
getModules
().
isEmpty
());
}
@Email
(
"https://groups.google.com/d/msg/hudson-users/Xhw00UopVN0/FA9YqDAIsSYJ"
)
public
void
testMavenWithDependencyVersionInEnvVar
()
throws
Exception
{
MavenModuleSet
m
=
createMavenProject
();
MavenInstallation
mavenInstallation
=
configureMaven3
();
ParametersDefinitionProperty
parametersDefinitionProperty
=
new
ParametersDefinitionProperty
(
new
StringParameterDefinition
(
"JUNITVERSION"
,
"3.8.2"
));
m
.
addProperty
(
parametersDefinitionProperty
);
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"envars-maven-project.zip"
)));
m
.
setGoals
(
"clean test-compile"
);
MavenModuleSetBuild
mmsb
=
buildAndAssertSuccess
(
m
);
assertFalse
(
mmsb
.
getProject
().
getModules
().
isEmpty
());
}
@Bug
(
8484
)
public
void
testMultiModMavenNonRecursive
()
throws
Exception
{
MavenInstallation
mavenInstallation
=
configureMaven3
();
MavenModuleSet
m
=
createMavenProject
();
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"maven-multimod.zip"
)));
m
.
setGoals
(
"-N validate"
);
assertTrue
(
"MavenModuleSet.isNonRecursive() should be true"
,
m
.
isNonRecursive
());
buildAndAssertSuccess
(
m
);
assertEquals
(
"not only one module"
,
1
,
m
.
getModules
().
size
());
}
@Bug
(
8573
)
public
void
testBuildTimeStampProperty
()
throws
Exception
{
MavenInstallation
mavenInstallation
=
configureMaven3
();
MavenModuleSet
m
=
createMavenProject
();
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"JENKINS-8573.zip"
)));
m
.
setGoals
(
"process-resources"
);
buildAndAssertSuccess
(
m
);
String
content
=
m
.
getLastBuild
().
getWorkspace
().
child
(
"target/classes/test.txt"
).
readToString
();
assertFalse
(
content
.
contains
(
"${maven.build.timestamp}"
)
);
assertFalse
(
content
.
contains
(
"${maven.build.timestamp}"
)
);
}
@Bug
(
1557
)
public
void
testDuplicateTestResults
()
throws
Exception
{
MavenInstallation
mavenInstallation
=
configureMaven3
();
MavenModuleSet
m
=
createMavenProject
();
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"JENKINS-1557.zip"
)));
m
.
setGoals
(
"verify"
);
buildAndAssertSuccess
(
m
);
int
totalCount
=
m
.
getModules
().
iterator
().
next
()
.
getAction
(
TestResultProjectAction
.
class
).
getLastTestResultAction
().
getTotalCount
();
assertEquals
(
4
,
totalCount
);
}
@Bug
(
9326
)
public
void
testTychoTestResults
()
throws
Exception
{
MavenInstallation
mavenInstallation
=
configureMaven3
();
MavenModuleSet
m
=
createMavenProject
();
m
.
setRootPOM
(
"org.foobar.build/pom.xml"
);
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"JENKINS-9326.zip"
),
"foobar"
));
m
.
setGoals
(
"verify"
);
buildAndAssertSuccess
(
m
);
System
.
out
.
println
(
"modules size "
+
m
.
getModules
());
MavenModule
testModule
=
null
;
for
(
MavenModule
mavenModule
:
m
.
getModules
())
{
System
.
out
.
println
(
"module "
+
mavenModule
.
getName
()
+
"/"
+
mavenModule
.
getDisplayName
());
if
(
"org.foobar:org.foobar.test"
.
equals
(
mavenModule
.
getName
()
))
testModule
=
mavenModule
;
}
AbstractTestResultAction
trpa
=
testModule
.
getLastBuild
().
getTestResultAction
();
int
totalCount
=
trpa
.
getTotalCount
();
assertEquals
(
1
,
totalCount
);
}
@Bug
(
9326
)
public
void
testTychoEclipseTestResults
()
throws
Exception
{
MavenInstallation
mavenInstallation
=
configureMaven3
();
MavenModuleSet
m
=
createMavenProject
();
m
.
setRootPOM
(
"org.foobar.build/pom.xml"
);
m
.
setMaven
(
mavenInstallation
.
getName
()
);
m
.
getReporters
().
add
(
new
TestReporter
());
m
.
setScm
(
new
ExtractResourceSCM
(
getClass
().
getResource
(
"foobar_eclipse_with_fix.zip"
),
"foobar_eclipse"
));
m
.
setGoals
(
"verify"
);
buildAndAssertSuccess
(
m
);
System
.
out
.
println
(
"modules size "
+
m
.
getModules
());
MavenModule
testModule
=
null
;
for
(
MavenModule
mavenModule
:
m
.
getModules
())
{
System
.
out
.
println
(
"module "
+
mavenModule
.
getName
()
+
"/"
+
mavenModule
.
getDisplayName
());
if
(
"org.foobar:org.foobar.test"
.
equals
(
mavenModule
.
getName
()
))
testModule
=
mavenModule
;
}
AbstractTestResultAction
trpa
=
testModule
.
getLastBuild
().
getTestResultAction
();
int
totalCount
=
trpa
.
getTotalCount
();
assertEquals
(
1
,
totalCount
);
}
private
static
class
TestReporter
extends
MavenReporter
{
@Override
public
boolean
end
(
MavenBuild
build
,
Launcher
launcher
,
BuildListener
listener
)
throws
InterruptedException
,
IOException
{
assertNotNull
(
build
.
getProject
().
getWorkspace
());
assertNotNull
(
build
.
getWorkspace
());
return
true
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录