Ejemplo n.º 1
0
 public static Address createAddress(
     final String str, final String city, final String zip, final String cc) {
   final Address result = new Address();
   result.setStreetAndNumber(str);
   result.setTown(city);
   result.setPostalCode(Integer.valueOf(zip));
   result.setCountry(cc);
   return result;
 }
Ejemplo n.º 2
0
  /** As per Bug 313969 */
  public void testUsesBeanObservablesWhenBindingABean() {
    final Person person = new Person("Max", "Muster"); // $NON-NLS-1$ //$NON-NLS-2$
    final Address pdx =
        createAddress(
            "pdx",
            "Portland",
            "97209",
            "USA"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    final Address fra =
        createAddress(
            "fra",
            "Frankfurt",
            "60329",
            "DE"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    person.setAddress(pdx);

    valueBindingSupport.bindToModel(person, "address.streetAndNumber"); // $NON-NLS-1$

    assertEquals("pdx", person.getAddress().getStreetAndNumber()); // $NON-NLS-1$
    assertEquals("pdx", pdx.getStreetAndNumber()); // $NON-NLS-1$

    target.setValue("new 1"); // $NON-NLS-1$

    assertEquals("new 1", person.getAddress().getStreetAndNumber()); // $NON-NLS-1$
    assertEquals("new 1", pdx.getStreetAndNumber()); // $NON-NLS-1$

    person.setAddress(fra);
    target.setValue("new 2"); // $NON-NLS-1$

    assertEquals("new 2", person.getAddress().getStreetAndNumber()); // $NON-NLS-1$
    assertEquals("new 2", fra.getStreetAndNumber()); // $NON-NLS-1$
    assertEquals("new 1", pdx.getStreetAndNumber()); // $NON-NLS-1$
  }