@Test
public void testTrustOnly() throws Throwable {
SslProperties props = new SslProperties("ssl", SslProperties.FormType.TRUST_ONLY);
props.init();
List<String> ALL = Arrays.asList(props.useSsl.getName(), props.trustStorePath.getName(),
props.trustStorePassword.getName(), props.trustStoreType.getName());
Form mainForm = props.getForm(Form.MAIN);
assertThat(mainForm.getWidgets(), hasSize(ALL.size()));
for (String field : ALL) {
Widget w = mainForm.getWidget(field);
Assert.assertThat(w, notNullValue());
}
assertFalse(props.useSsl.getValue());
assertTrue(mainForm.getWidget("useSsl").isVisible());
List<String> group1 = Arrays.asList("trustStoreType", "trustStorePath", "trustStorePassword");
for (String pName : group1) {
assertTrue(pName, mainForm.getWidget(pName).isHidden());
}
props.useSsl.setValue(true);
assertTrue(mainForm.getWidget("useSsl").isCallAfter());
PropertiesDynamicMethodHelper.afterProperty(props, "useSsl");
for (String pName : group1) {
assertTrue(pName, mainForm.getWidget(pName).isVisible());
}
}