Nuxeo IDE Test

I've used Studio to define an extension point for a new converter. Now I am trying to write a JUnit test that will test it using the Nuxeo Eclipse IDE.

In the setup() method of the test, the following bundles are deployed:

    cs = Framework.getLocalService(ConversionService.class);

But I'm finding in the main method of the test when it queries the list of all converters that my new converter isn't in the list – I do see 14 standard converters.

List<String> cc = cs.getRegistredConverters();

I think the reason that I'm not seeing it is because I haven't deployed the extension bundle developed on Studio where the converter is defined via extension points.

When I add the studio extension bundle to the list of deployed bundles in the setup():


The test program fails and I see in the console log:

DEBUG [OSGiRuntimeService] Loading component for: studio.extensions.myconverter path: OSGI-INF/extensions.xml url: jar:file:/C:/NuxeoDev/nuxeo-cap-5.9.5-tomcat-sdk/nxserver/bundles/myconverter.jar!/OSGI-INF/extensions.xml
INFO  [ComponentManagerImpl] Registering component: service:studio.extensions.myconverter
INFO  [ComponentRegistry] Registering component: service:studio.extensions.myconverter
DEBUG [ComponentManagerImpl] Dispatching event: COMPONENT_REGISTERED: service:studio.extensions.myconverter
INFO  [ComponentManagerImpl] Registration delayed for component: service:studio.extensions.myconverter. Waiting for: [service:org.nuxeo.runtime.started, service:org.nuxeo.ecm.platform.actions,]

There's the message about “Registration delayed for component” I thought the message means that it's missing org.nuxeo.runtime.started, …

So, I tried for example to then also deploy the following before I attempt deploying the Studio extensions:

  deployBundle("org.nuxeo.runtime");    // org.nuxeo.runtime.started

But when I do that, it fails with the error:

Failed to start bundle at: C:\NuxeoDev\nuxeo-cap-5.9.5-tomcat-sdk\nxserver\bundles\nuxeo-runtime-5.9.5.jar with activator: org.nuxeo.runtime.osgi.OSGiRuntimeActivator

and I see the following in the console:

DEBUG [OSGiRuntimeService] Bundle: org.nuxeo.runtime components: OSGI-INF/EventService.xml,OSGI-INF/ResourceService.xml,OSGI-INF/DeploymentService.xml,OSGI-INF/LoginComponent.xml,OSGI-INF/ContributionPersistence.xml
DEBUG [OSGiRuntimeService] Loading component for: org.nuxeo.runtime path: OSGI-INF/EventService.xml url: jar:file:/C:/NuxeoDev/nuxeo-cap-5.9.5-tomcat-sdk/nxserver/bundles/nuxeo-runtime-5.9.5.jar!/OSGI-INF/EventService.xml
DEBUG [OSGiRuntimeService] Loading component for: org.nuxeo.runtime path: OSGI-INF/ResourceService.xml url: jar:file:/C:/NuxeoDev/nuxeo-cap-5.9.5-tomcat-sdk/nxserver/bundles/nuxeo-runtime-5.9.5.jar!/OSGI-INF/ResourceService.xml
DEBUG [OSGiRuntimeService] Loading component for: org.nuxeo.runtime path: OSGI-INF/DeploymentService.xml url: jar:file:/C:/NuxeoDev/nuxeo-cap-5.9.5-tomcat-sdk/nxserver/bundles/nuxeo-runtime-5.9.5.jar!/OSGI-INF/DeploymentService.xml
DEBUG [OSGiRuntimeService] Loading component for: org.nuxeo.runtime path: OSGI-INF/LoginComponent.xml url: jar:file:/C:/NuxeoDev/nuxeo-cap-5.9.5-tomcat-sdk/nxserver/bundles/nuxeo-runtime-5.9.5.jar!/OSGI-INF/LoginComponent.xml
DEBUG [OSGiRuntimeService] Loading component for: org.nuxeo.runtime path: OSGI-INF/ContributionPersistence.xml url: jar:file:/C:/NuxeoDev/nuxeo-cap-5.9.5-tomcat-sdk/nxserver/bundles/nuxeo-runtime-5.9.5.jar!/OSGI-INF/ContributionPersistence.xml
DEBUG [OSGiRuntimeService] Home directory: null
DEBUG [OSGiRuntimeService] Working directory: c:\temp\Nuxeo\nxruntime-main-2136295918980629551.tmp\

Any suggestions for what I'm doing wrong? Is there something that I'm maybe missing in how I've set up the test?


I have created what seems to be the simplest test for using the Nuxeo IDE JUnit4 wizard. I created a unit test for my plugin project by selecting “Studio Unit Test” from the Nuxeo Artifact Wizard in eclipse. I added a simple test case to it and then tried to run the JUnit test in debug mode:

package com.mycompany.nuxeo.convert.plugins;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.platform.test.PlatformFeature;
import org.nuxeo.runtime.test.runner.Deploy;
import org.nuxeo.runtime.test.runner.Features;
import org.nuxeo.runtime.test.runner.FeaturesRunner;


public class bbbbbb {

    CoreSession coreSession;

    @Test public void testService() throws Exception {
        System.out.print("Hello world!");


I put a break inside testService() test case and select Debug from within Eclipse. But the break point is never hit.

I assume that all methods annotated as @Test should be run.

I have debug logging turned up and in the console I see a lot of Nuxeo components being registered, but there are what appear to be quite a few failures too, like the following:

INFO  [ComponentManagerImpl] Unregistering component: service:org.nuxeo.ecm.core.scheduler.SchedulerService
DEBUG [ComponentManagerImpl] Dispatching event: DEACTIVATING_COMPONENT: service:org.nuxeo.ecm.core.scheduler.SchedulerService
DEBUG [ComponentManagerImpl] Dispatching event: COMPONENT_DEACTIVATED: service:org.nuxeo.ecm.core.scheduler.SchedulerService
DEBUG [ComponentManagerImpl] Dispatching event: COMPONENT_UNRESOLVED: service:org.nuxeo.ecm.core.scheduler.SchedulerService
DEBUG [ComponentManagerImpl] Dispatching event: COMPONENT_UNREGISTERED: service:org.nuxeo.ecm.core.scheduler.SchedulerService}

I'm not sure if it is because of these messages that the test case isn't run? When I try to run the test without the method testService(), I get an error “No Runnable Methods” and there is no debug output showing that it is attempting to load components.

The test case is associated with a plugin project created using the Nuxeo wizard. The project has “Nuxeo SDK” libraries associated with the project.

Is this the right way to set up a Nuxeo JUnit test to be run inside Eclipse?

Edit August 30, 2014

After now going back to my original test case… When I again add my bundle created in Studio (“studio.extensions.myconverter”) to the the Deploy annotation list, I get the error: java.lang.RuntimeException: Could not resolve bundle org.nuxeo.ecm.platform.actions

org.nuxeo.ecm.platform.actions is referenced from NXRuntimeTestCase, but when looking through all available files in Nuxeo source code, I don't see that bundle is defined. Should this not be getting referenced from NXRuntimeTestCase? [I do see that there is a bundle called org.nuxeo.ecm.actions which has an Export-Package org.nuxeo.ecm.platform.actions, but not a bundle with that name.]

I also have a question about correctly setting up Eclipse JUnit testing. I was missing a number of bundles related to testing that weren't automatically included with my plugin project. I needed to manually build bundles like nuxeo-core-test-5.9.5.jar, nuxeo-features-test-5.9.5.jar, … I then copied these over and used from within Eclipse.

Is there a way to not have to build these bundle jar files manually – like having the wizard in the ide automatically include the correct test bundle jars?

0 votes

1 answers




org.nuxeo.runtime should already be deployed by the test framework. To get the org.nuxeo.runtime.started component deployed, you can deploy a fake component :

<component name="org.nuxeo.runtime.started">

But which test framework are you using ? You should follow and use the CoreFeature in order not to have to deploy manually all core bundles.

0 votes

I've tried to create a working example of a JUnit test by using the IDE Wizard for generating a "Studio JUnit Test". I've added more information in my description above. But it still isn't working for me.

The messages you see are not failure. By using the FeaturesRunner, it starts the nuxeo runtime (component are loading) and stops it at the end (components are unloaded). What is the result of your simple test ?

I have a breakpoint in the test method, but it doesn't get there. Also when I check the console log, I don't see the "Hello world" message. But you're right, in the console debug information it looks like it is loading up components and then unloading them, but it never runs the method annotated with @Test.

I have the simple test case working now. I wasn't looking at the JUnit Failure traceback – there I saw that I was missing the test jar nuxeo-core-storage-sql-test-5.9.5.jar. After including that it is working.

But then when I again add my bundle created in Studio ("studio.extensions.myconverter") to the the Deploy annotation list, I get the error: java.lang.RuntimeException: Could not resolve bundle org.nuxeo.ecm.platform.actions

org.nuxeo.ecm.platform.actions is referenced from NXRuntimeTestCase, but when looking through the files in Nuxeo source code, I don't see that bundle is defined.


My questions are:

  1. Why aren't the test jars, like nuxeo-features-test-5.9.5.jar already built and included in the nxserver/bundles directory for the cap-sdk download? The corresponding source is available in sdk/sources (like nuxeo-features-test-5.9.5-sources.jar)

  2. Why does NXRuntimeTestCase show org.nuxeo.ecm.platform.actions as a dependency, but there doesn't appear to be a bundle with that name? This causes my Studio-generated jar file with extention information not to load.