Package org.apache.commons.validator.routines

Examples of org.apache.commons.validator.routines.UrlValidator


    * Testing the same method of URL validator used in validate method. Its was really hard to create Error object
    */
@Test
public void testValidation() throws Exception {
      RegexValidator regex = new RegexValidator(new String[]{"http","https","((localhost)(:[0-9]+))",".*\\.linux-server(:[0-9]+)"});
      UrlValidator validator = new UrlValidator(regex, 0);
      assertTrue("localhost URL should validate",
                validator.isValid("http://localhost:8080/demogadgets/CTSSResourcesMapView.xml"));
        assertTrue("127.0.0.1 should validate",
                validator.isValid("http://127.0.0.1:8080/demogadgets/CTSSResourcesMapView.xml"));
        assertTrue("my.linux-server should validate",
                validator.isValid("http://my.linux-server:8080/demogadgets/CTSSResourcesMapView.xml"));

        assertFalse("broke.my-test should not validate",
                validator.isValid("http://broke.my-test/test/index.html"));

        assertTrue("www.apache.org should still validate",
                validator.isValid("http://www.apache.org/test/index.html"));
    }
View Full Code Here


    private final UrlValidator urlValidator;

    public WidgetValidator() {
        super();
        RegexValidator regex = new RegexValidator(new String[] {"http", "https","((localhost)(:[0-9]+))"});
        urlValidator = new UrlValidator(regex, 0);
    }
View Full Code Here

      return false;
    } else {
      if (logger.isDebugEnabled()) {
        logger.debug("Required configuration found. Validating {}", stratosURL);
      }
      UrlValidator urlValidator = new UrlValidator(new String[] { "https" });
      if (!urlValidator.isValid(stratosURL)) {
        if (logger.isDebugEnabled()) {
          logger.debug("Stratos Controller URL {} is not valid", stratosURL);
        }
        System.out.format(
            "The \"%s\" variable in your environment is not a valid URL. You have provided \"%s\".%n"
View Full Code Here

    private final UrlValidator urlValidator;

    public WidgetValidator() {
        super();
        RegexValidator regex = new RegexValidator(new String[] {"http", "https","((localhost)(:[0-9]+))"});
        urlValidator = new UrlValidator(regex, 0);
    }
View Full Code Here

    * Testing the same method of URL validator used in validate method. Its was really hard to create Error object
    */
@Test
public void testValidation() throws Exception {
      RegexValidator regex = new RegexValidator(new String[]{"http","https","((localhost)(:[0-9]+))",".*\\.linux-server(:[0-9]+)"});
      UrlValidator validator = new UrlValidator(regex, 0);
      assertTrue("localhost URL should validate",
                validator.isValid("http://localhost:8080/demogadgets/CTSSResourcesMapView.xml"));
        assertTrue("127.0.0.1 should validate",
                validator.isValid("http://127.0.0.1:8080/demogadgets/CTSSResourcesMapView.xml"));
        assertTrue("my.linux-server should validate",
                validator.isValid("http://my.linux-server:8080/demogadgets/CTSSResourcesMapView.xml"));

        assertFalse("broke.my-test should not validate",
                validator.isValid("http://broke.my-test/test/index.html"));

        assertTrue("www.apache.org should still validate",
                validator.isValid("http://www.apache.org/test/index.html"));
    }
View Full Code Here

      return false;
    } else {
      if (logger.isDebugEnabled()) {
        logger.debug("Required configuration found. Validating {}", stratosURL);
      }
      UrlValidator urlValidator = new UrlValidator(new String[] { "https" },UrlValidator.ALLOW_LOCAL_URLS);
      if (!urlValidator.isValid(stratosURL)) {
        if (logger.isDebugEnabled()) {
          logger.debug("Stratos Controller URL {} is not valid", stratosURL);
        }
        System.out.format(
            "The \"%s\" variable in your environment is not a valid URL. You have provided \"%s\".%n"
View Full Code Here

    private final UrlValidator urlValidator;

    public WidgetValidator() {
        super();
        RegexValidator regex = new RegexValidator(new String[] {"http", "https","((localhost)(:[0-9]+))"});
        urlValidator = new UrlValidator(regex, 0);
    }
View Full Code Here

    * Testing the same method of URL validator used in validate method. Its was really hard to create Error object
    */
@Test
public void testValidation() throws Exception {
      RegexValidator regex = new RegexValidator(new String[]{"http","https","((localhost)(:[0-9]+))",".*\\.linux-server(:[0-9]+)"});
      UrlValidator validator = new UrlValidator(regex, 0);
      assertTrue("localhost URL should validate",
                validator.isValid("http://localhost:8080/demogadgets/CTSSResourcesMapView.xml"));
        assertTrue("127.0.0.1 should validate",
                validator.isValid("http://127.0.0.1:8080/demogadgets/CTSSResourcesMapView.xml"));
        assertTrue("my.linux-server should validate",
                validator.isValid("http://my.linux-server:8080/demogadgets/CTSSResourcesMapView.xml"));

        assertFalse("broke.my-test should not validate",
                validator.isValid("http://broke.my-test/test/index.html"));

        assertTrue("www.apache.org should still validate",
                validator.isValid("http://www.apache.org/test/index.html"));
    }
View Full Code Here

     */
    protected static URL getLicenseURL( MavenProject project, String url )
        throws IOException
    {
        URL licenseUrl = null;
        UrlValidator urlValidator = new UrlValidator( UrlValidator.ALLOW_ALL_SCHEMES );
        // UrlValidator does not accept file URLs because the file
        // URLs do not contain a valid authority (no hostname).
        // As a workaround accept license URLs that start with the
        // file scheme.
        if ( urlValidator.isValid( url ) || StringUtils.defaultString( url ).startsWith( "file://" ) )
        {
            try
            {
                licenseUrl = new URL( url );
            }
View Full Code Here

  private UrlValidator urlValidator;

  public URIExtractorImpl(Resolver resolver, boolean isForSAX) {
    this.resolver = resolver;
    this.isForSAX = isForSAX;
    this.urlValidator = new UrlValidator();
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.validator.routines.UrlValidator

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.