Пример #1
0
 /** The test checks the correct constructor is initialized */
 public void testConstructor() throws Exception {
   Expression expr = new Expression(SampleBean.class, "new", new Object[] {"hello"});
   Object result = expr.getValue();
   if (result != null && result instanceof SampleBean) {
     SampleBean bean = (SampleBean) result;
     assertEquals("hello", bean.getText());
   } else {
     fail("Cannot instantiate an instance of Bean class.");
   }
 }
Пример #2
0
  /** The test checks the correct static method is initialized */
  public void testStatic() throws Exception {
    SampleBean theBean = new SampleBean();
    Expression expr = new Expression(SampleBean.class, "create", new Object[] {"hello", theBean});

    Object result = expr.getValue();
    if (result != null && result instanceof SampleBean) {
      SampleBean bean = (SampleBean) result;
      assertEquals("hello", bean.getText());
      assertEquals(theBean, bean.getObject());
    } else {
      fail("Cannot instantiate an instance of Bean class by " + "static method.");
    }
  }