Package hudson.util

Examples of hudson.util.FormValidation$URLCheck


    /**
     * Verifies the signature in the update center data file.
     */
    private FormValidation verifySignature(JSONObject o) throws IOException {
        try {
            FormValidation warning = null;

            JSONObject signature = o.getJSONObject("signature");
            if (signature.isNullObject()) {
                return FormValidation.error("No signature block found in update center '"+id+"'");
            }
View Full Code Here


    @Override
    public NumberMetadataValue createValue(Object o) throws Descriptor.FormException {
        MetadataChecks checks = new MetadataChecks();
        long value;
        if (o instanceof String) {
            FormValidation formValidation = checks.doCheckNumberValue((String)o);
            if (!formValidation.equals(FormValidation.ok())) {
                throw new Descriptor.FormException(formValidation.getMessage(), "");
            }
            value = Long.parseLong((String)o);
        } else {
            throw new Descriptor.FormException("Wrong number format", "");
        }
View Full Code Here

     */
    @Test
    public void testCheckDateValue() throws Exception {
        MetadataChecks checks = new MetadataChecks();

        FormValidation val = checks.doCheckDateValue("I am not a number", "5", "5");
        assertEquals(FormValidation.Kind.ERROR, val.kind);
        val = checks.doCheckDateValue("5", "me neither", "5");
        assertEquals(FormValidation.Kind.ERROR, val.kind);
        val = checks.doCheckDateValue("5", "5", "neither am I");
        assertEquals(FormValidation.Kind.ERROR, val.kind);
View Full Code Here

     */
    @Test
    public void testCheckTimeValue() throws Exception {
        MetadataChecks checks = new MetadataChecks();

        FormValidation val = checks.doCheckTimeValue("I am not a number", "5", "5");
        assertEquals(FormValidation.Kind.ERROR, val.kind);
        val = checks.doCheckTimeValue("5", "me neither", "5");
        assertEquals(FormValidation.Kind.ERROR, val.kind);
        val = checks.doCheckTimeValue("5", "5", "neither am I");
        assertEquals(FormValidation.Kind.ERROR, val.kind);
View Full Code Here

     * @throws Exception if so.
     */
    @Test
    public void testCheckNumberValue() throws Exception {
        MetadataChecks checks = new MetadataChecks();
        FormValidation val = checks.doCheckNumberValue("I am not a human being");
        assertEquals(FormValidation.Kind.ERROR, val.kind);
        val = checks.doCheckNumberValue("43");
        assertEquals(FormValidation.Kind.OK, val.kind);
    }
View Full Code Here

                month = jsonObject.getString("month");
            }
            if (jsonObject.has("year")) {
                year = jsonObject.getString("year");
            }
            FormValidation dateValidation = checks.doCheckDateValue(year, month, day);
            if (!dateValidation.equals(FormValidation.ok())) {
                throw new Descriptor.FormException("Wrong date format " + dateValidation.getMessage(), "");
            }
            cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(day));
            cal.set(Calendar.MONTH, Integer.parseInt(month) - DEFAULT_MONTH_ADJUSTMENT);
            cal.set(Calendar.YEAR, Integer.parseInt(year));


            if (jsonObject.has("details")) {
                String hour = "";
                String minute = "";
                String second = "";
                detailsCheck = true;
                JSONObject details = jsonObject.getJSONObject("details");
                if (details.has("hour")) {
                    hour = details.getString("hour");
                }
                if (details.has("minute")) {
                    minute = details.getString("minute");
                }
                if (details.has("second")) {
                    second = details.getString("second");
                }
                FormValidation timeValidation = checks.doCheckTimeValue(hour, minute, second);
                if (!timeValidation.equals(FormValidation.ok())) {
                    throw new Descriptor.FormException("Wrong time format: " + timeValidation.getMessage(), "");
                }
                cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hour));
                cal.set(Calendar.MINUTE, Integer.parseInt(minute));
                cal.set(Calendar.SECOND, Integer.parseInt(second));
            } else {
View Full Code Here

        }
    }

    @Test
    public void form_validator_should_advise_how_a_regex_could_be_improved() {
        FormValidation result = validator.doCheckIncludeRegex(")");

        assertThat(result.kind, is(ERROR));
        assertThat(htmlDecoded(result.getMessage()), containsString("Unmatched closing ')'"));
    }
View Full Code Here

     * Verifies that Axis names are valid and unique.
     */
    private void checkAxisNames(Iterable<Axis> newAxes) throws FormException {
        HashSet<String> axisNames = new HashSet<String>();
        for (Axis a : newAxes) {
            FormValidation fv = a.getDescriptor().doCheckName(a.getName());
            if (fv.kind!=Kind.OK)
                throw new FormException(Messages.MatrixProject_DuplicateAxisName(),fv,"axis.name");

            if (axisNames.contains(a.getName()))
                throw new FormException(Messages.MatrixProject_DuplicateAxisName(),"axis.name");
View Full Code Here

     */
    public FormValidation doDynamicConfigRefreshCheck(
            @QueryParameter("value")
            final String value) {

        FormValidation validatePositive = FormValidation.validatePositiveInteger(value);
        if (!validatePositive.kind.equals(FormValidation.Kind.OK)) {
            return validatePositive;
        } else {
            int intValue = Integer.parseInt(value);
            if (intValue < GerritDefaultValues.MINIMUM_DYNAMIC_CONFIG_REFRESH_INTERVAL) {
View Full Code Here

TOP

Related Classes of hudson.util.FormValidation$URLCheck

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.