@Before public void setUp() { expressions = Expressions.forTesting(); variables = Maps.newHashMap(); context = expressions.newELContext(new RootELResolver(variables)); }
@Test public void testExpressionEvaluation() { Expressions expressions = Expressions.forTesting(functions); ELContext context = expressions.newELContext(); ValueExpression expression = expressions.parse("${other:bonjour()}", String.class); assertEquals("French hello", expression.getValue(context)); expression = expressions.parse("${test:add(1, 2)}", Integer.class); assertEquals(3, expression.getValue(context)); }
/** * Returns an instance of Expressions that doesn't require * any functions or perform any caching. Use only for testing. */ @VisibleForTesting public static Expressions forTesting() { return new Expressions(null, null, new JuelTypeConverter(), new JuelProvider()); }
@Inject public Expressions(Functions functions, CacheProvider cacheProvider, ELTypeConverter typeConverter, ExpressionProvider expProvider) { this.functions = functions; this.typeConverter = typeConverter; factory = newExpressionFactory(expProvider, cacheProvider); // Stub context with no FunctionMapper, used only to parse expressions parseContext = new Context(null); defaultELResolver = createDefaultELResolver(); }
@Test(expected = ELException.class) public void failsInsteadOfMutualInfiniteRecursion() { expressions.parse("${Msg.mutual1}", String.class).getValue(context); } }
@Test(expected = ContainerConfigException.class) public void badConfigThrows() throws Exception { JSONObject json = new JSONObject(); json.put(CONTAINER_KEY, new String[]{CHILD_CONTAINER}); json.put(PARENT_KEY, "bad bad bad parent!"); json.put(ARRAY_NAME, ARRAY_ALT_VALUE); new JsonContainerConfig(createContainer(json).getAbsolutePath(), Expressions.forTesting()); }
/** * Protected to allow overriding. */ protected ELContext createExpressionContext(String container) { return getExpressions().newELContext(new ContainerConfigELResolver(this, container)); }
ValueExpression varExpression = expressions.constant(data, Object.class); elContext.getVariableMapper().setVariable(varAttr.getValue(), varExpression);
@Test(expected = ELException.class) public void failsInsteadOfMutualInfiniteRecursion() { expressions.parse("${Msg.mutual1}", String.class).getValue(context); } }
@Test(expected = ContainerConfigException.class) public void badConfigThrows() throws Exception { JSONObject json = new JSONObject(); json.put(CONTAINER_KEY, new String[]{CHILD_CONTAINER}); json.put(PARENT_KEY, "bad bad bad parent!"); json.put(ARRAY_NAME, ARRAY_ALT_VALUE); new JsonContainerConfig(createContainer(json).getAbsolutePath(), Expressions.forTesting()); }
/** * Protected to allow overriding. */ protected ELContext createExpressionContext(String container) { return getExpressions().newELContext(new ContainerConfigELResolver(this, container)); }
@Inject public Expressions(Functions functions, CacheProvider cacheProvider, ELTypeConverter typeConverter, ExpressionProvider expProvider) { this.functions = functions; this.typeConverter = typeConverter; factory = newExpressionFactory(expProvider, cacheProvider); // Stub context with no FunctionMapper, used only to parse expressions parseContext = new Context(null); defaultELResolver = createDefaultELResolver(); }
ValueExpression varExpression = expressions.constant(data, Object.class); elContext.getVariableMapper().setVariable(varAttr.getValue(), varExpression);
@Before public void setUp() { expressions = Expressions.forTesting(null); variables = Maps.newHashMap(); context = expressions.newELContext(new RootELResolver(variables)); }
@Test public void testExpressionEvaluation() { Expressions expressions = Expressions.forTesting(functions); ELContext context = expressions.newELContext(); ValueExpression expression = expressions.parse("${other:bonjour()}", String.class); assertEquals("French hello", expression.getValue(context)); expression = expressions.parse("${test:add(1, 2)}", Integer.class); assertEquals(3, expression.getValue(context)); }
@Test(expected = ELException.class) public void failsInsteadOfMutualInfiniteRecursion() { expressions.parse("${Msg.mutual1}", String.class).getValue(context); } }
@Before public void setUp() { elValues = Maps.newHashMap(); elResolver = new RootELResolver(elValues); expressions = Expressions.forTesting(); }
protected ELContext createExpressionContext(String container) { return getExpressions().newELContext(new ContainerConfigELResolver(this, container)); }
/** * Returns an instance of Expressions that doesn't require * any functions or perform any caching. Use only for testing. */ @VisibleForTesting public static Expressions forTesting() { return new Expressions(null, null, new JuelTypeConverter(), new JuelProvider()); }
@Inject public Expressions(Functions functions, CacheProvider cacheProvider, ELTypeConverter typeConverter, ExpressionProvider expProvider) { this.functions = functions; this.typeConverter = typeConverter; factory = newExpressionFactory(expProvider, cacheProvider); // Stub context with no FunctionMapper, used only to parse expressions parseContext = new Context(null); defaultELResolver = createDefaultELResolver(); }