clayContext.setChild(child);
clayContext.setAttribute(attr);
clayContext.setDisplayElement(displayElement);
clayContext.setSymbols(displayElement.getSymbols());
Command command = new PropertyValueCommand();
boolean isFinal = command.execute(clayContext);
assertEquals("command finished", true, isFinal);
assertEquals("value = 10", "10", child.getValue());
// test a symbol value of an el value
child = (javax.faces.component.html.HtmlOutputText)
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
assertNotNull("javax.faces.HtmlOutputText", child);
displayElement.addSymbol(createSymbol("@value", "#{value}"));
attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
servletContext.setAttribute("value", "10");
clayContext.setFacesContext(facesContext);
clayContext.setChild(child);
clayContext.setAttribute(attr);
clayContext.setDisplayElement(displayElement);
clayContext.setSymbols(displayElement.getSymbols());
isFinal = command.execute(clayContext);
assertEquals("command finished", true, isFinal);
assertEquals("value = 10", "10", child.getValue());
// test a symbol value with a null value symbol replacement
child = (javax.faces.component.html.HtmlOutputText)
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
assertNotNull("javax.faces.HtmlOutputText", child);
displayElement.addSymbol(createSymbol("@value", null));
attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
clayContext.setFacesContext(facesContext);
clayContext.setChild(child);
clayContext.setAttribute(attr);
clayContext.setDisplayElement(displayElement);
clayContext.setSymbols(displayElement.getSymbols());
isFinal = command.execute(clayContext);
assertEquals("command finished", true, isFinal);
assertEquals("value = null", null, child.getValue());
// test a symbol value with an empty String value.
// this will evaluate to null since it is a symbol replacement.
child = (javax.faces.component.html.HtmlOutputText)
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
assertNotNull("javax.faces.HtmlOutputText", child);
displayElement.addSymbol(createSymbol("@value", ""));
attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
clayContext.setFacesContext(facesContext);
clayContext.setChild(child);
clayContext.setAttribute(attr);
clayContext.setDisplayElement(displayElement);
clayContext.setSymbols(displayElement.getSymbols());
isFinal = command.execute(clayContext);
assertEquals("command finished", true, isFinal);
assertEquals("value = null", null, child.getValue());
//no symbol replacement for a empty string - should return
//an empty string. This allows components like the selectItem
//to create an empty select list pick.
attr.setValue(""); //empty string
child = (javax.faces.component.html.HtmlOutputText)
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
assertNotNull("javax.faces.HtmlOutputText", child);
clayContext.setFacesContext(facesContext);
clayContext.setChild(child);
clayContext.setAttribute(attr);
clayContext.setDisplayElement(displayElement);
isFinal = command.execute(clayContext);
assertEquals("command finished", true, isFinal);
assertEquals("value = \"\"", "", child.getValue());
//Case insensitive and reoccurring replacement
attr.setValue("@TeSt1, @tEst1 never @test2; @test1, @teSt1 till ya @tesT3"); //test multiple symbols
child = (javax.faces.component.html.HtmlOutputText)
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");
assertNotNull("javax.faces.HtmlOutputText", child);
displayElement.addSymbol(createSymbol("@test1", "rock"));
displayElement.addSymbol(createSymbol("@test2", "stop"));
displayElement.addSymbol(createSymbol("@test3", "drop"));
clayContext.setFacesContext(facesContext);
clayContext.setChild(child);
clayContext.setAttribute(attr);
clayContext.setDisplayElement(displayElement);
// normally done in the AssignChildrenCommand
clayContext.setSymbols(displayElement.getSymbols());
isFinal = command.execute(clayContext);
assertEquals("command finished", true, isFinal);
assertEquals("value = \"rock, rock never stop; rock, rock till ya drop\"",
"rock, rock never stop; rock, rock till ya drop", child.getValue());
}