Hi Achim, Thanks a lot for your response.
I've simplified the test to have only one class but unfortunately the problem is the same :-S. I've tried with two configurations: As previous using the paxexam configuration support: package com.paxexam.ds.it.greeter; import static com.paxexam.ds.it.BaseOptions.config; import static com.paxexam.ds.it.BaseOptions.scr; import static org.ops4j.pax.exam.CoreOptions.junitBundles; import static org.ops4j.pax.exam.CoreOptions.keepCaches; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.CoreOptions.systemProperty; import static org.ops4j.pax.exam.CoreOptions.when; import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration; import javax.inject.Inject; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.PaxExam; import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; import com.paxexam.ds.api.Greeter; @RunWith(PaxExam.class) @ExamReactorStrategy(PerClass.class) public class GreeterTest { private static String CONFIG_PID = "paxexam.greeter"; private static String MESSAGE = "Hello from a declarative service"; @Inject private Greeter greeter; private Option failOnUnresolvedBundles() { return systemProperty("pax.exam.osgi.unresolved.fail").value("true"); } private Option localMavenRepo() { final String localRepository = System.getProperty("maven.repo.local", ""); return when(localRepository.length() > 0) .useOptions(systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepository)); } @Configuration public Option[] options() { return new Option[] { failOnUnresolvedBundles(), keepCaches(), localMavenRepo(), junitBundles(), config(), scr(), newConfiguration(CONFIG_PID).put("message", MESSAGE).asOption(), mavenBundle("com.paxexam.ds", "ri").versionAsInProject() }; } @Test public void hello1() { System.out.println("============= " + greeter.sayHello() + " ============="); } } Using the @Before and provisioning directly with the injected ConfigAdmin (using your example as base) package com.paxexam.ds.it.greeter; import static com.paxexam.ds.it.BaseOptions.config; import static com.paxexam.ds.it.BaseOptions.scr; import static org.ops4j.pax.exam.CoreOptions.junitBundles; import static org.ops4j.pax.exam.CoreOptions.keepCaches; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.CoreOptions.systemProperty; import static org.ops4j.pax.exam.CoreOptions.when; import java.io.IOException; import java.util.Dictionary; import java.util.Hashtable; import javax.inject.Inject; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.PaxExam; import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; import org.osgi.service.cm.ConfigurationAdmin; import com.paxexam.ds.api.Greeter; @RunWith(PaxExam.class) @ExamReactorStrategy(PerClass.class) public class GreeterTest { private static String CONFIG_PID = "paxexam.greeter"; private static String MESSAGE = "Hello from a declarative service"; @Inject private ConfigurationAdmin caService; @Inject private Greeter greeter; private Option failOnUnresolvedBundles() { return systemProperty("pax.exam.osgi.unresolved.fail").value("true"); } private Option localMavenRepo() { final String localRepository = System.getProperty("maven.repo.local", ""); return when(localRepository.length() > 0) .useOptions(systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepository)); } @Configuration public Option[] options() { return new Option[] { failOnUnresolvedBundles(), keepCaches(), localMavenRepo(), junitBundles(), config(), scr(), mavenBundle("com.paxexam.ds", "ri").versionAsInProject() }; } @Before public void setUp() throws IOException { org.osgi.service.cm.Configuration config = caService.getConfiguration(CONFIG_PID); Dictionary<String, Object> props = new Hashtable<>(); props.put("message", MESSAGE); config.setBundleLocation(null); config.update(props); } @Test public void hello1() { System.out.println("============= " + greeter.sayHello() + " ============="); } } The result is the same. I hope this is not a stupid problem somehow :-S I've done this previously a lot of times mostly in bndtools environments without any problems Best Regards, Ivo Leitão On Sunday, 19 February 2017 09:24:20 UTC, Achim Nierbeck wrote: > > Hi, > > I think your test isn't correct. > In your configurations method you'll need to use the > > combine method for combining the super config stuff. > And you should also make sure you only have the @Configuration on your > overridden implementation, not on the base class. > > see for example this setup of the pax-web project: > > https://github.com/ops4j/org.ops4j.pax.web/blob/master/pax-web-itest/pax-web-itest-container/pax-web-itest-container-jetty/src/test/java/org/ops4j/pax/web/itest/jetty/HttpServiceWithConfigAdminIntegrationTest.java#L54-L58 > > regards, Achim > > > 2017-02-19 4:36 GMT+01:00 Ivo Leitão <ivo.l...@gmail.com <javascript:>>: > >> Hi ! >> >> I'm struggling with a issue in pax exam and declarative services for >> several days now which I'm not able to solve. I've created a very simple >> declarative services greeter project with metatype and configadmin to help >> illustrate the problem (in attach). The main issue is that the test times >> out with the error org.ops4j.pax.swissbox.tracker.ServiceLookupException: >> gave up waiting for service com.paxexam.ds.api.Greeter. >> >> This is happening because in the declarative service the configuration is >> mandatory (RQUIRED), the problem naturally disappears when the >> ConfigurationPolicy is IGNORE or OPTIONAL. However this should work. >> Besides, the service is not bound with the configuration in the lifetime of >> the test even with IGNORE or OPTIONAL. >> I'm using configuration admin support and from the tests that I've done >> it seems that the configuration is becoming attached to the probe. The >> bundle location extracted from the configuration object is valid but it >> shows as local (the same as the probe). The problem seems similar to the >> one reported in https://ops4j1.jira.com/browse/PAXEXAM-725 however I'm >> not able to influence the bundle location. From what I've seen in >> https://github.com/ops4j/org.ops4j.pax.exam2/blob/master/core/pax-exam-cm/src/main/java/org/ops4j/pax/exam/cm/internal/ConfigurationOptionConfigurationListener.java >> >> everything seems correct namely the null in the bundle location parameter, >> so I'm a bit lost here :-( >> >> My service is something as simples as the presented bellow: >> >> // @formatter:off >> @Component( >> configurationPid = GreeterConfig.CPID, >> configurationPolicy = ConfigurationPolicy.REQUIRE, >> immediate = true) >> // @formatter:on >> public final class GreeterImpl implements Greeter { >> private GreeterConfig config; >> @Activate >> public void activate(ComponentContext ctx, GreeterConfig config) { >> this.config = config; >> } >> @Modified >> public void modified(GreeterConfig config) { >> this.config = config; >> } >> >> @Override >> public String sayHello() { >> return config.message(); >> } >> } >> >> >> The configuration is: >> >> @ObjectClassDefinition(pid = GreeterConfig.CPID, name = "%name", >> description = "%description", localization = "OSGI-INF/l10n/greeter") >> public @interface GreeterConfig { >> public static final String CPID = "paxexam.greeter"; >> @AttributeDefinition(name = "%message.name", description = >> "%message.description") >> String message() default "Hello !!"; >> } >> >> >> The Pax exam test is: >> >> >> @RunWith(PaxExam.class) >> @ExamReactorStrategy(PerClass.class) >> public class GreeterTest extends BaseTestSupport { >> private static String MESSAGE = "Hello from a declarative service"; >> >> @Inject >> private Greeter greeter; >> >> @Override >> protected Option bundles() { >> return composite(super.bundles(), mavenBundle("com.paxexam.ds", >> "ri").versionAsInProject()); >> } >> >> @Override >> protected Option configurations() { >> return composite(super.configurations(), >> newConfiguration("paxexam.greeter").put("message", MESSAGE).asOption()); >> } >> >> @Test >> public void hello1() { >> System.out.println("============= " + greeter.sayHello() + " >> ============="); >> } >> } >> >> In the end this example should have presented "Hello from a declarative >> service" instead of error. >> >> Best Regards, >> Ivo Leitão >> >> dqweqwe >> >> -- >> -- >> ------------------ >> OPS4J - http://www.ops4j.org - op...@googlegroups.com <javascript:> >> >> --- >> 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 ops4j+un...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > > Apache Member > Apache Karaf <http://karaf.apache.org/> Committer & PMC > OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & > Project Lead > blog <http://notizblog.nierbeck.de/> > Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS> > > Software Architect / Project Manager / Scrum Master > > -- -- ------------------ OPS4J - http://www.ops4j.org - ops4j@googlegroups.com --- 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 ops4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.