我正在尝试编写 spock pax 考试扩展,但发现使用服务器模式进行捆绑安装存在问题。
这是我的代码
void visitSpecAnnotation(RunPax annotation, SpecInfo sp) {
sp.addListener(new AbstractRunListener() {
private TestContainer container
@Override
void beforeSpec(SpecInfo spec) {
ExamSystem system = PaxExamRuntime.createServerSystem(
CoreOptions.options(
karafDistributionConfiguration("mvn:org.apache.servicemix/apache-servicemix/4.4.1-fuse-03-06/tar.gz", // artifact to unpack and use
"servicemix", // name; display only
"2.2.4")
.unpackDirectory(new File("target/paxexam/unpack/"))
.useDeployFolder(false),
//debugConfiguration("5005", true),
keepRuntimeFolder(),
configureConsole().ignoreLocalConsole(),
when(isEquinox()).useOptions(
editConfigurationFilePut(
KARAF_FRAMEWORK, "equinox"),
systemProperty("pax.exam.framework").value(
System.getProperty("pax.exam.framework")),
//systemProperty("osgi.console").value("6666"),
//systemProperty("osgi.console.enable.builtin").value("true")
),
logLevel(WARN),
mavenBundle("org.sdo.coding", "words", "1.0")
))
container = PaxExamRuntime.createContainer(system)
container.start()
Thread.sleep(100000)
def ant = new AntBuilder()
ant.sshexec(host: "localhost",
port: '8101',
username: "smx",
password: 'smx',
trust: "yes",
command: "list",
outputproperty: 'result',
knownhosts: '/dev/null')
def result = ant.project.properties.'result'
println "result is $result"
def installed = result =~ /(?m)^(.*Installed.*)$/
println "installed ${installed[0]}"
}
即使我增加延迟,我也找不到我的包已安装。我可以看到选项 mavenBundle 不会影响 karaf 启动,因为如果我放置了错误的版本或 artifactId,pax 不会通知我。
有人对这个问题有任何线索吗?