use of hudson.util.FormValidation in project nodejs-plugin by jenkinsci.
the class NPMRegistryValidatorTest method test_server_url_that_contains_variable.
@Test
public void test_server_url_that_contains_variable() throws Exception {
DescriptorImpl descriptor = new DescriptorImpl();
FormValidation result = descriptor.doCheckUrl("${REGISTRY_URL}/root");
assertThat(result.kind, is(Kind.OK));
result = descriptor.doCheckUrl("http://${SERVER_NAME}/root");
assertThat(result.kind, is(Kind.OK));
result = descriptor.doCheckUrl("http://acme.com/${CONTEXT_ROOT}");
assertThat(result.kind, is(Kind.OK));
}
use of hudson.util.FormValidation in project nodejs-plugin by jenkinsci.
the class NPMRegistryValidatorTest method test_credentials_ok.
@Test
public void test_credentials_ok() throws Exception {
String credentialsId = "secret";
Credentials credentials = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, credentialsId, "", "user", "password");
Map<Domain, List<Credentials>> credentialsMap = new HashMap<>();
credentialsMap.put(Domain.global(), Arrays.asList(credentials));
SystemCredentialsProvider.getInstance().setDomainCredentialsMap(credentialsMap);
FreeStyleProject prj = mock(FreeStyleProject.class);
when(prj.hasPermission(isA(Permission.class))).thenReturn(true);
DescriptorImpl descriptor = mock(DescriptorImpl.class);
when(descriptor.doCheckCredentialsId(any(Item.class), (String) any(), anyString())).thenCallRealMethod();
String serverURL = "http://acme.com";
FormValidation result = descriptor.doCheckCredentialsId(prj, credentialsId, serverURL);
assertThat(result.kind, is(Kind.OK));
}
use of hudson.util.FormValidation in project selenium_java by sergueik.
the class DbAuditPublisherDescriptorImpl method doGenerateDdl.
@Override
public FormValidation doGenerateDdl(@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("doGenerateDdl('%s','%s','%s','*****'", jdbcDriver, jdbcUrl, username));
FormValidation retval;
try {
final String ddlText = HibernateUtil.getSchemaDdl(jdbcDriver, jdbcUrl, username, password);
retval = FormValidation.ok(ddlText);
} 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 testInvalidJdbcDriverShouldFail.
@Test
public void testInvalidJdbcDriverShouldFail() throws Exception {
final DbAuditPublisher publisher = new DbAuditPublisherImpl();
final DbAuditPublisherDescriptor descriptor = (DbAuditPublisherDescriptor) publisher.getDescriptor();
final FormValidation testResult = descriptor.doTestJdbcConnection("WrongDriver", jdbcUrl, jdbcUser, jdbcPassword);
Assert.assertEquals("Unexpected successful connection.", FormValidation.Kind.ERROR, testResult.kind);
}
use of hudson.util.FormValidation in project workflow-job-plugin by jenkinsci.
the class BuildTriggerTest method smokes.
@Issue("JENKINS-28113")
@Test
public void smokes() throws Exception {
BuildTrigger.DescriptorImpl d = r.jenkins.getDescriptorByType(BuildTrigger.DescriptorImpl.class);
FreeStyleProject us = r.createProject(FreeStyleProject.class, "us");
WorkflowJob ds = r.createProject(WorkflowJob.class, "ds");
ds.setDefinition(new CpsFlowDefinition("", true));
assertEquals(Collections.singletonList("ds"), d.doAutoCompleteChildProjects("d", us, r.jenkins).getValues());
FormValidation validation = d.doCheck(us, "ds");
assertEquals(validation.renderHtml(), FormValidation.Kind.OK, validation.kind);
us.getPublishersList().add(new BuildTrigger("ds", Result.SUCCESS));
r.jenkins.setQuietPeriod(0);
FreeStyleBuild us1 = r.buildAndAssertSuccess(us);
r.waitUntilNoActivity();
WorkflowRun ds1 = ds.getLastBuild();
assertNotNull("triggered", ds1);
Cause.UpstreamCause cause = ds1.getCause(Cause.UpstreamCause.class);
assertNotNull(cause);
assertEquals(us1, cause.getUpstreamRun());
}
Aggregations