@Test
public void testBind() throws Exception {

    Map<String, Object> o = newLinkedHashMap();
    o.put("host", "localhost");
    o.put("port", 2);
    o.put("auto", true);
    Config c = ConfigFactory.fromMap(o);
    Example e = ConfigFactory.bind(c, Example.class);
    assertEquals(2, e.getPort());
    String host = e.getHost().get();
    assertEquals("localhost", host);
    assertEquals(true, e.isAuto());
    try {
        e.getUser();
        fail("user");
    } catch (IllegalStateException se) {
    }
    BindConfig bc = new BindConfig();
    bc.setAllowMissing(true);
    e = ConfigFactory.bind(c, Example.class, bc);
    assertNull(e.getUser());
    assertTrue(!e.alias().isPresent());
    o.put("alias", "demo");
    assertEquals("demo", e.alias().get());
}