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.lei...@gmail.com>:

> 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 - 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.
>



-- 

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.

Reply via email to