Java Code Examples for org.springframework.expression.ParseException#printStackTrace()
The following examples show how to use
org.springframework.expression.ParseException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetValueTests.java From spring-analysis-note with MIT License | 6 votes |
/** * Call setValue() but expect it to fail. */ protected void setValueExpectError(String expression, Object value) { try { Expression e = parser.parseExpression(expression); if (e == null) { fail("Parser returned null for expression"); } if (DEBUG) { SpelUtilities.printAbstractSyntaxTree(System.out, e); } StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext(); e.setValue(lContext, value); fail("expected an error"); } catch (ParseException pe) { pe.printStackTrace(); fail("Unexpected Exception: " + pe.getMessage()); } catch (EvaluationException ee) { // success! } }
Example 2
Source File: ParsingTests.java From spring-analysis-note with MIT License | 6 votes |
/** * Parse the supplied expression and then create a string representation of the resultant AST, it should be the * expected value. * * @param expression the expression to parse * @param expectedStringFormOfAST the expected string form of the AST */ public void parseCheck(String expression, String expectedStringFormOfAST) { try { SpelExpression e = parser.parseRaw(expression); if (e != null && !e.toStringAST().equals(expectedStringFormOfAST)) { SpelUtilities.printAbstractSyntaxTree(System.err, e); } if (e == null) { fail("Parsed exception was null"); } assertEquals("String form of AST does not match expected output", expectedStringFormOfAST, e.toStringAST()); } catch (ParseException ee) { ee.printStackTrace(); fail("Unexpected Exception: " + ee.getMessage()); } }
Example 3
Source File: SetValueTests.java From java-technology-stack with MIT License | 6 votes |
/** * Call setValue() but expect it to fail. */ protected void setValueExpectError(String expression, Object value) { try { Expression e = parser.parseExpression(expression); if (e == null) { fail("Parser returned null for expression"); } if (DEBUG) { SpelUtilities.printAbstractSyntaxTree(System.out, e); } StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext(); e.setValue(lContext, value); fail("expected an error"); } catch (ParseException pe) { pe.printStackTrace(); fail("Unexpected Exception: " + pe.getMessage()); } catch (EvaluationException ee) { // success! } }
Example 4
Source File: ParsingTests.java From java-technology-stack with MIT License | 6 votes |
/** * Parse the supplied expression and then create a string representation of the resultant AST, it should be the * expected value. * * @param expression the expression to parse * @param expectedStringFormOfAST the expected string form of the AST */ public void parseCheck(String expression, String expectedStringFormOfAST) { try { SpelExpression e = parser.parseRaw(expression); if (e != null && !e.toStringAST().equals(expectedStringFormOfAST)) { SpelUtilities.printAbstractSyntaxTree(System.err, e); } if (e == null) { fail("Parsed exception was null"); } assertEquals("String form of AST does not match expected output", expectedStringFormOfAST, e.toStringAST()); } catch (ParseException ee) { ee.printStackTrace(); fail("Unexpected Exception: " + ee.getMessage()); } }
Example 5
Source File: SetValueTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Call setValue() but expect it to fail. */ protected void setValueExpectError(String expression, Object value) { try { Expression e = parser.parseExpression(expression); if (e == null) { fail("Parser returned null for expression"); } if (DEBUG) { SpelUtilities.printAbstractSyntaxTree(System.out, e); } StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext(); e.setValue(lContext, value); fail("expected an error"); } catch (ParseException pe) { pe.printStackTrace(); fail("Unexpected Exception: " + pe.getMessage()); } catch (EvaluationException ee) { // success! } }
Example 6
Source File: SetValueTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
protected void setValue(String expression, Object value) { try { Expression e = parser.parseExpression(expression); if (e == null) { fail("Parser returned null for expression"); } if (DEBUG) { SpelUtilities.printAbstractSyntaxTree(System.out, e); } StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext(); assertTrue("Expression is not writeable but should be", e.isWritable(lContext)); e.setValue(lContext, value); assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext,value.getClass())); } catch (EvaluationException ee) { ee.printStackTrace(); fail("Unexpected Exception: " + ee.getMessage()); } catch (ParseException pe) { pe.printStackTrace(); fail("Unexpected Exception: " + pe.getMessage()); } }
Example 7
Source File: ExpressionLanguageScenarioTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Scenario: using the standard infrastructure and running simple expression evaluation. */ @Test public void testScenario_UsingStandardInfrastructure() { try { // Create a parser SpelExpressionParser parser = new SpelExpressionParser(); // Parse an expression Expression expr = parser.parseRaw("new String('hello world')"); // Evaluate it using a 'standard' context Object value = expr.getValue(); // They are reusable value = expr.getValue(); assertEquals("hello world", value); assertEquals(String.class, value.getClass()); } catch (EvaluationException ee) { ee.printStackTrace(); fail("Unexpected Exception: " + ee.getMessage()); } catch (ParseException pe) { pe.printStackTrace(); fail("Unexpected Exception: " + pe.getMessage()); } }
Example 8
Source File: ExpressionLanguageScenarioTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Scenario: using your own java methods and calling them from the expression */ @Test public void testScenario_RegisteringJavaMethodsAsFunctionsAndCallingThem() throws SecurityException, NoSuchMethodException { try { // Create a parser SpelExpressionParser parser = new SpelExpressionParser(); // Use the standard evaluation context StandardEvaluationContext ctx = new StandardEvaluationContext(); ctx.registerFunction("repeat",ExpressionLanguageScenarioTests.class.getDeclaredMethod("repeat",String.class)); Expression expr = parser.parseRaw("#repeat('hello')"); Object value = expr.getValue(ctx); assertEquals("hellohello", value); } catch (EvaluationException ee) { ee.printStackTrace(); fail("Unexpected Exception: " + ee.getMessage()); } catch (ParseException pe) { pe.printStackTrace(); fail("Unexpected Exception: " + pe.getMessage()); } }
Example 9
Source File: ParsingTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Parse the supplied expression and then create a string representation of the resultant AST, it should be the * expected value. * * @param expression the expression to parse * @param expectedStringFormOfAST the expected string form of the AST */ public void parseCheck(String expression, String expectedStringFormOfAST) { try { SpelExpression e = parser.parseRaw(expression); if (e != null && !e.toStringAST().equals(expectedStringFormOfAST)) { SpelUtilities.printAbstractSyntaxTree(System.err, e); } if (e == null) { fail("Parsed exception was null"); } assertEquals("String form of AST does not match expected output", expectedStringFormOfAST, e.toStringAST()); } catch (ParseException ee) { ee.printStackTrace(); fail("Unexpected Exception: " + ee.getMessage()); } }
Example 10
Source File: FilterGeneratorFactory.java From circus-train with Apache License 2.0 | 5 votes |
/** * check filter and generate more friendly message than CT normally does * * @param partitionFilter */ private void checkSpelFilter(String partitionFilter) { LOG.info("Located partition filter expression: {}", partitionFilter); try { expressionParser.parse(partitionFilter); } catch (ParseException e) { System.out.println("WARNING: There was a problem parsing your expression. Check above to see what was " + "resolved from the YML file to see if it is what you expect."); System.out.println("Perhaps you are inadvertently creating a YAML comment with '#{ #'?"); e.printStackTrace(System.out); return; } }
Example 11
Source File: SetValueTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * For use when coercion is happening during a setValue(). The expectedValue should be * the coerced form of the value. */ protected void setValue(String expression, Object value, Object expectedValue) { try { Expression e = parser.parseExpression(expression); if (e == null) { fail("Parser returned null for expression"); } if (DEBUG) { SpelUtilities.printAbstractSyntaxTree(System.out, e); } StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext(); assertTrue("Expression is not writeable but should be", e.isWritable(lContext)); e.setValue(lContext, value); Object a = expectedValue; Object b = e.getValue(lContext); if (!a.equals(b)) { fail("Not the same: ["+a+"] type="+a.getClass()+" ["+b+"] type="+b.getClass()); // assertEquals("Retrieved value was not equal to set value", expectedValue, e.getValue(lContext)); } } catch (EvaluationException ee) { ee.printStackTrace(); fail("Unexpected Exception: " + ee.getMessage()); } catch (ParseException pe) { pe.printStackTrace(); fail("Unexpected Exception: " + pe.getMessage()); } }
Example 12
Source File: DateConverter.java From phone with Apache License 2.0 | 5 votes |
@Override public Date convert(String source) { try { return DateUtil.parse(source); } catch (ParseException e) { e.printStackTrace(); } return null; }