Providing external bundle as a Maven dependency when unit testing

Hello,

I want to execute tests in a bundle A and those tests need bundle B to be deployed.

Bundle B is provided as a dependency by an in-house Nexus server, and declared as a dependency with the scope “test” in bundle A pom.

Then I want to deploy bundle A using RuntimeFeature:

@RunWith(FeaturesRunner.class)
@Features({ CoreFeature.class, RuntimeFeature.class  })
@Deploy({ "org.nuxeo.ecm.automation.core", "org.nuxeo.ecm.core.schema", "com.company.my.types"})
public class MakeLinkBeanTest {

    @Inject
    CoreSession session;

    private DocumentModel doc;

    @Test
    public void testDoGet() throws Exception {
      doc = session.createDocumentModel("/", "test", "Thesis"); // <- defined in bundle B
    }
}

But this does not work. What I get is:

[NXRuntimeTestCase] No bundle with symbolic name 'com.company.my.types'; Falling back to deprecated url lookup scheme
[RuntimeFeature] Unable to deploy artifact: com.company.my.types

One solution is to bundle everything together, but this has led me to ask myself: what's wrong with this ?

Thanks

0 votes

1 answers

2760 views

ANSWER



If the bundle B (which I suppose is com.company.my.types) is not found, that means that it's not in your classpath.

To put it in the classpath, you should add the maven module containing it to your dependencies in your pom.xml and run a

mvn eclipse:eclipse

in your module. Then refresh you project in eclipse, check that the bundle is in the “Referenced Libraries”, then it should work.

0 votes



That's right, I forgot the mvn eclipse part of the process, thank you !
07/10/2015