protected void setUp() { map = new DefaultsMap(); map.put("foo", "bar"); map.put("stay", "unchanged"); map.put("foo", "baz"); }
public void testClearAndIsEmpty() { assertFalse(map.isEmpty()); map.clear(); assertTrue(map.isEmpty()); assertEquals(0, map.getChanged().size()); assertEquals(0, map.size()); }
public void testRemove() { assertEquals(1, map.getChanged().size()); map.remove("foo"); assertEquals(0, map.getChanged().size()); assertFalse(map.containsKey("foo")); map.put("foo", "two"); assertEquals(0, map.getChanged().size()); map.remove("foo"); assertFalse(map.containsKey("foo")); }
/** * Allows the JMX Agent to set a command line option to be used when MySQL * is launched. * * @throws AttributeNotFoundException * ReflectionException */ public synchronized void setAttribute(Attribute attribute) throws AttributeNotFoundException { String name = attribute.getName(); if (!attributes.containsKey(name)) { // new RuntimeException("attempting to set '" + name + "'") // .printStackTrace(); throw new AttributeNotFoundException(name); } attributes.put(name, attribute); }
public void testPutUnchangedOriginal() { assertEquals(1, map.getChanged().size()); map.put("stay", "unchanged"); assertEquals(1, map.getChanged().size()); } }
public void testGetAndGetDefault() throws Exception { assertEquals("bar", map.getDefault("foo")); assertEquals("baz", map.get("foo")); assertEquals("unchanged", map.get("stay")); }
public void testContainsValue() throws Exception { assertTrue(map.containsValue("baz")); assertFalse(map.containsValue("bar")); assertFalse(map.containsValue(null)); map.put("null", null); assertTrue(map.containsValue(null)); }
public void testValues() { Collection values = map.values(); assertEquals(2, values.size()); assertTrue(map.containsValue("baz")); assertTrue(map.containsValue("unchanged")); }
/** * @param attributeName * represents a command line argument to a MySQL database. * @return a String with the value associated the argument */ public synchronized Object getAttribute(String attributeName) throws AttributeNotFoundException { Attribute attribute = ((Attribute) attributes.get(attributeName)); if (attribute == null) { throw new AttributeNotFoundException(attributeName); } return attribute.getValue(); }
private String getStringAttribute(final String key) { if (!attributes.containsKey(key)) { return null; } Exceptions.Block block = new Exceptions.Block() { protected Object inner() throws Exception { return getAttribute(key); } }; return (String) block.exec(); } }
public void testEntrySet() throws Exception { Set entrySet = map.entrySet(); assertEquals(2, entrySet.size()); List entries = new ArrayList(entrySet); Map.Entry one = (Map.Entry) entries.get(0); assertEquals("foo", one.getKey()); assertEquals("baz", one.getValue()); Map.Entry two = (Map.Entry) entries.get(1); assertEquals("stay", two.getKey()); assertEquals("unchanged", two.getValue()); }
Map attributesToOpionMap() { Map options = new HashMap(); for (Iterator iter = attributes.getChanged().values().iterator(); iter .hasNext();) { Attribute at = (Attribute) iter.next(); options.put(at.getName(), at.getValue()); } options.remove(AUTOSTART_ATTR); return options; }
private void initAttributes() { attributes = new DefaultsMap(); Map options = new TreeMap(mysqldResource.getServerOptions()); List attInfs = new ArrayList(); makeAttribute(attInfs, AUTOSTART_ATTR, Boolean.FALSE.toString(), true); for (Iterator iter = options.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String attName = (String) entry.getKey(); String attValue = (String) entry.getValue(); makeAttribute(attInfs, attName, attValue, true); } makeAttribute(attInfs, versionAttributeName(), VERSION, false); this.attrInfos = (MBeanAttributeInfo[]) attInfs .toArray(new MBeanAttributeInfo[attInfs.size()]); }
public void testPutUnchangedOriginal() { assertEquals(1, map.getChanged().size()); map.put("stay", "unchanged"); assertEquals(1, map.getChanged().size()); } }
public void testGetAndGetDefault() throws Exception { assertEquals("bar", map.getDefault("foo")); assertEquals("baz", map.get("foo")); assertEquals("unchanged", map.get("stay")); }
public void testContainsValue() throws Exception { assertTrue(map.containsValue("baz")); assertFalse(map.containsValue("bar")); assertFalse(map.containsValue(null)); map.put("null", null); assertTrue(map.containsValue(null)); }