Search in sources :

Example 1 with URLPropertyHandler

use of org.olat.user.propertyhandlers.URLPropertyHandler in project OpenOLAT by OpenOLAT.

the class UserPropertiesTest method testURLPropertyHandlerValidation.

@Test
public void testURLPropertyHandlerValidation() {
    URLPropertyHandler urlHandler = new URLPropertyHandler();
    ValidationError error = new ValidationError();
    // test for valid URL's
    assertTrue(urlHandler.isValidValue(null, "http://www.openolat.org", error, null));
    assertTrue(urlHandler.isValidValue(null, "https://www.openolat.org", error, null));
    assertTrue(urlHandler.isValidValue(null, "http://test.ch", error, null));
    assertTrue(urlHandler.isValidValue(null, "http://localhost", error, null));
    // test for invalid URL's
    assertFalse(urlHandler.isValidValue(null, "http:www.openolat.org", error, null));
    assertFalse(urlHandler.isValidValue(null, "www.openolat.org", error, null));
}
Also used : URLPropertyHandler(org.olat.user.propertyhandlers.URLPropertyHandler) ValidationError(org.olat.core.gui.components.form.ValidationError) Test(org.junit.Test)

Example 2 with URLPropertyHandler

use of org.olat.user.propertyhandlers.URLPropertyHandler in project openolat by klemens.

the class UserPropertiesTest method testURLPropertyHandlerValidation.

@Test
public void testURLPropertyHandlerValidation() {
    URLPropertyHandler urlHandler = new URLPropertyHandler();
    ValidationError error = new ValidationError();
    // test for valid URL's
    assertTrue(urlHandler.isValidValue(null, "http://www.openolat.org", error, null));
    assertTrue(urlHandler.isValidValue(null, "https://www.openolat.org", error, null));
    assertTrue(urlHandler.isValidValue(null, "http://test.ch", error, null));
    assertTrue(urlHandler.isValidValue(null, "http://localhost", error, null));
    // test for invalid URL's
    assertFalse(urlHandler.isValidValue(null, "http:www.openolat.org", error, null));
    assertFalse(urlHandler.isValidValue(null, "www.openolat.org", error, null));
}
Also used : URLPropertyHandler(org.olat.user.propertyhandlers.URLPropertyHandler) ValidationError(org.olat.core.gui.components.form.ValidationError) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ValidationError (org.olat.core.gui.components.form.ValidationError)2 URLPropertyHandler (org.olat.user.propertyhandlers.URLPropertyHandler)2