use of org.apache.sling.provisioning.model.ModelUtility.VariableResolver in project sling by apache.
the class ModelResolveUtilityReplaceTest method testOneResolver.
@Test
public void testOneResolver() {
VariableResolver resolver = new VariableResolver() {
@Override
public String resolve(Feature feature, String name) {
return name.toUpperCase();
}
};
assertEquals("one VAR1 variable", replace(TEST_FEATURE, "one ${var1} variable", resolver));
assertEquals("VAR1 one variable", replace(TEST_FEATURE, "${var1} one variable", resolver));
assertEquals("VAR1 one variable VAR2", replace(TEST_FEATURE, "${var1} one variable ${var2}", resolver));
}
use of org.apache.sling.provisioning.model.ModelUtility.VariableResolver in project sling by apache.
the class ModelUtilityApplyVariablesTest method setUp.
@Before
public void setUp() {
testModel = new Model();
Feature feature = testModel.getOrCreateFeature("feature1");
feature.getVariables().put("param1", "v1");
feature.getVariables().put("extparam2", "v2");
RunMode runMode = feature.getOrCreateRunMode(new String[] { "rm1" });
ArtifactGroup group = runMode.getOrCreateArtifactGroup(10);
group.add(new Artifact("g1", "a1", "${param1}", "c1", "t1"));
group.add(new Artifact("g2", "a2", "${extparam2}", null, null));
Configuration conf = runMode.getOrCreateConfiguration("pid1", null);
conf.getProperties().put(ModelConstants.CFG_UNPROCESSED, "conf1=\"${extparam1}\"\n" + "conf2=\"${extparam2}\"");
runMode.getSettings().put("set1", "${param1}");
// dummy variable resolver that simulates external resolving of some variables
testVariableResolver = new VariableResolver() {
@Override
public String resolve(Feature feature, String name) {
if ("extparam1".equals(name)) {
return "extvalue1";
}
if ("extparam2".equals(name)) {
return "extvalue2";
}
return feature.getVariables().get(name);
}
};
}
use of org.apache.sling.provisioning.model.ModelUtility.VariableResolver in project sling by apache.
the class CustomResolverTest method testCustomVariableResolverNoFilter.
@Test
public void testCustomVariableResolverNoFilter() throws Exception {
final Model m = U.readCompleteTestModel();
final VariableResolver r = new CustomVariableResolver();
final Model effective = ModelUtility.getEffectiveModel(m, new ResolverOptions().variableResolver(r));
final ArtifactGroup g = U.getGroup(effective, "example", "jackrabbit", 15);
U.assertArtifact(g, "mvn:org.apache.sling/org.apache.sling.jcr.jackrabbit.server/#example#jackrabbit.version#/jar");
}
Aggregations