Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
900341f4
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,发现更多精彩内容 >>
提交
900341f4
编写于
1月 04, 2013
作者:
C
Christoph Kutzinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add regression test for SurefireArchiver test mojo detection [JENKINS-8334]
上级
310e22db
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
252 addition
and
15 deletion
+252
-15
maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java
...rc/main/java/hudson/maven/reporters/SurefireArchiver.java
+1
-1
maven-plugin/src/test/java/hudson/maven/MojoInfoBuilder.java
maven-plugin/src/test/java/hudson/maven/MojoInfoBuilder.java
+85
-0
maven-plugin/src/test/java/hudson/maven/reporters/SurefireArchiverDetectTestMojosTest.java
.../maven/reporters/SurefireArchiverDetectTestMojosTest.java
+163
-0
maven-plugin/src/test/java/hudson/maven/reporters/SurefireArchiverUnitTest.java
...java/hudson/maven/reporters/SurefireArchiverUnitTest.java
+3
-14
未找到文件。
maven-plugin/src/main/java/hudson/maven/reporters/SurefireArchiver.java
浏览文件 @
900341f4
...
...
@@ -253,7 +253,7 @@ public class SurefireArchiver extends TestFailureDetector {
}
}
private
boolean
isTestMojo
(
MojoInfo
mojo
)
{
boolean
isTestMojo
(
MojoInfo
mojo
)
{
if
((!
mojo
.
is
(
"com.sun.maven"
,
"maven-junit-plugin"
,
"test"
))
&&
(!
mojo
.
is
(
"org.sonatype.flexmojos"
,
"flexmojos-maven-plugin"
,
"test-run"
))
&&
(!
mojo
.
is
(
"org.eclipse.tycho"
,
"tycho-surefire-plugin"
,
"test"
))
...
...
maven-plugin/src/test/java/hudson/maven/MojoInfoBuilder.java
0 → 100644
浏览文件 @
900341f4
package
hudson.maven
;
import
hudson.maven.MojoInfo
;
import
java.io.File
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.maven.plugin.MojoExecution
;
import
org.apache.maven.plugin.descriptor.MojoDescriptor
;
import
org.apache.maven.plugin.descriptor.PluginDescriptor
;
import
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator
;
import
org.codehaus.plexus.configuration.DefaultPlexusConfiguration
;
import
org.codehaus.plexus.configuration.PlexusConfiguration
;
public
class
MojoInfoBuilder
{
private
String
groupId
;
private
String
artifactId
;
private
String
goalName
;
private
String
version
=
"1.0"
;
private
Map
<
String
,
String
>
configValues
=
new
HashMap
<
String
,
String
>();
public
static
MojoInfoBuilder
mojoBuilder
(
String
groupId
,
String
artifactId
,
String
goalName
)
{
return
new
MojoInfoBuilder
(
groupId
,
artifactId
,
goalName
);
}
private
MojoInfoBuilder
(
String
groupId
,
String
artifactId
,
String
goalName
)
{
this
.
groupId
=
groupId
;
this
.
artifactId
=
artifactId
;
this
.
goalName
=
goalName
;
}
public
MojoInfoBuilder
copy
()
{
MojoInfoBuilder
copy
=
new
MojoInfoBuilder
(
this
.
groupId
,
this
.
artifactId
,
this
.
goalName
)
.
version
(
this
.
version
);
copy
.
configValues
.
putAll
(
this
.
configValues
);
return
copy
;
}
public
MojoInfoBuilder
version
(
String
version
)
{
this
.
version
=
version
;
return
this
;
}
public
MojoInfoBuilder
configValue
(
String
key
,
String
value
)
{
configValues
.
put
(
key
,
value
);
return
this
;
}
public
MojoInfo
build
()
{
PluginDescriptor
pluginDescriptor
=
new
PluginDescriptor
();
pluginDescriptor
.
setGroupId
(
groupId
);
pluginDescriptor
.
setArtifactId
(
artifactId
);
pluginDescriptor
.
setVersion
(
version
);
MojoDescriptor
mojoDescriptor
=
new
MojoDescriptor
();
mojoDescriptor
.
setPluginDescriptor
(
pluginDescriptor
);
mojoDescriptor
.
setGoal
(
goalName
);
MojoExecution
mojoExecution
=
new
MojoExecution
(
mojoDescriptor
);
PlexusConfiguration
configuration
=
new
DefaultPlexusConfiguration
(
"configuration"
);
for
(
Map
.
Entry
<
String
,
String
>
e
:
this
.
configValues
.
entrySet
())
{
configuration
.
addChild
(
e
.
getKey
(),
e
.
getValue
());
}
ExpressionEvaluator
evaluator
=
new
ExpressionEvaluator
()
{
@Override
public
Object
evaluate
(
String
expression
)
{
return
expression
;
}
@Override
public
File
alignToBaseDirectory
(
File
file
)
{
return
file
;
}
};
MojoInfo
info
=
new
MojoInfo
(
mojoExecution
,
null
,
configuration
,
evaluator
);
return
info
;
}
}
maven-plugin/src/test/java/hudson/maven/reporters/SurefireArchiverDetectTestMojosTest.java
0 → 100644
浏览文件 @
900341f4
package
hudson.maven.reporters
;
import
static
hudson
.
maven
.
MojoInfoBuilder
.
mojoBuilder
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
hudson.maven.MojoInfo
;
import
hudson.maven.MojoInfoBuilder
;
import
org.junit.Before
;
import
org.junit.Test
;
/**
* Regression test for the detection of test mojos in {@link SurefireArchiver}.
*
* @author kutzi
*/
public
class
SurefireArchiverDetectTestMojosTest
{
private
SurefireArchiver
surefireArchiver
;
@Before
public
void
before
()
{
this
.
surefireArchiver
=
new
SurefireArchiver
();
}
@Test
public
void
shouldDetectMavenSurefire
()
{
MojoInfo
mojo
=
mojoBuilder
(
"org.apache.maven.plugins"
,
"maven-surefire-plugin"
,
"test"
).
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectMavenFailsafe
()
{
MojoInfo
mojo
=
mojoBuilder
(
"org.apache.maven.plugins"
,
"maven-failsafe-plugin"
,
"verify"
).
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectMavenSurefireSkip
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"org.apache.maven.plugins"
,
"maven-surefire-plugin"
,
"test"
);
MojoInfo
mojo
=
builder
.
copy
()
.
configValue
(
"skip"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
()
.
version
(
"2.4"
)
.
configValue
(
"skipTests"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
()
.
version
(
"2.3"
)
.
configValue
(
"skipExec"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
// That's not a valid skip property:
mojo
=
builder
.
copy
()
.
configValue
(
"skip--Exec"
,
"true"
).
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectMavenJunitPlugin
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"com.sun.maven"
,
"maven-junit-plugin"
,
"test"
);
MojoInfo
mojo
=
builder
.
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
()
.
configValue
(
"skipTests"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectFlexMojoMavenPlugin
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"org.sonatype.flexmojos"
,
"flexmojos-maven-plugin"
,
"test-run"
);
MojoInfo
mojo
=
builder
.
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
()
.
configValue
(
"skipTest"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectOsgiTestPlugin
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"org.sonatype.tycho"
,
"maven-osgi-test-plugin"
,
"test"
);
MojoInfo
mojo
=
builder
.
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
().
configValue
(
"skipTest"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectTychoSurefirePlugin
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"org.eclipse.tycho"
,
"tycho-surefire-plugin"
,
"test"
);
MojoInfo
mojo
=
builder
.
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
().
configValue
(
"skipTest"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectMavenAndroidPlugin
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"com.jayway.maven.plugins.android.generation2"
,
"maven-android-plugin"
,
"internal-integration-test"
)
.
version
(
"3.0.0-alpha-6"
);
MojoInfo
mojo
=
builder
.
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
().
configValue
(
"skipTests"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectAndroidMavenPlugin
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"com.jayway.maven.plugins.android.generation2"
,
"android-maven-plugin"
,
"internal-integration-test"
)
.
version
(
"3.0.0-alpha-6"
);
MojoInfo
mojo
=
builder
.
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
().
configValue
(
"skipTests"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectGwtMavenPlugin
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"org.codehaus.mojo"
,
"gwt-maven-plugin"
,
"test"
)
.
version
(
"1.2"
);
MojoInfo
mojo
=
builder
.
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
// that version of the plugin is too old
mojo
=
builder
.
copy
().
version
(
"1.1"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectSoapUiMavenPlugin
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"eviware"
,
"maven-soapui-plugin"
,
"test"
);
MojoInfo
mojo
=
builder
.
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
().
configValue
(
"skip"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
@Test
public
void
shouldDetectSoapUiProMavenPlugin
()
{
MojoInfoBuilder
builder
=
mojoBuilder
(
"eviware"
,
"maven-soapui-pro-plugin"
,
"test"
);
MojoInfo
mojo
=
builder
.
build
();
assertTrue
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
mojo
=
builder
.
copy
().
configValue
(
"skip"
,
"true"
).
build
();
assertFalse
(
this
.
surefireArchiver
.
isTestMojo
(
mojo
));
}
}
maven-plugin/src/test/java/hudson/maven/reporters/SurefireArchiverUnitTest.java
浏览文件 @
900341f4
...
...
@@ -13,6 +13,7 @@ import hudson.maven.MavenBuildProxy;
import
hudson.maven.MavenProjectActionBuilder
;
import
hudson.maven.MavenReporter
;
import
hudson.maven.MojoInfo
;
import
hudson.maven.MojoInfoBuilder
;
import
hudson.model.BuildListener
;
import
hudson.model.Cause
;
import
hudson.model.Result
;
...
...
@@ -28,9 +29,6 @@ import java.util.Calendar;
import
java.util.List
;
import
org.apache.commons.io.output.NullOutputStream
;
import
org.apache.maven.plugin.MojoExecution
;
import
org.apache.maven.plugin.descriptor.MojoDescriptor
;
import
org.apache.maven.plugin.descriptor.PluginDescriptor
;
import
org.apache.tools.ant.types.FileSet
;
import
org.codehaus.plexus.component.configurator.ComponentConfigurationException
;
import
org.junit.Assert
;
...
...
@@ -69,17 +67,8 @@ public class SurefireArchiverUnitTest {
}
private
MojoInfo
createMojoInfo
()
throws
ComponentConfigurationException
{
PluginDescriptor
pluginDescriptor
=
new
PluginDescriptor
();
pluginDescriptor
.
setGroupId
(
"org.apache.maven.plugins"
);
pluginDescriptor
.
setArtifactId
(
"maven-surefire-plugin"
);
pluginDescriptor
.
setVersion
(
"2.9"
);
MojoDescriptor
mojoDescriptor
=
new
MojoDescriptor
();
mojoDescriptor
.
setPluginDescriptor
(
pluginDescriptor
);
mojoDescriptor
.
setGoal
(
"test"
);
MojoExecution
mojoExecution
=
new
MojoExecution
(
mojoDescriptor
);
MojoInfo
info
=
new
MojoInfo
(
mojoExecution
,
null
,
null
,
null
);
MojoInfo
info
=
MojoInfoBuilder
.
mojoBuilder
(
"org.apache.maven.plugins"
,
"maven-surefire-plugin"
,
"test"
)
.
version
(
"2.9"
).
build
();
MojoInfo
spy
=
spy
(
info
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录