Home | History | Annotate | Download | only in util
      1 package com.xtremelabs.robolectric.util;
      2 
      3 import org.junit.Test;
      4 
      5 import java.util.Properties;
      6 
      7 import static org.junit.Assert.assertEquals;
      8 
      9 public 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