AstStringTest.java :  » Scripting » JUEL » de » odysseus » el » tree » impl » ast » Java Open Source

Java Open Source » Scripting » JUEL 
JUEL » de » odysseus » el » tree » impl » ast » AstStringTest.java
/*
 * Copyright 2006, 2007 Odysseus Software GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ 
package de.odysseus.el.tree.impl.ast;

import javax.el.ELException;

import de.odysseus.el.TestCase;

public class AstStringTest extends TestCase {
  AstString parseNode(String expression) {
    return (AstString)parse(expression).getRoot().getChild(0);
  }

  public void testEval() {
    assertEquals("foo", parseNode("${'foo'}").eval(null, null));
  }

  public void testAppendStructure() {
    StringBuilder s = new StringBuilder();
    parseNode("${'foo'}").appendStructure(s, null);
    assertEquals("'foo'", s.toString());
  }

  public void testIsLiteralText() {
    assertFalse(parseNode("${'foo'}").isLiteralText());
  }

  public void testIsLeftValue() {
    assertFalse(parseNode("${'foo'}").isLeftValue());
  }

  public void testGetType() {
    assertNull(parseNode("${'foo'}").getType(null, null));
  }

  public void testIsReadOnly() {
    assertTrue(parseNode("${'foo'}").isReadOnly(null, null));
  }

  public void testSetValue() {
    try { parseNode("${'foo'}").setValue(null, null, null); fail(); } catch (ELException e) {}
  }

  public void testGetValue() {
    assertEquals("1", parseNode("${'1'}").getValue(null, null, null));
    assertEquals(1, parseNode("${'1'}").getValue(null, null, Integer.class));
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.