Пример #1
0
  @Test
  public void testTrunc() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "Trunc");
    fi.reset();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    Date d1 = sdf.parse("2009-12-01 12:34");
    Date d2 = sdf.parse("2009-12-01 14:54");
    fi.insertOperand(d1);
    Date d3 = (Date) fi.evaluate();

    fi.reset();
    fi.insertOperand(d2);
    Date d4 = (Date) fi.evaluate();

    assertEquals(sdf.format(d3), sdf.format(d4));
  }
Пример #2
0
 @Test
 public void testNavajoRequestToString() throws Exception {
   Navajo n = createTestNavajo();
   FunctionInterface fi = fff.getInstance(cl, "NavajoRequestToString");
   fi.setInMessage(n);
   fi.reset();
   Object o = fi.evaluate();
   assertTrue(((String) o).indexOf("Aap") != -1);
 }
Пример #3
0
  @Test
  public void testXmlUnescape() throws Exception {

    FunctionInterface fi = fff.getInstance(cl, "XmlUnescape");
    fi.reset();
    fi.insertOperand("<><>");
    Object o = fi.evaluate();
    assertNotNull(o);
    assertEquals(o.getClass(), String.class);

    boolean exception = false;
    try {
      fi.reset();
      fi.insertOperand(new Integer(10));
      fi.evaluateWithTypeChecking();
    } catch (Exception e) {
      exception = true;
    }

    assertTrue(exception);
  }