use of hudson.util.FormValidation in project contrast-continuous-application-security-plugin by jenkinsci.
the class ThresholdConditionTest method testDoCheckThresholdCountInvalid.
@Test
public void testDoCheckThresholdCountInvalid() {
FormValidation result = descriptor.doCheckThresholdCount("blah");
assertEquals(result.kind, FormValidation.Kind.ERROR);
}
use of hudson.util.FormValidation in project selenium_java by sergueik.
the class DbAuditPublisherDescriptorImpl method doTestJdbcConnection.
/**
* @see org.jenkins.plugins.audit2db.internal.DbAuditPublisherDescriptor#doTestJdbcConnection(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public FormValidation doTestJdbcConnection(@QueryParameter("audit2db.jdbcDriver") final String jdbcDriver, @QueryParameter("audit2db.jdbcUrl") final String jdbcUrl, @QueryParameter("audit2db.jdbcUser") final String username, @QueryParameter("audit2db.jdbcPassword") final String password) throws IOException, ServletException {
LOGGER.log(Level.FINE, String.format("doTestJdbcConnection('%s','%s','%s','*****'", jdbcDriver, jdbcUrl, username));
FormValidation retval = FormValidation.ok(Messages.DbAuditPublisherDescriptor_ConnectionOk());
try {
final Properties props = HibernateUtil.getExtraProperties(jdbcDriver, jdbcUrl, username, password);
final Session session = HibernateUtil.getSessionFactory(props).getCurrentSession();
final Transaction tx = session.beginTransaction();
tx.rollback();
this.jdbcDriver = jdbcDriver;
this.jdbcUrl = jdbcUrl;
this.jdbcUser = username;
this.jdbcPassword = Scrambler.scramble(password);
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
retval = FormValidation.error(e.getMessage());
}
return retval;
}
use of hudson.util.FormValidation in project selenium_java by sergueik.
the class WhenTestingDataSource method testGeneratingDdlWithValidJdbcDetailsShouldSucceed.
@Test
public void testGeneratingDdlWithValidJdbcDetailsShouldSucceed() throws Exception {
final DbAuditPublisher publisher = new DbAuditPublisherImpl();
final DbAuditPublisherDescriptor descriptor = (DbAuditPublisherDescriptor) publisher.getDescriptor();
final FormValidation testResult = descriptor.doGenerateDdl(jdbcDriver, jdbcUrl, jdbcUser, jdbcPassword);
Assert.assertEquals("Unexpected connection error.", FormValidation.Kind.OK, testResult.kind);
}
use of hudson.util.FormValidation in project selenium_java by sergueik.
the class WhenTestingDataSource method testValidJdbcDatasourceShouldSucceed.
@Test
public void testValidJdbcDatasourceShouldSucceed() throws Exception {
final DbAuditPublisher publisher = new DbAuditPublisherImpl();
final DbAuditPublisherDescriptor descriptor = (DbAuditPublisherDescriptor) publisher.getDescriptor();
final FormValidation testResult = descriptor.doTestJdbcConnection(jdbcDriver, jdbcUrl, jdbcUser, jdbcPassword);
Assert.assertEquals("Unexpected connection error.", FormValidation.Kind.OK, testResult.kind);
}
Aggregations