1 22 package org.jboss.test.jmx.test; 23 24 import javax.management.MBeanServerConnection ; 25 import javax.management.ObjectName ; 26 27 import junit.framework.Test; 28 29 import org.jboss.test.JBossTestCase; 30 31 36 public class AttributesUnitTestCase 37 extends JBossTestCase 38 { 39 public AttributesUnitTestCase(String name) 40 { 41 super(name); 42 } 43 44 public static Test suite() 45 throws Exception 46 { 47 return getDeploySetup(AttributesUnitTestCase.class, "attrtest.sar"); 48 } 49 50 public void testXmlString() 51 throws Exception 52 { 53 getLog().info("+++ testXmlString"); 54 MBeanServerConnection server = super.getServer(); 55 ObjectName serviceName = new ObjectName ("test:name=AttrTests,case=#1"); 56 String xml = (String ) server.getAttribute(serviceName, "XmlString"); 57 getLog().info("XmlString: '"+xml+"'"); 58 String expectedXml = "<depinfo>\n<value name='abc'>A Value</value>\n</depinfo>"; 59 assertTrue("xml cdata as expected", xml.equals(expectedXml)); 60 } 61 62 public void testSysPropRef() 63 throws Exception 64 { 65 MBeanServerConnection server = super.getServer(); 66 ObjectName serviceName = new ObjectName ("test:name=AttrTests,case=#1"); 67 String prop = (String ) server.getAttribute(serviceName, "SysPropRef"); 68 assertTrue("prop has been replaced", prop.equals("${java.vm.version}") == false); 69 } 70 71 public void testTrimedString() 72 throws Exception 73 { 74 MBeanServerConnection server = super.getServer(); 75 ObjectName serviceName = new ObjectName ("test:name=AttrTests,case=#1"); 76 String prop = (String ) server.getAttribute(serviceName, "TrimedString"); 77 assertTrue("whitespace is trimed", prop.equals("123456789")); 78 } 79 80 public void testSysPropRefNot() 81 throws Exception 82 { 83 MBeanServerConnection server = super.getServer(); 84 ObjectName serviceName = new ObjectName ("test:name=AttrTests,case=#2"); 85 String prop = (String ) server.getAttribute(serviceName, "SysPropRef"); 86 assertTrue("prop has NOT been replaced", prop.equals("${java.vm.version}")); 87 } 88 89 public void testTrimedStringNot() 90 throws Exception 91 { 92 MBeanServerConnection server = super.getServer(); 93 ObjectName serviceName = new ObjectName ("test:name=AttrTests,case=#2"); 94 String prop = (String ) server.getAttribute(serviceName, "TrimedString"); 95 assertTrue("whitespace is NOT trimed", prop.equals(" 123456789 ")); 96 } 97 } 98 | Popular Tags |