Hello,
It looks that waitForService() and waitBundleState() are not working fine for
me, they are generating random errors. Locally, about half of the tests ‘fail’,
but thanks to ‘trick’ in KarafTestSuite they are restarted and on 2nd time they
work.
In Gitlab build, this ‘trick’ doesn’t work and all tests fail…
This random error is:
1) When I use waitBundleState, it’s IllegalStateException: Invalid
BundleContext
waitBundleState("com.example.myservice", Bundle.ACTIVE);
java.lang.IllegalStateException: Invalid BundleContext.
at
org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:511)
at
org.apache.felix.framework.BundleContextImpl.getBundles(BundleContextImpl.java:199)
at
com.riag.karaf.test.commons.KarafTestSupport.findBundleByName(KarafTestSupport.java:647)
at
com.riag.karaf.test.commons.KarafTestSupport.waitBundleState(KarafTestSupport.java:502)
2) When I use waitForService, it's NoClassDefFoundException:
waitForService(MyService.class, SERVICE_TIMEOUT);
java.lang.NoClassDefFoundError: com/example/service/MyService
...
Caused by: java.lang.ClassNotFoundException: Unable to load class
'com.example.service.MyService' because the bundle wiring for
PAXEXAM-PROBE-7d20ac86-eee1-44f5-b1ce-56f18ad317d9 is no longer valid.
at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1575)
at
org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
What is interesting, both run in Eclipse and command line (maven) those tests
fail at random, sometimes it's 1st and 3rd, sometimes 2nd and 4rd. Repetition
works, so JUNIT tests are passed. Gitlab CI means that tests either hang and
fail or fail 'immediately' with 1 of above failures.
I'm installing features with command featureService.installFeatures(featureSet,
EnumSet.noneOf(org.apache.karaf.features.FeaturesService.Option.class));
Then I run one of those waits.
Any thoughts what is going wrong here?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
From: [email protected] [mailto:[email protected]] On Behalf Of
Lukasz Lech
Sent: Freitag, 3. August 2018 15:53
To: [email protected]
Subject: RE: [PAX-EXAM] No runnable methods
Great, Thanks.
waitForService() together with waitBundleState() form KarafTestSupport are the
working solution for my case.
Best Regards,
Lukasz Lech
From: [email protected] [mailto:[email protected]] On Behalf Of
Jean-Baptiste Onofré
Sent: Freitag, 3. August 2018 09:25
To: [email protected]
Subject: Re: [PAX-EXAM] No runnable methods
Hi,
bundles are started by the features service.
What I do in the Karaf itests is to wait the given OSGi service (there's a
waitOsgiService() method in itest common).
Regards
JB
On 03/08/2018 08:47, Lukasz Lech wrote:
Hello,
The only problem with installAndAssertFeature() is, I can’t @Inject the OSGi
service. I need to take ServiceRefercence from BundleContext.
And one thing bothers me a bit in that scenario. Do FeaturesService wait for
bundles to start or just installs jars? Some blueprint context might take some
time to initialize… Is there any reliable mechanism to wait for all bundles to
start in pax-exam test?
Best regards,
Lukasz Lech
From: [email protected] [mailto:[email protected]] On Behalf Of
Jean-Baptiste Onofré
Sent: Freitag, 3. August 2018 06:38
To: [email protected]
Subject: Re: [PAX-EXAM] No runnable methods
Hi Lukasz,
The boot features are installed in the early stage of the Karaf bootstrap.
That's why we have to add in the cfg file.
You can install a feature with the provided features just after the bootstrap
(in @before as you did).
So, what's exactly your request ? CoreOptions.featureInstall() would be like
installAndAssertFeature() (after Karaf bootstrap, mavenBundle() doesn't add the
bundle in startup.properties for instance, it just installs the bundle after
Karaf bootstrap).
Regards
JB
On 02/08/2018 17:39, Lukasz Lech wrote:
A bit self-answering: I’ve taken the class
https://github.com/apache/karaf/blob/master/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
and extended it, basing on tests from the same project.
Which resulted in another question on my side: is there really no option to
install features on startup other than the trick with
KarafDistributionOption.editConfigurationFilePut ? The problem with
editConfigurationFilePut, it replaces the existing option, so I need to
replicate the existing content.
For feature repositories I’ve based on pax-exam test I’ve found in the repo and
created helper method to allow easily add custom repos:
protected Option karafFeaturesOption() {
String version = MavenUtils.getArtifactVersion("org.apache.karaf",
"apache-karaf");
StringBuilder sb = new StringBuilder();
sb.append("mvn:org.apache.karaf.features/framework/" + version +
"/xml/features, " +
"mvn:org.apache.karaf.features/spring/" + version +
"/xml/features, " +
"mvn:org.apache.karaf.features/spring-legacy/" + version
+ "/xml/features, " +
"mvn:org.apache.karaf.features/enterprise/" + version +
"/xml/features, " +
"mvn:org.apache.karaf.features/enterprise-legacy/" +
version + "/xml/features");
String[] extraFeatures = getAdditionalFeatureRepositories();
for (String feature: extraFeatures) {
sb.append(", ").append(feature);
}
return editConfigurationFilePut("etc/org.apache.karaf.features.cfg",
"featuresRepositories", sb.toString());
}
For features, there are too much of them, and I suppose, they change between
versions? So I’ve called installAndAssertFeature in @Before … That works, but
needs to be adapted to config file changes, so effectively I could take config
file from distribution, append feature per hand and replace the whole file in
Options.
You can install bundles via CoreOptions.mavenBundle(), so I don’t see why it
shouldn’t be possible for features… Or it’s already supported and I’ve failed
to find out how?
Best regards,
Lukasz Lech
From: [email protected] [mailto:[email protected]] On Behalf Of
Lukasz Lech
Sent: Montag, 30. Juli 2018 12:08
To: [email protected]
Subject: [PAX-EXAM] No runnable methods
Hello,
I’m tryin once again to start with pax-exam. I’ve taken the Wiki example from
https://ops4j1.jira.com/wiki/spaces/PAXEXAM4/pages/54263846/Getting+Started+with+OSGi+Tests
And I’ve created the following code:
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
public class ServiceTest
{
@Inject
private MyService myService;
@Configuration
public Option[] config() {
return options(
mavenBundle("com.example", "myservice", "1.0.0-SNAPSHOT"),
junitBundles()
);
}
@Test
public void getService() {
assertNotNull(myService);
}
}
I’m absolutely astounded by the error message I’ve got:
Java.lang.Exception: No runnable method.
My test method is annotated with org.junit.Test, exactly like on Wiki page.
What I’m missing here?
Looking for the same error I’ve found the solutions like here:
http://permalink.gmane.org/gmane.comp.java.ops4j.general/13999
But changing junitBundles() to new JUnitBundlesOption() has taken absolutely no
effect, same error message.
My maven dependencies are:
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-karaf</artifactId>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<version>4.7.0</version>
<scope>test</scope>
</dependency>
Best regards,
Lukasz Lech
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.