@Test
 public void testExceptionThrownWhenNoTemplateFound() {
   DomReadyTemplate tmpl = new DomReadyTemplate(DomReadyTemplateTest.class);
   try {
     tmpl.renderHead(null, this.response);
     Assert.fail("Did not throw exception as expected.");
   } catch (WicketRuntimeException wre) {
     Assert.assertTrue(wre.getMessage().startsWith("Failed to locate JavaScript template"));
   }
 }
Пример #2
0
  @Test
  public void fromTypeErasedModelFails() {
    final A a = new A();

    try {
      from(new Model<A>(a));

      fail();
    } catch (WicketRuntimeException ex) {
      assertEquals("cannot detect target type", ex.getMessage());
    }
  }
Пример #3
0
  @Test
  public void bindToTypeErasedModelWithNull() {
    LazyModel<B> model = model(from(A.class).getB()).bind(new Model<A>(null));

    assertNull(model.getObjectType());
    assertNull(model.getObjectClass());

    try {
      model.getPath();

      fail();
    } catch (WicketRuntimeException ex) {
      assertEquals("cannot detect target type", ex.getMessage());
    }
  }