public void testEightParamCtor() throws Exception
{
Float[] legalvalues = {new Float(0.75), new Float(1.00), new Float(1.50)};
Float defaultvalue = new Float(1.00);
OpenMBeanAttributeInfoSupport info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
SimpleType.FLOAT,
true,
false,
false,
defaultvalue,
legalvalues);
assertTrue("Null info constructed", info != null);
Set legalset = info.getLegalValues();
assertTrue("Legal set is the wrong size", legalset.size() == legalvalues.length);
assertTrue("0.75 not in legal set",
legalset.contains(new Float(0.75)));
assertTrue("1.00 not in legal set",
legalset.contains(new Float(1.00)));
assertTrue("1.50 not in legal set",
legalset.contains(new Float(1.50)));
info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
SimpleType.FLOAT,
true,
false,
false,
defaultvalue,
null);
assertTrue("Null info constructed", info != null);
assertFalse("There should be no legal value set for null",
info.hasLegalValues());
info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
SimpleType.FLOAT,
true,
false,
false,
defaultvalue,
new Float[0]);
assertTrue("Null info constructed", info != null);
assertFalse("There should be no legal value set for Float[0]",
info.hasLegalValues());
info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
SimpleType.FLOAT,
true,
false,
false,
null,
legalvalues);
assertTrue("Null info constructed", info != null);
assertFalse("Has a default value", info.hasDefaultValue());
try
{
info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
SimpleType.FLOAT,
true,
false,
false,
"Invalid Default Value",
new Float[0]);
fail("Expecting exception for invalid default value");
}
catch (OpenDataException x)
{
assertTrue(true);
}
try
{
info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
SimpleType.FLOAT,
true,
false,
false,
defaultvalue,
new Object[]{new Float(0.75), "$1.50"});
fail("Expecting exception for invalid legal value");
}
catch (OpenDataException x)
{
assertTrue(true);
}
try
{
info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
new ArrayType(1, SimpleType.FLOAT),
true,
false,
false,
defaultvalue,
null);
fail("Expecting exception for non null default w/ArrayType attribute");
}
catch (OpenDataException x)
{
assertTrue(true);
}
try
{
info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
new ArrayType(1, SimpleType.FLOAT),
true,
false,
false,
null,
new Float[]{new Float(0.75), new Float(1.50)});
fail("Expecting exception for non null legal set w/ArrayType attribute");
}
catch (OpenDataException x)
{
assertTrue(true);
}
try
{
info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
new ArrayType(1, SimpleType.FLOAT),
true,
false,
false,
new Float(0.25),
legalvalues);
fail("Expecting exception for default not in legal set");
}
catch (OpenDataException x)
{
assertTrue(true);
}
try
{
info =
new OpenMBeanAttributeInfoSupport("price",
"how much it costs",
SimpleType.INTEGER,
true,
false,
false,