1package com.xtremelabs.robolectric.util;
2
3import org.junit.Test;
4
5import java.util.Properties;
6
7import static org.junit.Assert.assertEquals;
8
9public class PropertiesHelperTest {
10    @Test
11    public void shouldDoVariableSubstitutionUsingSystemProperties() throws Exception {
12        System.setProperty("blinfiddle.ox.heart", "orange juice");
13        System.setProperty("ornithopter.defenestration", "nickel");
14
15        assertEquals(PropertiesHelper.doSingleSubstitution("presenting: ${blinfiddle.ox.heart} -- ${ornithopter.defenestration}.", null), "presenting: orange juice -- nickel.");
16    }
17
18    @Test
19    public void shouldDoVariableSubstitutionOnProperties() throws Exception {
20        Properties properties = new Properties();
21        properties.setProperty("result", "{${first.value} + ${system.value.xbf5547}}");
22        System.setProperty("system.value.xbf5547", "system");
23        properties.setProperty("first.value", "first");
24        PropertiesHelper.doSubstitutions(properties);
25        assertEquals("{first + system}", properties.getProperty("result"));
26    }
27}
28