### Question:
JavaMailJMSStatistics extends NotificationBroadcasterSupport implements JavaMailJMSStatisticsLocal, DynamicMBean { @Override public AttributeList setAttributes(AttributeList attributes) { for(Attribute attribute : attributes.asList()) { try { setAttribute(attribute); } catch (Exception e) { throw new IllegalStateException("Cannot set value '" + attribute.getValue() + "' for " + attribute.getName(), e); } } return attributes; }  @PostConstruct void registerInJMX(); @PreDestroy void unregisterFromJMX(); void onSuccess(MimeMessage mimeMessage, Address[] addresses); void onFailure(MimeMessage mimeMessage, Address[] addresses, Exception ex); @Override AttributeList getAttributes(String[] attributeNames); @Override Object getAttribute(String attribute); @Override void setAttribute(Attribute attribute); @Override AttributeList setAttributes(AttributeList attributes); @Override Object invoke(String actionName, Object[] params, String[] signature); @Override MBeanInfo getMBeanInfo(); static final String NOTIFICATION_TYPE_SUCCESS; static final String JAVA_MAIL_SEND_FAILURE; static final ObjectName JMX_OBJECT_NAME; }### Answer:
@Test(expected = Exception.class) public void testSetReadOnlyAttributes() throws Exception { MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); AttributeList attributeList = new AttributeList(); Attribute attribute = new Attribute("countSuccessful", 10L); attributeList.add(attribute); platformMBeanServer.setAttributes(JavaMailJMSStatistics.JMX_OBJECT_NAME, attributeList); }