Search in sources :

Example 21 with FormValidation

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);
}
Also used : FormValidation(hudson.util.FormValidation) Test(org.junit.Test)

Example 22 with FormValidation

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;
}
Also used : FormValidation(hudson.util.FormValidation) Transaction(org.hibernate.Transaction) Properties(java.util.Properties) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) Session(org.hibernate.Session)

Example 23 with FormValidation

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);
}
Also used : FormValidation(hudson.util.FormValidation) DbAuditPublisherImpl(org.jenkins.plugins.audit2db.internal.DbAuditPublisherImpl) DbAuditPublisher(org.jenkins.plugins.audit2db.DbAuditPublisher) DbAuditPublisherDescriptor(org.jenkins.plugins.audit2db.DbAuditPublisherDescriptor) Test(org.junit.Test)

Example 24 with FormValidation

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);
}
Also used : FormValidation(hudson.util.FormValidation) DbAuditPublisherImpl(org.jenkins.plugins.audit2db.internal.DbAuditPublisherImpl) DbAuditPublisher(org.jenkins.plugins.audit2db.DbAuditPublisher) DbAuditPublisherDescriptor(org.jenkins.plugins.audit2db.DbAuditPublisherDescriptor) Test(org.junit.Test)

Aggregations

FormValidation (hudson.util.FormValidation)24 Test (org.junit.Test)21 DescriptorImpl (jenkins.plugins.nodejs.configfiles.NPMRegistry.DescriptorImpl)11 FreeStyleProject (hudson.model.FreeStyleProject)4 Item (hudson.model.Item)3 Permission (hudson.security.Permission)3 DbAuditPublisher (org.jenkins.plugins.audit2db.DbAuditPublisher)3 DbAuditPublisherDescriptor (org.jenkins.plugins.audit2db.DbAuditPublisherDescriptor)3 DbAuditPublisherImpl (org.jenkins.plugins.audit2db.internal.DbAuditPublisherImpl)3 IOException (java.io.IOException)2 ServletException (javax.servlet.ServletException)2 Credentials (com.cloudbees.plugins.credentials.Credentials)1 Domain (com.cloudbees.plugins.credentials.domains.Domain)1 UsernamePasswordCredentialsImpl (com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl)1 Cause (hudson.model.Cause)1 FormException (hudson.model.Descriptor.FormException)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 BuildTrigger (hudson.tasks.BuildTrigger)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1