1 22 package org.jboss.test.jcaprops.test; 23 24 import javax.management.Attribute ; 25 import javax.management.AttributeList ; 26 import javax.management.MBeanServerConnection ; 27 28 import junit.framework.Test; 29 30 import org.jboss.test.JBossTestCase; 31 import org.jboss.test.jcaprops.support.PropertyTestResourceAdapterMBean; 32 33 39 public class JBossRaXmlOverrideUnitTestCase extends JBossTestCase 40 { 41 42 public JBossRaXmlOverrideUnitTestCase(String name) 43 { 44 super(name); 45 } 46 47 public void testJBossRaXmlOverride() throws Exception 48 { 49 50 AttributeList expected = new AttributeList (); 51 expected.add(new Attribute ("StringRAR", "XMLOVERRIDE")); 52 expected.add(new Attribute ("BooleanRAR", Boolean.FALSE)); 53 expected.add(new Attribute ("ByteRAR", new Byte ((byte) 1))); 54 expected.add(new Attribute ("CharacterRAR", new Character ('A'))); 55 expected.add(new Attribute ("ShortRAR", new Short ((short) 2))); 56 expected.add(new Attribute ("IntegerRAR", new Integer (3))); 57 expected.add(new Attribute ("LongRAR", new Long (4))); 58 expected.add(new Attribute ("FloatRAR", Float.valueOf("5e6"))); 59 expected.add(new Attribute ("DoubleRAR", Double.valueOf("7e8"))); 60 MBeanServerConnection connection = getServer(); 61 AttributeList result = connection.getAttributes(PropertyTestResourceAdapterMBean.NAME, getExpectedStringArray(expected)); 62 63 AttributeList resultClone = (AttributeList ) result.clone(); 64 resultClone.removeAll(expected); 65 assertTrue("Did not expect: " + list(resultClone) + " expected " + list(expected), resultClone.size() == 0); 66 67 expected.removeAll(result); 68 assertTrue("Expected: " + list(expected) + " got " + list(result), expected.size() == 0); 69 70 } 71 72 public static Test suite() throws Exception 73 { 74 return getDeploySetup(JBossRaXmlOverrideUnitTestCase.class, "testjcaprops-override.rar"); 75 } 76 77 protected String [] getExpectedStringArray(AttributeList attributes) 78 { 79 String [] result = new String [attributes.size()]; 80 for (int i = 0; i < attributes.size(); ++i) 81 result [i] = ((Attribute ) attributes.get(i)).getName(); 82 return result; 83 } 84 85 protected String list(AttributeList list) 86 { 87 StringBuffer buffer = new StringBuffer (); 88 buffer.append('['); 89 for (int i = 0; i < list.size(); ++i) 90 { 91 Attribute attribute = (Attribute ) list.get(i); 92 buffer.append(attribute.getName()); 93 buffer.append('='); 94 buffer.append(attribute.getValue()); 95 if (i+1 < list.size()) 96 buffer.append(", "); 97 } 98 buffer.append(']'); 99 return buffer.toString(); 100 } 101 102 103 } 104 | Popular Tags |