本文整理汇总了Java中org.springframework.expression.ParseException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ParseException.printStackTrace方法的具体用法?Java ParseException.printStackTrace怎么用?Java ParseException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.expression.ParseException
的用法示例。
在下文中一共展示了ParseException.printStackTrace方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setValueExpectError
import org.springframework.expression.ParseException; //导入方法依赖的package包/类
/**
* 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!
}
}
示例2: setValue
import org.springframework.expression.ParseException; //导入方法依赖的package包/类
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());
}
}
示例3: testScenario_UsingStandardInfrastructure
import org.springframework.expression.ParseException; //导入方法依赖的package包/类
/**
* 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());
}
}
示例4: testScenario_RegisteringJavaMethodsAsFunctionsAndCallingThem
import org.springframework.expression.ParseException; //导入方法依赖的package包/类
/**
* 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());
}
}
示例5: parseCheck
import org.springframework.expression.ParseException; //导入方法依赖的package包/类
/**
* 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());
}
}
示例6: checkSpelFilter
import org.springframework.expression.ParseException; //导入方法依赖的package包/类
/**
* 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;
}
}
示例7: convert
import org.springframework.expression.ParseException; //导入方法依赖的package包/类
@Override
public Date convert(String source) {
try {
return DateUtil.parse(source);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
示例8: evaluate
import org.springframework.expression.ParseException; //导入方法依赖的package包/类
/**
* Evaluate an expression and check that the actual result matches the expectedValue and the class of the result
* matches the expectedClassOfResult.
* @param expression The expression to evaluate
* @param expectedValue the expected result for evaluating the expression
* @param expectedResultType the expected class of the evaluation result
*/
public void evaluate(String expression, Object expectedValue, Class<?> expectedResultType) {
try {
Expression expr = parser.parseExpression(expression);
if (expr == null) {
fail("Parser returned null for expression");
}
if (DEBUG) {
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
}
// Class<?> expressionType = expr.getValueType();
// assertEquals("Type of the expression is not as expected. Should be '"+expectedResultType+"' but is
// '"+expressionType+"'",
// expectedResultType,expressionType);
Object value = expr.getValue(eContext);
// Check the return value
if (value == null) {
if (expectedValue == null) {
return; // no point doing other checks
}
assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
null);
}
Class<?> resultType = value.getClass();
assertEquals("Type of the actual result was not as expected. Expected '" + expectedResultType
+ "' but result was of type '" + resultType + "'", expectedResultType, resultType);
// .equals/* isAssignableFrom */(resultType), truers);
// TODO isAssignableFrom would allow some room for compatibility
// in the above expression...
if (expectedValue instanceof String) {
assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
ExpressionTestCase.stringValueOf(value));
} else {
assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
}
} catch (EvaluationException ee) {
ee.printStackTrace();
fail("Unexpected Exception: " + ee.getMessage());
} catch (ParseException pe) {
pe.printStackTrace();
fail("Unexpected Exception: " + pe.getMessage());
}
}