aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/xtremelabs/robolectric/util/PropertiesHelperTest.java
blob: f87055dbbab9cb16c4eb4fa007da7006f48b58fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.xtremelabs.robolectric.util;

import org.junit.Test;

import java.util.Properties;

import static org.junit.Assert.assertEquals;

public class PropertiesHelperTest {
    @Test
    public void shouldDoVariableSubstitutionUsingSystemProperties() throws Exception {
        System.setProperty("blinfiddle.ox.heart", "orange juice");
        System.setProperty("ornithopter.defenestration", "nickel");

        assertEquals(PropertiesHelper.doSingleSubstitution("presenting: ${blinfiddle.ox.heart} -- ${ornithopter.defenestration}.", null), "presenting: orange juice -- nickel.");
    }

    @Test
    public void shouldDoVariableSubstitutionOnProperties() throws Exception {
        Properties properties = new Properties();
        properties.setProperty("result", "{${first.value} + ${system.value.xbf5547}}");
        System.setProperty("system.value.xbf5547", "system");
        properties.setProperty("first.value", "first");
        PropertiesHelper.doSubstitutions(properties);
        assertEquals("{first + system}", properties.getProperty("result"));
    }
}