public void testGetSetProperties() throws Exception { PortletContext original = PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE, false); PropertyMap props = consumer.getProperties(original); checkProperties(props, BasicPortletManagementBehavior.PROPERTY_VALUE); PortletContext clone = consumer.createClone(PortletStateType.OPAQUE, original); props = consumer.getProperties(clone); checkProperties(props, BasicPortletManagementBehavior.PROPERTY_VALUE); consumer.setProperties( clone, new PropertyChange[] { PropertyChange.newUpdate( BasicPortletManagementBehavior.PROPERTY_NAME, BasicPortletManagementBehavior.PROPERTY_NEW_VALUE) }); checkProperties( consumer.getProperties(clone), BasicPortletManagementBehavior.PROPERTY_NEW_VALUE); consumer.setProperties( clone, new PropertyChange[] { PropertyChange.newReset(BasicPortletManagementBehavior.PROPERTY_NAME) }); checkProperties(consumer.getProperties(clone), BasicPortletManagementBehavior.PROPERTY_VALUE); }
public void testSetResetSameProperty() throws PortletInvokerException { PortletContext original = PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE, false); PortletContext clone = consumer.createClone(PortletStateType.OPAQUE, original); try { consumer.setProperties( clone, new PropertyChange[] { PropertyChange.newUpdate( BasicPortletManagementBehavior.PROPERTY_NAME, BasicPortletManagementBehavior.PROPERTY_NEW_VALUE), PropertyChange.newReset(BasicPortletManagementBehavior.PROPERTY_NAME) }); fail("Shouldn't be possible to set and reset the same property in the same call"); } catch (Exception e) { assertTrue( e.getCause() .getLocalizedMessage() .contains( BasicPortletManagementBehavior .CANNOT_BOTH_SET_AND_RESET_A_PROPERTY_AT_THE_SAME_TIME)); } }