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]> [mailto:[email protected]] On Behalf Of Jean-Baptiste Onofré Sent: Freitag, 3. August 2018 06:38 To: [email protected]<mailto:[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]> [mailto:[email protected]] On Behalf Of Lukasz Lech Sent: Montag, 30. Juli 2018 12:08 To: [email protected]<mailto:[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]<mailto:[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]<mailto:[email protected]>. For more options, visit https://groups.google.com/d/optout. -- -- ------------------ OPS4J - http://www.ops4j.org - [email protected]<mailto:[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]<mailto:[email protected]>. For more options, visit https://groups.google.com/d/optout. -- -- ------------------ OPS4J - http://www.ops4j.org - [email protected]<mailto:[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]<mailto:[email protected]>. For more options, visit https://groups.google.com/d/optout. -- -- ------------------ OPS4J - http://www.ops4j.org - [email protected]<mailto:[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]<mailto:[email protected]>. For more options, visit https://groups.google.com/d/optout. -- -- ------------------ OPS4J - http://www.ops4j.org - [email protected]<mailto:[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]<mailto:[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.
