cancel
Showing results for 
Search instead for 
Did you mean: 

localization dependency in unit test

Eric_Ace
Confirmed Champ
Confirmed Champ

Background: I built component X. Component X has OSGI-INF/l10n/messages.properties. In component X, ResourceBundle.getBundle works fine when unit testing X in its own project. Problem: When component X is referenced (via Maven) from separate project Y, Y invokes X, and the call to ResourceBundle.getBundle down inside X brings back a bundle missing the properties defined in X. I've read the "Understanding Bundles Deployment" docs and looking at the framework code it looks like the DeploymentPreprocessor.java class is responsible to process the OSGI-INF/deployment-fragment.xml files and merge all the various component properties into a single messages.properties, messages_xx_yy.properties, etc. However, it does not appear that DeploymentPreprocessor.java runs in the unit test environment. I could duplicate the properties X needs in the Y project, so that X doesn't fail. This seems bad. Does anyone have a best practice here? (Or maybe I'm just doing something wrong?)

1 REPLY 1

slacoin_Lacoin
Star Contributor
Star Contributor

You're right, the pre-deployment is not played as part of the runtime feature. You can try to add this logic by implementing a new feature for. Here is the code snipset that do the pre-deployment.

 String rootPath = Environment.getDefault().getRuntimeHome().getAbsolutePath();
    File root = new File(rootPath);
    DeploymentPreprocessor processor = new DeploymentPreprocessor(root);
    // initialize
    processor.init();
    // and predeploy
    processor.predeploy();
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.