@Override @Before public void setUp() throws Exception { super.setUp(); config = new DBConfigUtils(false); config.refreshVdcOptionCache(dbFacade); }
@Test public void testDefaultValues() { ConfigValues[] values = ConfigValues.values(); for (ConfigValues curConfig : values) { if (curConfig == ConfigValues.Invalid) continue; Field configField = null; try { configField = ConfigValues.class.getField(curConfig.name()); } catch (Exception e) { Assert.fail("Failed to look up" + curConfig.name()); e.printStackTrace(); } OptionBehaviourAttribute behaviourAttr = configField.getAnnotation(OptionBehaviourAttribute.class); if (behaviourAttr != null && behaviourAttr.behaviour() == OptionBehaviour.Password) { continue; // no cert available for password decrypt } TypeConverterAttribute typeAttr = configField.getAnnotation(TypeConverterAttribute.class); assertNotNull( "The following field is missing the " + TypeConverterAttribute.class.getSimpleName() + " annotation: " + curConfig.name(), typeAttr); Class<?> c = typeAttr.value(); Object obj = config.getValue(curConfig, ConfigCommon.defaultConfigurationVersion); Assert.assertTrue("null return for " + curConfig.name(), obj != null); Assert.assertTrue( curConfig.name() + " is a " + obj.getClass().getName() + " but should be a " + c.getName(), c.isInstance(obj)); } }