use of javax.el.ELContext in project camel by apache.
the class JuelTest method testJuel.
@Test
public void testJuel() throws Exception {
ExpressionFactory factory = new ExpressionFactoryImpl();
ELContext context = new SimpleContext();
ValueExpression valueExpression = factory.createValueExpression(context, "${123 * 2}", Object.class);
Object value = valueExpression.getValue(context);
assertEquals("Result is a Long object", 246L, value);
}
use of javax.el.ELContext in project ART-TIME by Artezio.
the class CustomOutputLabelRendererTest method testDetermineRequireness_ifGetterNotFound.
@Test
public void testDetermineRequireness_ifGetterNotFound() throws Exception {
TestObject testObject = new TestObject();
ELContext elContext = createMock(ELContext.class);
setField(renderer, "elContext", elContext);
UIComponent component = createMock(UIComponent.class);
ValueExpression valueExpression = createMock(ValueExpression.class);
ValueReference valueReference = createMock(ValueReference.class);
PowerMock.mockStatic(ValueExpressionAnalyzer.class);
expect(component.getValueExpression("value")).andReturn(valueExpression);
expect(ValueExpressionAnalyzer.getReference(elContext, valueExpression)).andReturn(valueReference);
expect(valueReference.getBase()).andReturn(testObject);
expect(valueReference.getProperty()).andReturn("attr_2");
PowerMock.replayAll(ValueExpressionAnalyzer.class, component, valueReference);
boolean actual = renderer.determineRequireness(component);
PowerMock.verifyAll();
assertFalse(actual);
}
use of javax.el.ELContext in project ART-TIME by Artezio.
the class CustomOutputLabelRendererTest method testDetermineRequireness_ifValueExpressionIsNull.
@Test
public void testDetermineRequireness_ifValueExpressionIsNull() throws Exception {
ELContext elContext = createMock(ELContext.class);
setField(renderer, "elContext", elContext);
UIComponent component = createMock(UIComponent.class);
expect(component.getValueExpression("value")).andReturn(null);
replay(component);
boolean actual = renderer.determineRequireness(component);
verify(component);
assertFalse(actual);
}
use of javax.el.ELContext in project ART-TIME by Artezio.
the class ContextUtilTest method testGetELContext.
@Test
public void testGetELContext() {
PowerMock.mockStatic(FacesContext.class);
FacesContext facesContext = createMock(FacesContext.class);
ELContext elContext = createMock(ELContext.class);
expect(FacesContext.getCurrentInstance()).andReturn(facesContext);
expect(facesContext.getELContext()).andReturn(elContext);
PowerMock.replayAll(FacesContext.class);
ELContext actual = ContextUtil.getELContext();
PowerMock.verifyAll();
}
use of javax.el.ELContext in project ART-TIME by Artezio.
the class Sheet method updateModel.
/**
* Override to update model with local values. Note that this is where
* things can be fragile in that we can successfully update some values and
* fail on others. There is no clean way to roll back the updates, but we
* also need to fail processing.
* <p>
* TODO consider keeping old values as we update (need for event anyhow) and
* if there is a failure attempt to roll back by updating successful model
* updates with the old value. This may not all be necessary.
*/
@Override
public void updateModel(FacesContext context) {
HashSet<Object> dirtyRows = new HashSet<Object>();
Iterator<Entry<RowColIndex, String>> commentsEntries = comments.entrySet().iterator();
while (commentsEntries.hasNext()) {
final Entry<RowColIndex, String> entry = commentsEntries.next();
final String newValue = entry.getValue();
final Object rowKey = entry.getKey().getRowKey();
final int col = entry.getKey().getColIndex();
final Column column = getColumns().get(col);
final RowMap map = rowMap.get(rowKey);
this.setRowIndex(context, map.sortedIndex);
String oldValue = null;
ValueExpression valueExpression = column.getValueExpression("comment");
if (valueExpression != null) {
oldValue = (String) valueExpression.getValue(context.getELContext());
valueExpression.setValue(context.getELContext(), newValue);
}
commentsEntries.remove();
appendUpdateEvent(map.sortedIndex, col, map.value, oldValue, newValue);
dirtyRows.add(rowKey);
}
Iterator<Entry<RowColIndex, Object>> entries = localValues.entrySet().iterator();
// updates on what was touched
while (entries.hasNext()) {
final Entry<RowColIndex, Object> entry = entries.next();
final Object newValue = entry.getValue();
final Object rowKey = entry.getKey().getRowKey();
final int col = entry.getKey().getColIndex();
final Column column = getColumns().get(col);
final RowMap map = rowMap.get(rowKey);
this.setRowIndex(context, map.sortedIndex);
// System.out.println("Local key=" + rowKey + " and sortedRow is " + map.sortedIndex);
ValueExpression ve = column.getValueExpression(PropertyKeys.value.name());
ELContext elContext = context.getELContext();
Object oldValue = ve.getValue(elContext);
if (!column.isReadonlyCell()) {
ve.setValue(elContext, newValue);
}
entries.remove();
appendUpdateEvent(map.sortedIndex, col, map.value, oldValue, newValue);
dirtyRows.add(rowKey);
}
setLocalValueSet(false);
setRowIndex(context, -1);
this.sortAndFilter();
if (context.getPartialViewContext().isPartialRequest())
this.renderRowUpdateScript(context, dirtyRows);
}
Aggregations