ops4j / org.ops4j.pax.cdi

Contexts and Dependency Injection for OSGi
Apache License 2.0
34 stars 26 forks source link

Karaf iTest fails if we try to get the CDI OSGI Service (Hazelnut, Chocolate, ...) [PAXCDI-220] #265

Closed ops4j-issues closed 5 years ago

ops4j-issues commented 8 years ago

Charles Moulliard created PAXCDI-220

@RunWith(PaxExam.class)
public class PaxCdiWeldTest {

    @Inject
    private CdiContainerFactory factory;

    @Inject
    @OsgiService(filter = "(flavour=hazelnut)")
    private IceCreamService iceCreamService;

    @Configuration
    public Option[] config() {
        return options( 
            regressionDefaults(),
            features(PAX_CDI_FEATURES, "pax-cdi-weld"),
            SAMPLE1);
    }

    @Test
    public void test() throws Exception {
        assertThat(factory, is(notNullValue()));
        assertThat(iceCreamService, is(notNullValue()));
        assertThat(iceCreamService.getFlavour(),is("hazelnut"));
    }
}

Attachments:

Votes: 0, Watches: 2

ops4j-issues commented 8 years ago

Charles Moulliard commented

@OsgiService(filter = "(flavour=hazelnut)") doesn't work but @Filter(value = "(flavour=hazelnut)") will work

ops4j-issues commented 5 years ago

Grzegorz Grzybek commented

API was rewritten without trace in JIRA :smile:
https://github.com/ops4j/org.ops4j.pax.cdi/commit/0f39ef2f8121cf8afb4d822a0a32b10a9c0dde1d