cancel
Showing results for 
Search instead for 
Did you mean: 

Testing framework: Is it possible to deploy a contribution on per method base?

Edgar_
Confirmed Champ
Confirmed Champ

Hi,

I've seen some examples from the Nuxeo source , where the deployment is done within the test methods through deployContrib (...) (old testing framework?). I would like to do the same using annotations on per method base. Or is it by design to deploy contributions on per class base?

Thanks.

[example]

@RunWith(FeaturesRunner.class)  
@Features({CoreFeature.class})  
[..]
public class TestClass {
	
	@Test  
    @Deploy({"org.my.service:OSGI-INF/my-test-contrib.xml"}) /*nice to have*/
	public void myTest() throws Exception {
		...;
	}
1 ACCEPTED ANSWER

Laurent_Doguin
Star Collaborator
Star Collaborator

Hi Edgar,

Using Deploy annotations on method does not do anything. In fact you should not be able to do this. We need to fix the target of the Deploy and LocalDeploy annotation. But what you can do is inject the test harness like this:

@RunWith(FeaturesRunner.class)
@Features({CoreFeature.class})
public class TestClass {
    @Inject
    protected RuntimeHarness harness.

    @Test
    public void myTest() throws Exception {
        // deploy the complete bundle
        harness.deployBundle("org.my.service");
        // deploy a specific contribution
        harness.deployContrib("org.my.service","OSGI-INF/my-test-contrib.xml");
    }
}

View answer in original post

1 REPLY 1

Laurent_Doguin
Star Collaborator
Star Collaborator

Hi Edgar,

Using Deploy annotations on method does not do anything. In fact you should not be able to do this. We need to fix the target of the Deploy and LocalDeploy annotation. But what you can do is inject the test harness like this:

@RunWith(FeaturesRunner.class)
@Features({CoreFeature.class})
public class TestClass {
    @Inject
    protected RuntimeHarness harness.

    @Test
    public void myTest() throws Exception {
        // deploy the complete bundle
        harness.deployBundle("org.my.service");
        // deploy a specific contribution
        harness.deployContrib("org.my.service","OSGI-INF/my-test-contrib.xml");
    }
}
Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.