1 22 package org.jboss.test.system.controller.configure.value.text.test; 23 24 import java.math.BigDecimal ; 25 import java.text.DateFormat ; 26 import java.text.SimpleDateFormat ; 27 import java.util.Date ; 28 29 import javax.management.ObjectName ; 30 31 import org.jboss.deployment.DeploymentException; 32 import org.jboss.test.system.controller.AbstractControllerTest; 33 import org.jboss.test.system.controller.support.BrokenDynamicMBeanAttributeInfoTypeNotFound; 34 import org.jboss.test.system.controller.support.BrokenDynamicMBeanNoAttributeInfoType; 35 import org.jboss.test.system.controller.support.Simple; 36 import org.jboss.test.system.controller.support.SimpleMBean; 37 import org.jboss.util.NestedRuntimeException; 38 39 45 public abstract class TextValueTest extends AbstractControllerTest 46 { 47 private static final DateFormat dateFormat = new SimpleDateFormat ("EEE MMM d HH:mm:ss z yyyy"); 48 49 private static final String stringValue = new String ("StringValue"); 50 private static final Byte byteValue = new Byte ("12"); 51 private static final Boolean booleanValue = Boolean.TRUE; 52 private static final Short shortValue = new Short ("123"); 55 private static final Integer integerValue = new Integer ("1234"); 56 private static final Long longValue = new Long ("12345"); 57 private static final Float floatValue = new Float ("3.14"); 58 private static final Double doubleValue = new Double ("3.14e12"); 59 private static final Date dateValue = createDate("Mon Jan 01 00:00:00 CET 2001"); 60 private static final BigDecimal bigDecimalValue = new BigDecimal ("12e4"); 61 63 public TextValueTest(String name) 64 { 65 super(name); 66 } 67 68 public void testPropertyEditors() throws Exception 69 { 70 ObjectName name = SimpleMBean.OBJECT_NAME; 71 72 assertInstall(name); 73 try 74 { 75 Simple test = getSimple(); 76 77 assertEquals(stringValue, test.getAString()); 78 assertEquals(byteValue, test.getAByte()); 79 assertEquals(booleanValue, test.getABoolean()); 80 assertEquals(shortValue, test.getAShort()); 83 assertEquals(integerValue, test.getAnInt()); 84 assertEquals(longValue, test.getALong()); 85 assertEquals(floatValue, test.getAFloat()); 86 assertEquals(doubleValue, test.getADouble()); 87 assertEquals(dateValue, test.getADate()); 88 assertEquals(bigDecimalValue, test.getABigDecimal()); 89 assertEquals(byteValue.byteValue(), test.getAbyte()); 92 assertEquals(booleanValue.booleanValue(), test.isAboolean()); 93 assertEquals(shortValue.shortValue(), test.getAshort()); 96 assertEquals(integerValue.intValue(), test.getAnint()); 97 assertEquals(longValue.longValue(), test.getAlong()); 98 assertEquals(floatValue.floatValue(), test.getAfloat()); 99 assertEquals(doubleValue.doubleValue(), test.getAdouble()); 100 } 101 finally 102 { 103 assertUninstall(name); 104 } 105 } 106 107 public void testNoPropertyEditor() throws Exception 108 { 109 assertDeployFailure(SimpleMBean.OBJECT_NAME, DeploymentException.class); 110 } 111 112 public void testNoAttributeInfoType() throws Exception 113 { 114 assertDeployFailure(BrokenDynamicMBeanNoAttributeInfoType.OBJECT_NAME, DeploymentException.class); 115 } 116 117 public void testAttributeInfoTypeNotFound() throws Exception 118 { 119 assertDeployFailure(BrokenDynamicMBeanAttributeInfoTypeNotFound.OBJECT_NAME, ClassNotFoundException .class); 120 } 121 122 private static Date createDate(String date) 123 { 124 try 125 { 126 return dateFormat.parse(date); 127 } 128 catch (Exception e) 129 { 130 throw new NestedRuntimeException(e); 131 } 132 } 133 } 134 | Popular Tags |