コード例 #1
0
  @Test
  public void checkAMessage() {
    // Setup
    String result = null;
    String expectedException =
        "Unable to find a Locale specific resource file to bind with i18n interface 'com.octo.gwt.test.i18n.MyMessages' and there is no @DefaultXXXValue annotation on 'a_message' called method";

    // Test 1
    try {
      result = messages.a_message("Gael", 23, true);
      Assert.fail(
          "The test is expected to throw an execption since 'a_message' can't be retrieve in the default property file and no @DefaultMessage is set on the method");
    } catch (Exception e) {
      Assert.assertEquals(expectedException, e.getMessage());
    }

    // Setup 2
    GwtConfig.setLocale(Locale.FRANCE);

    // Test 2
    result = messages.a_message("Gael", 23, true);

    // Assert2
    Assert.assertEquals("Bonjour Gael, vous avez saisi le nombre 23 et le booléen true", result);
  }