我正在尝试使用 gradle、arquillian 和 bnd 工具为 liferay 7 portlet 编写集成测试。
这是我在测试类中的部署方法:
@Deployment
public static JavaArchive create() throws IllegalArgumentException, FileNotFoundException {
print("Eseguo il Deployment");
BndProjectBuilder bndProjectBuilder = ShrinkWrap.create(BndProjectBuilder.class);
bndProjectBuilder.setBndFile(new File("bnd-test.bnd"));
bndProjectBuilder.generateManifest(true);
JavaArchive j = bndProjectBuilder.as(JavaArchive.class);
return j;
}
这是 bnd-test.bnd 文件:
Bundle-Name: Beep Col Portlet Test
Bundle-SymbolicName: it.polimi.metid.beep.beepcol.test
Bundle-Version: 1.0.0
Include-Resource:build/classes/main,META-INF/resources=src/main/resources/META-INF/resources
Require-Capability:\
osgi.extender;filter:="(&(osgi.extender=jsp.taglib)(uri=http://liferay.com/tld/ddm))",\
osgi.extender;filter:="(&(osgi.extender=jsp.taglib)(uri=http://liferay.com/tld/frontend))",\
osgi.extender;filter:="(&(osgi.extender=jsp.taglib)(uri=http://java.sun.com/portlet_2_0))",\
osgi.extender;filter:="(&(osgi.extender=jsp.taglib)(uri=http://liferay.com/tld/aui))",\
osgi.extender;filter:="(&(osgi.extender=jsp.taglib)(uri=http://liferay.com/tld/portlet))",\
osgi.extender;filter:="(&(osgi.extender=jsp.taglib)(uri=http://liferay.com/tld/theme))",\
osgi.extender;filter:="(&(osgi.extender=jsp.taglib)(uri=http://liferay.com/tld/ui))",\
osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
-jsp: *.jsp,*.jspf
-plugin.bundle: com.liferay.ant.bnd.resource.bundle.ResourceBundleLoaderAnalyzerPlugin
-plugin.jsp: com.liferay.ant.bnd.jsp.JspAnalyzerPlugin
-plugin.sass: com.liferay.ant.bnd.sass.SassAnalyzerPlugin
-sass: *
-sources: true
-dsannotations: *
通过功能测试,这可以正常工作,但是当我尝试进行一些集成测试并尝试使用 com.liferay.portal:com.liferay.portal.test;version='1.0.0' 等外部库时,问题就
出现
了
将像这样使用这个库的一些类:
@Test
public void prova() throws Exception {
Group g = GroupTestUtil.addGroup();
}
我得到这个例外:
java.lang.NoClassDefFoundError: com/liferay/portal/kernel/test/util/GroupTestUtil
我认为这是因为 BndProjectBuilder 不包含依赖项 jar,或者我错误地配置了 bnd 文件。
有人已经遇到过这个问题吗?