// Test setting properties to valid values public void testPropertiesValid() throws Exception { super.testPropertiesValid(); UISelectItem selectItem = (UISelectItem) component; // value SelectItem item = new SelectItem("foo"); selectItem.setValue(item); assertEquals("expected value", item, selectItem.getValue()); selectItem.setValue(null); assertNull("erased value", selectItem.getValue()); selectItem.setItemDescription("foo"); assertEquals("foo", selectItem.getItemDescription()); selectItem.setItemDescription(null); assertNull(selectItem.getItemDescription()); selectItem.setItemDisabled(false); assertFalse(selectItem.isItemDisabled()); selectItem.setItemDisabled(true); assertTrue(selectItem.isItemDisabled()); selectItem.setItemLabel("foo"); assertEquals("foo", selectItem.getItemLabel()); selectItem.setItemLabel(null); assertNull(selectItem.getItemLabel()); selectItem.setItemValue("foo"); assertEquals("foo", selectItem.getItemValue()); selectItem.setItemValue(null); assertNull(selectItem.getItemValue()); }
// Test attribute-property transparency public void testAttributesTransparency() { super.testAttributesTransparency(); UISelectItem selectItem = (UISelectItem) component; assertEquals(selectItem.getValue(), component.getAttributes().get("value")); SelectItem item = new SelectItem("foo"); selectItem.setValue(item); assertEquals(item, component.getAttributes().get("value")); selectItem.setValue(null); assertNull(component.getAttributes().get("value")); component.getAttributes().put("value", "bar"); assertEquals("bar", selectItem.getValue()); component.getAttributes().put("value", null); assertNull(selectItem.getValue()); assertEquals( selectItem.getItemDescription(), (String) selectItem.getAttributes().get("itemDescription")); selectItem.setItemDescription("foo"); assertEquals("foo", (String) selectItem.getAttributes().get("itemDescription")); selectItem.setItemDescription(null); assertNull((String) selectItem.getAttributes().get("itemDescription")); selectItem.getAttributes().put("itemDescription", "bar"); assertEquals("bar", selectItem.getItemDescription()); selectItem.getAttributes().put("itemDescription", null); assertNull(selectItem.getItemDescription()); assertEquals( selectItem.isItemDisabled(), ((Boolean) selectItem.getAttributes().get("itemDisabled")).booleanValue()); selectItem.setItemDisabled(true); assertTrue(((Boolean) selectItem.getAttributes().get("itemDisabled")).booleanValue()); selectItem.setItemDisabled(false); assertFalse(((Boolean) selectItem.getAttributes().get("itemDisabled")).booleanValue()); selectItem.getAttributes().put("itemDisabled", Boolean.FALSE); assertFalse(selectItem.isItemDisabled()); selectItem.getAttributes().put("itemDisabled", Boolean.TRUE); assertTrue(selectItem.isItemDisabled()); assertEquals(selectItem.getItemLabel(), (String) selectItem.getAttributes().get("itemLabel")); selectItem.setItemLabel("foo"); assertEquals("foo", (String) selectItem.getAttributes().get("itemLabel")); selectItem.setItemLabel(null); assertNull((String) selectItem.getAttributes().get("itemLabel")); selectItem.getAttributes().put("itemLabel", "bar"); assertEquals("bar", selectItem.getItemLabel()); selectItem.getAttributes().put("itemLabel", null); assertNull(selectItem.getItemLabel()); assertEquals(selectItem.getItemValue(), (String) selectItem.getAttributes().get("itemValue")); selectItem.setItemValue("foo"); assertEquals("foo", (String) selectItem.getAttributes().get("itemValue")); selectItem.setItemValue(null); assertNull((String) selectItem.getAttributes().get("itemValue")); selectItem.getAttributes().put("itemValue", "bar"); assertEquals("bar", selectItem.getItemValue()); selectItem.getAttributes().put("itemValue", null); assertNull(selectItem.getItemValue()); }
public void PENDING_FIXME_testValueBindings() { super.testValueBindings(); UISelectItem test = (UISelectItem) component; // "itemDescription" property request.setAttribute("foo", "bar"); test.setItemDescription(null); assertNull(test.getItemDescription()); test.setValueBinding("itemDescription", application.createValueBinding("#{foo}")); assertNotNull(test.getValueBinding("itemDescription")); assertEquals("bar", test.getItemDescription()); test.setItemDescription("baz"); assertEquals("baz", test.getItemDescription()); test.setItemDescription(null); assertEquals("bar", test.getItemDescription()); test.setValueBinding("itemDescription", null); assertNull(test.getValueBinding("itemDescription")); assertNull(test.getItemDescription()); // "itemDisabled" property assertFalse(test.isItemDisabled()); request.setAttribute("foo", Boolean.TRUE); test.setValueBinding("itemDisabled", application.createValueBinding("#{foo}")); assertNotNull(test.getValueBinding("itemDisabled")); assertTrue(test.isItemDisabled()); test.setItemDisabled(false); assertFalse(test.isItemDisabled()); test.setValueBinding("itemDisabled", null); assertNull(test.getValueBinding("itemDisabled")); assertFalse(test.isItemDisabled()); // "itemLabel" property request.setAttribute("foo", "bar"); test.setItemLabel(null); assertNull(test.getItemLabel()); test.setValueBinding("itemLabel", application.createValueBinding("#{foo}")); assertNotNull(test.getValueBinding("itemLabel")); assertEquals("bar", test.getItemLabel()); test.setItemLabel("baz"); assertEquals("baz", test.getItemLabel()); test.setItemLabel(null); assertEquals("bar", test.getItemLabel()); test.setValueBinding("itemLabel", null); assertNull(test.getValueBinding("itemLabel")); assertNull(test.getItemLabel()); // "itemValue" property request.setAttribute("foo", "bar"); test.setItemValue(null); assertNull(test.getItemValue()); test.setValueBinding("itemValue", application.createValueBinding("#{foo}")); assertNotNull(test.getValueBinding("itemValue")); assertEquals("bar", test.getItemValue()); test.setItemValue("baz"); assertEquals("baz", test.getItemValue()); test.setItemValue(null); assertEquals("bar", test.getItemValue()); test.setValueBinding("itemValue", null); assertNull(test.getValueBinding("itemValue")); assertNull(test.getItemValue()); // "value" property request.setAttribute("foo", "bar"); test.setValue(null); assertNull(test.getValue()); test.setValueBinding("value", application.createValueBinding("#{foo}")); assertNotNull(test.getValueBinding("value")); assertEquals("bar", test.getValue()); test.setValue("baz"); assertEquals("baz", test.getValue()); test.setValue(null); assertEquals("bar", test.getValue()); test.setValueBinding("value", null); assertNull(test.getValueBinding("value")); assertNull(test.getValue()); }