@SuppressWarnings({"rawtypes", "unchecked"})

@Test
public void testExpandProperties() throws IOException, NamingException {
    LOG.info("testExpandProperties");
    final Binder binder = Mockito.mock(Binder.class);
    Mockito.when(binder.skipSources(Names.class)).thenReturn(binder);
    Mockito.when(binder.bind(Mockito.any(Key.class))).thenReturn(Mockito.mock(LinkedBindingBuilder.class));
    final Properties props = new Properties();
    GuiceUtils.loadUrl(props, "classpath:" + PROPERTY_FILE_ENVVAR);
    GuiceUtils.expandProperties(binder, props);
    Mockito.verify(binder, Mockito.times(4)).addError(Mockito.any(String.class));
    Assert.assertEquals(10, props.size());
    final String homeValue = System.getenv("HOME");
    Assert.assertEquals(homeValue, props.getProperty("envVarExists"));
    Assert.assertEquals(homeValue + 'y', props.getProperty("envVarExistsFront"));
    Assert.assertEquals("x" + homeValue + 'y', props.getProperty("envVarExistsMid"));
    Assert.assertEquals("x" + homeValue, props.getProperty("envVarExistsEnd"));
    Assert.assertEquals(null, props.getProperty("envVarDoesNotExist"));
    Assert.assertEquals("", props.getProperty("envVarDefaultValueUndefined"));
    Assert.assertEquals("{empty}", props.getProperty("envVarDefaultValueEmpty"));
    Assert.assertEquals("x", props.getProperty("envVarDefaultValueNonEmpty"));
    Assert.assertEquals(null, props.getProperty("envVarSyntaxError1"));
    Assert.assertEquals(null, props.getProperty("envVarSyntaxError2"));
    Assert.assertEquals(null, props.getProperty("envVarSyntaxError3"));
    Assert.assertEquals(null, props.getProperty("envVarSyntaxError4"));
    Assert.assertEquals("12", props.getProperty("envVarTwo1"));
    Assert.assertEquals("1-2", props.getProperty("envVarTwo2"));
}