Tabnine Logo
SpelExpressionParser.parseRaw
Code IndexAdd Tabnine to your IDE (free)

How to use
parseRaw
method
in
org.springframework.expression.spel.standard.SpelExpressionParser

Best Java code snippets using org.springframework.expression.spel.standard.SpelExpressionParser.parseRaw (Showing top 20 results out of 315)

origin: spring-projects/spring-framework

@Test
public void elvis_SPR7209_2() {
  Expression expr = null;
  // Have empty string treated as null for elvis
  expr = new SpelExpressionParser().parseRaw("?:'default'");
  assertEquals("default", expr.getValue());
  expr = new SpelExpressionParser().parseRaw("\"\"?:'default'");
  assertEquals("default", expr.getValue());
  expr = new SpelExpressionParser().parseRaw("''?:'default'");
  assertEquals("default", expr.getValue());
}
origin: spring-projects/spring-framework

@Test
public void whitespace() {
  SpelExpressionParser parser = new SpelExpressionParser();
  SpelExpression expr = parser.parseRaw("2      +    3");
  assertEquals(5, expr.getValue());
  expr = parser.parseRaw("2	+	3");
  assertEquals(5, expr.getValue());
  expr = parser.parseRaw("2\n+\t3");
  assertEquals(5, expr.getValue());
  expr = parser.parseRaw("2\r\n+\t3");
  assertEquals(5, expr.getValue());
}
origin: spring-projects/spring-framework

@Test
public void SPR5905_InnerTypeReferences() {
  StandardEvaluationContext context = new StandardEvaluationContext(new Spr5899Class());
  Expression expr = new SpelExpressionParser().parseRaw("T(java.util.Map$Entry)");
  assertEquals(Map.Entry.class, expr.getValue(context));
  expr = new SpelExpressionParser().parseRaw("T(org.springframework.expression.spel.SpelReproTests$Outer$Inner).run()");
  assertEquals(12, expr.getValue(context));
  expr = new SpelExpressionParser().parseRaw("new org.springframework.expression.spel.SpelReproTests$Outer$Inner().run2()");
  assertEquals(13, expr.getValue(context));
}
origin: spring-projects/spring-framework

private void checkNumber(String expression, Object value, Class<?> type) {
  try {
    SpelExpressionParser parser = new SpelExpressionParser();
    SpelExpression expr = parser.parseRaw(expression);
    Object exprVal = expr.getValue();
    assertEquals(value, exprVal);
    assertEquals(type, exprVal.getClass());
  }
  catch (Exception ex) {
    fail(ex.getMessage());
  }
}
origin: spring-projects/spring-framework

/** Should be accessing Goo.setKey field because 'bar' variable evaluates to "key" */
@Test
public void indexingAsAPropertyAccess_SPR6968_5() {
  Goo g = Goo.instance;
  StandardEvaluationContext context = new StandardEvaluationContext(g);
  Expression expr = null;
  expr = new SpelExpressionParser().parseRaw("instance[bar]='world'");
  expr.getValue(context, String.class);
  assertEquals("world", g.value);
  expr.getValue(context, String.class); // will be using the cached accessor this time
  assertEquals("world", g.value);
}
origin: spring-projects/spring-framework

@Test
public void stringLiterals() {
  SpelExpression expr = new SpelExpressionParser().parseRaw("'howdy'");
  assertEquals("howdy", expr.getValue());
  expr = new SpelExpressionParser().parseRaw("'hello '' world'");
  assertEquals("hello ' world", expr.getValue());
}
origin: spring-projects/spring-framework

@Test
public void stringLiterals2() {
  SpelExpression expr = new SpelExpressionParser().parseRaw("'howdy'.substring(0,2)");
  assertEquals("ho", expr.getValue());
}
origin: spring-projects/spring-framework

@Test
public void arithmeticPrecedence1() {
  SpelExpressionParser parser = new SpelExpressionParser();
  SpelExpression expr = parser.parseRaw("2*3+5");
  assertEquals(11, expr.getValue());
}
origin: spring-projects/spring-framework

@Test
public void arithmeticPrecedence6() {
  SpelExpression expr = new SpelExpressionParser().parseRaw("(3+2)*2");
  assertEquals(10, expr.getValue());
}
origin: spring-projects/spring-framework

@Test
public void SPR11445_simple() {
  StandardEvaluationContext context = new StandardEvaluationContext(new Spr11445Class());
  Expression expr = new SpelExpressionParser().parseRaw("echo(parameter())");
  assertEquals(1, expr.getValue(context));
}
origin: spring-projects/spring-framework

@Test
public void SPR11445_beanReference() {
  StandardEvaluationContext context = new StandardEvaluationContext();
  context.setBeanResolver(new Spr11445Class());
  Expression expr = new SpelExpressionParser().parseRaw("@bean.echo(@bean.parameter())");
  assertEquals(1, expr.getValue(context));
}
origin: spring-projects/spring-framework

@Test
public void selectFirstItemInList() throws Exception {
  Expression expression = new SpelExpressionParser().parseRaw("integers.^[#this<5]");
  EvaluationContext context = new StandardEvaluationContext(new ListTestBean());
  Object value = expression.getValue(context);
  assertTrue(value instanceof Integer);
  assertEquals(0, value);
}
origin: spring-projects/spring-framework

@Test
public void selectFirstItemInPrimitiveArray() throws Exception {
  Expression expression = new SpelExpressionParser().parseRaw("ints.^[#this<5]");
  EvaluationContext context = new StandardEvaluationContext(new ArrayTestBean());
  Object value = expression.getValue(context);
  assertTrue(value instanceof Integer);
  assertEquals(0, value);
}
origin: spring-projects/spring-framework

@Test
public void selectLastItemInList() throws Exception {
  Expression expression = new SpelExpressionParser().parseRaw("integers.$[#this<5]");
  EvaluationContext context = new StandardEvaluationContext(new ListTestBean());
  Object value = expression.getValue(context);
  assertTrue(value instanceof Integer);
  assertEquals(4, value);
}
origin: spring-projects/spring-framework

@Test
public void selectFirstItemInArray() throws Exception {
  Expression expression = new SpelExpressionParser().parseRaw("integers.^[#this<5]");
  EvaluationContext context = new StandardEvaluationContext(new ArrayTestBean());
  Object value = expression.getValue(context);
  assertTrue(value instanceof Integer);
  assertEquals(0, value);
}
origin: spring-projects/spring-framework

@Test
public void dollars2() {
  StandardEvaluationContext context = new StandardEvaluationContext(new XX());
  Expression expr = null;
  expr = new SpelExpressionParser().parseRaw("m[$foo]");
  context.setVariable("file_name", "$foo");
  assertEquals("wibble", expr.getValue(context, String.class));
}
origin: spring-projects/spring-framework

private void checkNumberError(String expression, SpelMessage expectedMessage) {
  try {
    SpelExpressionParser parser = new SpelExpressionParser();
    parser.parseRaw(expression);
    fail();
  }
  catch (ParseException ex) {
    assertTrue(ex instanceof SpelParseException);
    SpelParseException spe = (SpelParseException) ex;
    assertEquals(expectedMessage, spe.getMessageCode());
  }
}
origin: spring-projects/spring-framework

@Test
public void testPropertiesNested03() throws ParseException {
  try {
    new SpelExpressionParser().parseRaw("placeOfBirth.23");
    fail();
  }
  catch (SpelParseException spe) {
    assertEquals(SpelMessage.UNEXPECTED_DATA_AFTER_DOT, spe.getMessageCode());
    assertEquals("23", spe.getInserts()[0]);
  }
}
origin: spring-projects/spring-framework

@Test
public void testStringLiterals_DoubleQuotes_spr9620_2() {
  try {
    new SpelExpressionParser().parseRaw("\"double quote: \\\"\\\".\"");
    fail("Should have failed");
  }
  catch (SpelParseException spe) {
    assertEquals(17, spe.getPosition());
    assertEquals(SpelMessage.UNEXPECTED_ESCAPE_CHAR, spe.getMessageCode());
  }
}
origin: spring-projects/spring-framework

@Test
public void projectionTypeDescriptors_2() {
  StandardEvaluationContext context = new StandardEvaluationContext(new C());
  SpelExpressionParser parser = new SpelExpressionParser();
  String el1 = "as.![#this.equals('abc')]";
  SpelExpression exp = parser.parseRaw(el1);
  Object[] value = (Object[]) exp.getValue(context);
  // value is array containing [true,false]
  assertEquals(Boolean.class, value[0].getClass());
  TypeDescriptor evaluated = exp.getValueTypeDescriptor(context);
  assertEquals(Boolean.class, evaluated.getElementTypeDescriptor().getType());
}
org.springframework.expression.spel.standardSpelExpressionParserparseRaw

Popular methods of SpelExpressionParser

  • parseExpression
  • <init>
    Create a parser with the specified configuration.
  • doParseExpression

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • getSystemService (Context)
  • getSharedPreferences (Context)
  • Kernel (java.awt.image)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JComboBox (javax.swing)
  • JFrame (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now