### Question:
JmxHelper { public void setAttribute(String objectName, String attribute, Object val) { setAttribute(createObjectName(objectName), attribute, val); } JmxHelper(EntityLocal entity);  JmxHelper(String url);  JmxHelper(String url, String user, String password);  JmxHelper(String url, EntityLocal entity, String user, String password); static String toJmxUrl(EntityLocal entity); static String toRmiJmxUrl(String host, Integer jmxRmiServerPort, Integer rmiRegistryPort, String context); static String toJmxmpUrl(String host, Integer jmxmpPort); void setMinTimeBetweenReconnectAttempts(int val); String getUrl(); boolean isConnected(); synchronized void reconnectWithRetryDampened(); synchronized void reconnect(); @SuppressWarnings({ "rawtypes", "unchecked" }) synchronized void connect(); @SuppressWarnings({ "rawtypes", "unchecked" }) Map getConnectionEnvVars(); boolean connect(long timeoutMs); synchronized void disconnect(); void terminate(); ObjectName toLiteralObjectName(ObjectName objectName); Set<ObjectInstance> findMBeans(final ObjectName objectName); ObjectInstance findMBean(ObjectName objectName); Set<ObjectInstance> doesMBeanExistsEventually(final ObjectName objectName, Duration timeout); Set<ObjectInstance> doesMBeanExistsEventually(final ObjectName objectName, TimeDuration timeout); Set<ObjectInstance> doesMBeanExistsEventually(final ObjectName objectName, long timeoutMillis); Set<ObjectInstance> doesMBeanExistsEventually(String objectName, Duration timeout); Set<ObjectInstance> doesMBeanExistsEventually(String objectName, TimeDuration timeout); Set<ObjectInstance> doesMBeanExistsEventually(String objectName, long timeout, TimeUnit timeUnit); Set<ObjectInstance> doesMBeanExistsEventually(final ObjectName objectName, long timeout, TimeUnit timeUnit); void assertMBeanExistsEventually(ObjectName objectName, Duration timeout); void assertMBeanExistsEventually(ObjectName objectName, TimeDuration timeout); void assertMBeanExistsEventually(ObjectName objectName, long timeoutMillis); void assertMBeanExistsEventually(ObjectName objectName, long timeout, TimeUnit timeUnit); Object getAttribute(ObjectName objectName, final String attribute); void setAttribute(String objectName, String attribute, Object val); void setAttribute(ObjectName objectName, final String attribute, final Object val); Object operation(String objectName, String method, Object... arguments); Object operation(ObjectName objectName, final String method, final Object... arguments); void addNotificationListener(String objectName, NotificationListener listener); void addNotificationListener(String objectName, NotificationListener listener, NotificationFilter filter); void addNotificationListener(ObjectName objectName, NotificationListener listener); void addNotificationListener(final ObjectName objectName, final NotificationListener listener, final NotificationFilter filter); void removeNotificationListener(String objectName, NotificationListener listener); void removeNotificationListener(final ObjectName objectName, final NotificationListener listener); void removeNotificationListener(final ObjectName objectName, final NotificationListener listener, final NotificationFilter filter); M getProxyObject(String objectName, Class<M> mbeanInterface); M getProxyObject(ObjectName objectName, Class<M> mbeanInterface); static ObjectName createObjectName(String name); static final String JMX_URL_FORMAT; static final String RMI_JMX_URL_FORMAT; static final String JMXMP_URL_FORMAT; static final Map<String, String> CLASSES; }### Answer:
@Test public void testSetAttribute() throws Exception { DynamicMBean mbean = jmxService.registerMBean(MutableMap.of("myattr", "myval"), objectName); jmxHelper.setAttribute(jmxObjectName, "myattr", "abc"); Object actual = jmxHelper.getAttribute(jmxObjectName, "myattr"); assertEquals(actual, "abc"); }