public void testGetAttribute() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); assertEquals("bar", myBean.getAttribute("foo")); try { myBean.getAttribute("b0gus"); fail(); } catch (AttributeNotFoundException e) { assertTrue(e.getMessage().indexOf("b0gus") >= 0); } }
public void testAutoStart() throws Exception { MysqldResourceI mysqld = new MysqldResourceTestImpl(); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); assertFalse(mysqld.isRunning()); String autostart = SimpleMysqldDynamicMBean.AUTOSTART_ATTR; String str_true = Boolean.TRUE.toString(); myBean.setAttribute(new Attribute(autostart, str_true)); assertFalse(mysqld.isRunning()); assertFalse(mysqld.getServerOptions().containsKey(autostart)); }
public void testPassOptionsMapToMysqld() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); options.put("baz", "wiz"); options.put("datadir", "/bogus/dir"); options.put("help", ""); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); myBean.setAttribute(new Attribute("foo", "changed")); assertTrue(myBean.attributesToOpionMap().containsKey("foo")); assertEquals(1, myBean.attributesToOpionMap().size()); myBean.invoke(SimpleMysqldDynamicMBean.START_METHOD, null, null); assertEquals("changed", mysqld.getServerOptions().get("foo")); }
public void testSetAttribute() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); try { myBean.setAttribute(new Attribute("bogus", "werid")); fail(); } catch (AttributeNotFoundException e) { assertTrue(e.getMessage(), e.getMessage().indexOf("bogus") >= 0); } }
public void testFreezeAttributes() { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); MBeanInfo info = myBean.getMBeanInfo(); MBeanAttributeInfo[] atts = info.getAttributes(); assertTrue(atts[0].isWritable()); myBean.freezeAttributes(); info = myBean.getMBeanInfo(); atts = info.getAttributes(); assertFalse(atts[0].isWritable()); }
assertNotNull(info); assertEquals(myBean.getClass().getName(), info.getClassName()); assertEquals("MySQL MBean", info.getDescription()); assertEquals(3, atts.length); assertEquals(SimpleMysqldDynamicMBean.AUTOSTART_ATTR, atts[0].getName()); assertEquals("", atts[0].getDescription()); assertEquals(String.class.getName(), atts[0].getType()); assertTrue(atts[0].isReadable()); assertTrue(atts[0].isWritable()); assertEquals(false, atts[0].isIs()); assertEquals("foo", atts[1].getName()); assertEquals("", atts[1].getDescription()); assertEquals(String.class.getName(), atts[1].getType()); assertTrue(atts[1].isReadable()); assertTrue(atts[1].isWritable()); assertEquals(false, atts[1].isIs()); assertEquals(1, cons.length); assertEquals(0, cons[0].getSignature().length); assertEquals(0, notes.length); assertEquals(1, ops.length); assertEquals(SimpleMysqldDynamicMBean.START_METHOD, ops[0].getName()); assertEquals("Start MySQL", ops[0].getDescription()); assertEquals(0, ops[0].getSignature().length); assertEquals("void", ops[0].getReturnType());
public void testGetAttributeList() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); options.put("baz", "wiz"); options.put("datadir", "/bogus/dir"); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); AttributeList attributeList = myBean.getAttributes(new String[] { "foo", "datadir" }); assertEquals(2, attributeList.size()); Attribute att = (Attribute) attributeList.get(0); assertEquals("foo", att.getName()); assertEquals("bar", att.getValue()); }
public void testGetAgentVersion() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); String verAttName = myBean.versionAttributeName(); String expected = "$Id: " + new ClassUtil().shortName(myBean); String beanVersion = (String) myBean.getAttribute(verAttName); new TestUtil().assertContainsIgnoreCase(beanVersion, expected); MBeanInfo info = myBean.getMBeanInfo(); MBeanAttributeInfo[] atts = info.getAttributes(); assertTrue(atts[0].isReadable()); assertTrue(atts[0].isWritable()); assertFalse(atts[0].isIs()); assertTrue(atts[1].isReadable()); assertTrue(atts[1].isWritable()); assertFalse(atts[1].isIs()); assertTrue(atts[2].isReadable()); assertFalse(atts[2].isWritable()); assertFalse(atts[2].isIs()); }
assertNotNull(info); assertEquals(myBean.getClass().getName(), info.getClassName()); assertEquals("MySQL MBean", info.getDescription()); assertEquals(3, atts.length); assertEquals(SimpleMysqldDynamicMBean.AUTOSTART_ATTR, atts[0].getName()); assertEquals("", atts[0].getDescription()); assertEquals(String.class.getName(), atts[0].getType()); assertTrue(atts[0].isReadable()); assertTrue(atts[0].isWritable()); assertEquals(false, atts[0].isIs()); assertEquals("foo", atts[1].getName()); assertEquals("", atts[1].getDescription()); assertEquals(String.class.getName(), atts[1].getType()); assertTrue(atts[1].isReadable()); assertTrue(atts[1].isWritable()); assertEquals(false, atts[1].isIs()); assertEquals(1, cons.length); assertEquals(0, cons[0].getSignature().length); assertEquals(0, notes.length); assertEquals(1, ops.length); assertEquals(SimpleMysqldDynamicMBean.START_METHOD, ops[0].getName()); assertEquals("Start MySQL", ops[0].getDescription()); assertEquals(0, ops[0].getSignature().length); assertEquals("void", ops[0].getReturnType());
public void testSetAttribute() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, options, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); try { myBean.setAttribute(new Attribute("bogus", "werid")); fail(); } catch (AttributeNotFoundException e) { assertTrue(e.getMessage(), e.getMessage().indexOf("bogus") >= 0); } }
public void testPassOptionsMapToMysqld() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); options.put("baz", "wiz"); options.put("datadir", "/bogus/dir"); options.put("help", ""); MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, options, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); myBean.setAttribute(new Attribute("foo", "changed")); assertTrue(myBean.attributesToOpionMap().containsKey("foo")); assertEquals(1, myBean.attributesToOpionMap().size()); myBean.invoke(SimpleMysqldDynamicMBean.START_METHOD, null, null); assertEquals("changed", mysqld.getServerOptions().get("foo")); }
public void testSetAttributes() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); options.put("baz", "wiz"); options.put("datadir", "/bogus/dir"); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); AttributeList list = new AttributeList(); list.add(new Attribute("foo", "changed")); list.add(new Attribute("datadir", "/changed/dir")); myBean.setAttributes(list); assertEquals("changed", myBean.getAttribute("foo")); assertEquals("wiz", myBean.getAttribute("baz")); assertEquals("/changed/dir", myBean.getAttribute("datadir")); }
public void testInvoke() throws Exception { MysqldResourceI mysqld = new MysqldResourceTestImpl(); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); assertEquals(false, mysqld.isRunning()); myBean.invoke(SimpleMysqldDynamicMBean.START_METHOD, null, null); assertTrue(mysqld.isRunning()); myBean.invoke(SimpleMysqldDynamicMBean.STOP_METHOD, null, null); assertEquals(false, mysqld.isRunning()); try { myBean.invoke("bogus", null, null); fail(); } catch (Exception e) { assertTrue(e.getMessage().indexOf("bogus") >= 0); } }
public void testFreezeAttributes() { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, options, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); MBeanInfo info = myBean.getMBeanInfo(); MBeanAttributeInfo[] atts = info.getAttributes(); assertTrue(atts[0].isWritable()); myBean.freezeAttributes(); info = myBean.getMBeanInfo(); atts = info.getAttributes(); assertFalse(atts[0].isWritable()); }
public void testSetAttributes() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); options.put("baz", "wiz"); options.put("datadir", "/bogus/dir"); MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, options, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); AttributeList list = new AttributeList(); list.add(new Attribute("foo", "changed")); list.add(new Attribute("datadir", "/changed/dir")); myBean.setAttributes(list); assertEquals("changed", myBean.getAttribute("foo")); assertEquals("wiz", myBean.getAttribute("baz")); assertEquals("/changed/dir", myBean.getAttribute("datadir")); }
public void testAutoStart() throws Exception { MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); assertFalse(mysqld.isRunning()); String autostart = SimpleMysqldDynamicMBean.AUTOSTART_ATTR; String str_true = Boolean.TRUE.toString(); myBean.setAttribute(new Attribute(autostart, str_true)); assertFalse(mysqld.isRunning()); assertFalse(mysqld.getServerOptions().containsKey(autostart)); }
public void testGetAttribute() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, options, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); assertEquals("bar", myBean.getAttribute("foo")); try { myBean.getAttribute("b0gus"); fail(); } catch (AttributeNotFoundException e) { assertTrue(e.getMessage().indexOf("b0gus") >= 0); } }
public void testGetAgentVersion() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, options, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); String verAttName = myBean.versionAttributeName(); String expected = "$Id: " + new Str().shortClassName(myBean); String beanVersion = (String) myBean.getAttribute(verAttName); new TestUtil().assertContainsIgnoreCase(beanVersion, expected); MBeanInfo info = myBean.getMBeanInfo(); MBeanAttributeInfo[] atts = info.getAttributes(); assertTrue(atts[0].isReadable()); assertTrue(atts[0].isWritable()); assertFalse(atts[0].isIs()); assertTrue(atts[1].isReadable()); assertTrue(atts[1].isWritable()); assertFalse(atts[1].isIs()); assertTrue(atts[2].isReadable()); assertFalse(atts[2].isWritable()); assertFalse(atts[2].isIs()); }
public void testGetAttributeList() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); options.put("baz", "wiz"); options.put("datadir", "/bogus/dir"); MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, options, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); AttributeList attributeList = myBean.getAttributes(new String[] { "foo", "datadir" }); assertEquals(2, attributeList.size()); Attribute att = (Attribute) attributeList.get(0); assertEquals("foo", att.getName()); assertEquals("bar", att.getValue()); }
public void testInvoke() throws Exception { MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); assertEquals(false, mysqld.isRunning()); myBean.invoke(SimpleMysqldDynamicMBean.START_METHOD, null, null); assertTrue(mysqld.isRunning()); myBean.invoke(SimpleMysqldDynamicMBean.STOP_METHOD, null, null); assertEquals(false, mysqld.isRunning()); try { myBean.invoke("bogus", null, null); fail(); } catch (Exception e) { assertTrue(e.getMessage().indexOf("bogus") >= 0); } }