Package org.springframework.expression.spel.testresources

Examples of org.springframework.expression.spel.testresources.Inventor$TestException


   * @param testContext the evaluation context in which to set the root object
   */
  private static void setupRootContextObject(StandardEvaluationContext testContext) {
    GregorianCalendar c = new GregorianCalendar();
    c.set(1856, 7, 9);
    Inventor tesla = new Inventor("Nikola Tesla", c.getTime(), "Serbian");
    tesla.setPlaceOfBirth(new PlaceOfBirth("SmilJan"));
    tesla.setInventions(new String[] { "Telephone repeater", "Rotating magnetic field principle",
        "Polyphase alternating-current system", "Induction motor", "Alternating-current power transmission",
        "Tesla coil transformer", "Wireless communication", "Radio", "Fluorescent lights" });
    testContext.setRootObject(tesla);
  }
View Full Code Here


  public void testRootObject() throws Exception {
    GregorianCalendar c = new GregorianCalendar();
    c.set(1856, 7, 9);

    //  The constructor arguments are name, birthday, and nationaltiy.
    Inventor tesla = new Inventor("Nikola Tesla", c.getTime(), "Serbian");

    ExpressionParser parser = new SpelExpressionParser();
    Expression exp = parser.parseExpression("name");

    StandardEvaluationContext context = new StandardEvaluationContext();
View Full Code Here

  @Test
  public void testDictionaryAccess() throws Exception {
    StandardEvaluationContext societyContext = new StandardEvaluationContext();
    societyContext.setRootObject(new IEEE());
    // Officer's Dictionary
    Inventor pupin = parser.parseExpression("officers['president']").getValue(societyContext, Inventor.class);
    assertNotNull(pupin);

    // evaluates to "Idvor"
    String city = parser.parseExpression("officers['president'].PlaceOfBirth.city").getValue(societyContext, String.class);
    assertNotNull(city);

    // setting values
    Inventor i = parser.parseExpression("officers['advisors'][0]").getValue(societyContext,Inventor.class);
    assertEquals("Nikola Tesla",i.getName());

    parser.parseExpression("officers['advisors'][0].PlaceOfBirth.Country").setValue(societyContext, "Croatia");

    Inventor i2 = parser.parseExpression("reverse[0]['advisors'][0]").getValue(societyContext,Inventor.class);
    assertEquals("Nikola Tesla",i2.getName());

  }
View Full Code Here

  // 7.5.5

  @Test
  public void testAssignment() throws Exception {
    Inventor inventor = new Inventor();
    StandardEvaluationContext inventorContext = new StandardEvaluationContext();
    inventorContext.setRootObject(inventor);

    parser.parseExpression("foo").setValue(inventorContext, "Alexander Seovic2");
View Full Code Here

  @Test
  public void testConstructors() throws Exception {
    StandardEvaluationContext societyContext = new StandardEvaluationContext();
    societyContext.setRootObject(new IEEE());
    Inventor einstein =
         parser.parseExpression("new org.springframework.expression.spel.testresources.Inventor('Albert Einstein',new java.util.Date(), 'German')").getValue(Inventor.class);
    assertEquals("Albert Einstein", einstein.getName());
    //create new inventor instance within add method of List
    parser.parseExpression("Members2.add(new org.springframework.expression.spel.testresources.Inventor('Albert Einstein', 'German'))").getValue(societyContext);
  }
View Full Code Here

  // 7.5.8

  @Test
  public void testVariables() throws Exception {
    Inventor tesla = new Inventor("Nikola Tesla", "Serbian");
    StandardEvaluationContext context = new StandardEvaluationContext();
    context.setVariable("newName", "Mike Tesla");

    context.setRootObject(tesla);

    parser.parseExpression("foo = #newName").getValue(context);

    assertEquals("Mike Tesla",tesla.getFoo());
  }
View Full Code Here

TOP

Related Classes of org.springframework.expression.spel.testresources.Inventor$TestException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.