/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4883712 4869006 4894856 5016685
* @summary Test that DescriptorSupport correctly validates fields
* @author Eamonn McManus
* @run clean DescriptorSupportTest
* @run build DescriptorSupportTest
* @run main DescriptorSupportTest
*/
public class DescriptorSupportTest {
"value", "",
"severity", "0",
"severity", "6",
};
"name", null,
"name", "",
"descriptorType", null,
"descriptorType", "",
"setMethod", null,
"getMethod", null,
"role", null,
"class", null,
"visibility", null,
"visibility", "0",
"visibility", "5",
"severity", null,
"severity", "-1",
"severity", "7",
"persistPolicy", null,
"persistPolicy", "bogusPersistPolicy",
"persistPeriod", null,
"persistPeriod", "not a number",
"currencyTimeLimit", null,
"currencyTimeLimit", "not a number",
"lastUpdatedTimeStamp", null,
"lastUpdatedTimeStamp", "not a number",
"lastReturnedTimeStamp", null,
"lastReturnedTimeStamp", "not a number",
"log", null,
"log", "not T or F or true or false",
};
boolean ok = true;
"mandatory");
for (int i = 0; i < 3; i++) {
if (addName)
if (addDescriptorType)
"DescriptorSupport with " +
ok = false;
} else
}
" DescriptorSupport fields");
try {
if (shouldAccept)
else {
ok = false;
}
} catch (RuntimeOperationsException e) {
if (shouldAccept) {
": " + e);
ok = false;
} else {
// OK: this is what should happen
}
} catch (Exception e) {
ok = false;
}
}
}
// 4894856: ModelMBeanInfoSupport.setDescriptor(d, "mbean") fails
try {
} catch (Exception e) {
ok = false;
}
// 5016685: DescriptorSupport forces field names to lower case
"but preserved");
"DescriptorSupport(String[])");
new String[] {"blah"}),
"DescriptorSupport(String[], Object[])");
"DescriptorSupport(Descriptor)");
"DescriptorSupport(String)");
if (ok)
else {
}
}
boolean ok = true;
ok = false;
}
ok = false;
}
ok = false;
}
ok = false;
}
ok = false;
}
ok = false;
}
ok = false;
}
d.removeField("NAme");
names = d.getFieldNames();
ok = false;
}
if (ok)
return ok;
}
}