Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Liferay 7.1 Integration test
Hi,
i followed this page (https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/injecting-service-components-into-tests) to create a simple integration test for my osgi service.
In my gradle i have imported this dependencies:
If i do a gradle build, this test is never run, but if i launch an jUnit test i have this trace:
Can anyone help me?
i followed this page (https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/injecting-service-components-into-tests) to create a simple integration test for my osgi service.
In my gradle i have imported this dependencies:
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: "com.liferay.portal", name: "com.liferay.portal.kernel"
testCompile group: 'com.liferay.portal', name: 'com.liferay.portal.test.integration'
testCompile group: "com.liferay.portal", name: "com.liferay.portal.test"
My integration test code is very simple:public class TestIntegration {
private static Log _log = LogFactoryUtil.getLog(TestIntegration.class);
@ClassRule
@Rule
public static final AggregateTestRule aggregateTestRule = new LiferayIntegrationTestRule();
@Inject(type = MyService.class)
private static MyService _myService;
@Before
public void setUp() {
_log.info("Init TestIntegration");
}
@Test
public void schedulerDescription() {
_log.info("TestIntegration");
}
}
If i do a gradle build, this test is never run, but if i launch an jUnit test i have this trace:
java.lang.NoClassDefFoundError: com/liferay/petra/concurrent/ConcurrentReferenceKeyHashMap
at com.liferay.portal.kernel.test.rule.BaseTestRule.<clinit>(BaseTestRule.java:178)
at com.liferay.portal.test.rule.LiferayIntegrationTestRule.<clinit>(LiferayIntegrationTestRule.java:86)
at it.myservice.test.integration.TestIntegration.<clinit>(TestIntegration.java:36)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
at java.lang.reflect.Field.get(Field.java:393)
at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
at org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.ClassNotFoundException: com.liferay.petra.concurrent.ConcurrentReferenceKeyHashMap
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 21 more</clinit></clinit></clinit>
Can anyone help me?
Hi,
Try Adding depedency compileOnly group: "com.liferay", name: "com.liferay.petra.concurrent" in build.gradle and check
Try Adding depedency compileOnly group: "com.liferay", name: "com.liferay.petra.concurrent" in build.gradle and check
Hi Mohammed
are there any full-example for liferary testIntegrarion?
Or could you please share with me your implementation?
Thanks.
are there any full-example for liferary testIntegrarion?
Or could you please share with me your implementation?
Thanks.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™