@Test
 public void testBindErrorNotWritableWithPrefix() throws Exception {
   VanillaTarget target = new VanillaTarget();
   BindingResult result = bind(target, "spam: bar\n" + "vanilla.value: 123", "vanilla");
   assertEquals(0, result.getErrorCount());
   assertEquals(123, target.getValue());
 }
 @Test
 public void testBindWithAlias() throws Exception {
   VanillaTarget target = new VanillaTarget();
   MutablePropertyValues properties = new MutablePropertyValues();
   properties.add("flub", "a");
   properties.add("foo", "b");
   new RelaxedDataBinder(target).withAlias("flub", "fooBaz").bind(properties);
   assertThat(target.getFooBaz(), equalTo("a"));
   assertThat(target.getFoo(), equalTo("b"));
 }
 @Test
 public void testMixed() throws Exception {
   // gh-3385
   VanillaTarget target = new VanillaTarget();
   RelaxedDataBinder binder = getBinder(target, "test");
   MutablePropertyValues values = new MutablePropertyValues();
   values.add("test.FOO_BAZ", "boo");
   values.add("test.foo-baz", "bar");
   binder.bind(values);
   assertEquals("boo", target.getFooBaz());
 }
 @Test
 public void testOnlyTopLevelFields() throws Exception {
   VanillaTarget target = new VanillaTarget();
   RelaxedDataBinder binder = getBinder(target, null);
   binder.setIgnoreUnknownFields(false);
   binder.setIgnoreNestedProperties(true);
   BindingResult result = bind(binder, target, "foo: bar\n" + "value: 123\n" + "nested.bar: spam");
   assertEquals(123, target.getValue());
   assertEquals("bar", target.getFoo());
   assertEquals(0, result.getErrorCount());
 }
 @Test
 public void testAllowedFields() throws Exception {
   VanillaTarget target = new VanillaTarget();
   RelaxedDataBinder binder = getBinder(target, null);
   binder.setAllowedFields("foo");
   binder.setIgnoreUnknownFields(false);
   BindingResult result = bind(binder, target, "foo: bar\n" + "value: 123\n" + "bar: spam");
   assertEquals(0, target.getValue());
   assertEquals("bar", target.getFoo());
   assertEquals(0, result.getErrorCount());
 }
  private void doTestBindCaseInsensitiveEnums(VanillaTarget target) throws Exception {
    BindingResult result = bind(target, "bingo: THIS");
    assertThat(result.getErrorCount(), equalTo(0));
    assertThat(target.getBingo(), equalTo(Bingo.THIS));

    result = bind(target, "bingo: oR");
    assertThat(result.getErrorCount(), equalTo(0));
    assertThat(target.getBingo(), equalTo(Bingo.or));

    result = bind(target, "bingo: that");
    assertThat(result.getErrorCount(), equalTo(0));
    assertThat(target.getBingo(), equalTo(Bingo.THAT));

    result = bind(target, "bingo: the-other");
    assertThat(result.getErrorCount(), equalTo(0));
    assertThat(target.getBingo(), equalTo(Bingo.THE_OTHER));

    result = bind(target, "bingo: the_other");
    assertThat(result.getErrorCount(), equalTo(0));
    assertThat(target.getBingo(), equalTo(Bingo.THE_OTHER));

    result = bind(target, "bingo: The_Other");
    assertThat(result.getErrorCount(), equalTo(0));
    assertThat(target.getBingo(), equalTo(Bingo.THE_OTHER));
  }
 @Test
 public void testBindFromEnvironmentStyleWithPrefix() throws Exception {
   VanillaTarget target = new VanillaTarget();
   bind(target, "TEST_FOO: bar", "test");
   assertEquals("bar", target.getFoo());
 }
 @Test
 public void testBindStringWithPrefix() throws Exception {
   VanillaTarget target = new VanillaTarget();
   bind(target, "test.foo: bar", "test");
   assertEquals("bar", target.getFoo());
 }
 @Test
 public void testBindChars() throws Exception {
   VanillaTarget target = new VanillaTarget();
   bind(target, "bar: foo");
   assertEquals("foo", new String(target.getBar()));
 }
 @Test
 public void testBindNumber() throws Exception {
   VanillaTarget target = new VanillaTarget();
   bind(target, "foo: bar\n" + "value: 123");
   assertEquals(123, target.getValue());
 }
 @Test
 public void testBindCamelCase() throws Exception {
   VanillaTarget target = new VanillaTarget();
   bind(target, "fooBaz: bar");
   assertEquals("bar", target.getFooBaz());
 }
 @Test
 public void testBindUnderscoreInActualPropertyName() throws Exception {
   VanillaTarget target = new VanillaTarget();
   bind(target, "foo-bar: bar");
   assertEquals("bar", target.getFoo_bar());
 }
 @Test
 public void testBindCapitals() throws Exception {
   VanillaTarget target = new VanillaTarget();
   bind(target, "FOO: bar");
   assertEquals("bar", target.getFoo());
 }