* This test uses the xmbean.dtd
*/
public void testCachedAttribute2() throws Exception
{
MBeanServer server = MBeanServerFactory.createMBeanServer();
Test resource = new Test();
Descriptor d = new DescriptorSupport();
d.setField(RESOURCE_REFERENCE, resource);
d.setField(RESOURCE_TYPE, "file:./src/main/test/implementation/modelmbean/support/xml/TrivialManagementInterface5.xml");
d.setField(SAX_PARSER, "org.apache.crimson.parser.XMLReaderImpl");
XMBean mmb = new XMBean(d, DESCRIPTOR);
ObjectName name = new ObjectName(":test=test");
server.registerMBean(mmb, name);
server.getAttribute(name, "Something");
assertTrue(resource.getBarCount() == 1);
server.setAttribute(name, new Attribute("Something", "yksi"));
assertTrue(resource.getFooCount() == 1);
String str = (String)server.getAttribute(name, "Something");
assertTrue(resource.getBarCount() == 1);
assertTrue(str.equals("yksi"));
try { Thread.sleep(1100); } catch (Throwable t) {}
server.getAttribute(name, "Something");
assertTrue(resource.getBarCount() == 2);
server.setAttribute(name, new Attribute("Something", "kaksi"));
assertTrue(resource.getFooCount() == 2);
try { Thread.sleep(1100); } catch (Throwable t) {}
str = (String)server.getAttribute(name, "Something");
assertTrue(resource.getBarCount() == 3);
assertTrue(str.equals("kaksi"));
str = (String)server.getAttribute(name, "Something");
assertTrue(resource.getBarCount() == 3);
assertTrue(str.equals("kaksi"));
}