Exemplo n.º 1
0
 @Test
 public void testImport() {
   elm.importClass("org.glassfish.el.test.ELProcessorTest$MyBean");
   assertTrue((Boolean) elp.eval("ELProcessorTest$MyBean.aaaa == 101"));
   assertTrue((Boolean) elp.eval("ELProcessorTest$MyBean.getBar() == 64"));
   elm.importStatic("org.glassfish.el.test.ELProcessorTest$MyBean.aaaa");
   assertEquals(new Integer(101), elp.eval("aaaa"));
   elm.importStatic("org.glassfish.el.test.ELProcessorTest$MyBean.getBar");
   assertEquals(new Integer(64), elp.eval("getBar()"));
   /*
   elm.importStatic("a.b.NonExisting.foobar");
   elp.eval("foobar");
   elp.eval("ELProcessorTest$MyBean.getFoo()");
   */
 }
Exemplo n.º 2
0
 @Test
 public void testMethExpr() {
   MethodExpression meth = null;
   ELContext ctxt = elm.getELContext();
   try {
     meth = factory.createMethodExpression(ctxt, "#{str.length}", Object.class, null);
   } catch (NullPointerException ex) {
     // Do nothing
   }
   assertTrue(meth == null);
   meth = factory.createMethodExpression(ctxt, "#{'abc'.length()}", Object.class, null);
   Object result = meth.invoke(ctxt, new Object[] {"abcde"});
   System.out.println("'abc'.length() called, equals " + result);
   assertEquals(result, new Integer(3));
 }
Exemplo n.º 3
0
 @BeforeClass
 public static void setUpClass() throws Exception {
   elp = new ELProcessor();
   elm = elp.getELManager();
   factory = elm.getExpressionFactory();
 }