All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.junit.fedora.server.validation.ValidationUtilityTest Maven / Gradle / Ivy

Go to download

The Fedora Client is a Java Library that allows API access to a Fedora Repository. The client is typically one part of a full Fedora installation.

The newest version!
/**
 * 
 */
package fedora.server.validation;

import junit.framework.JUnit4TestAdapter;

import org.junit.Test;

import fedora.server.errors.ValidationException;

/**
 * @author Edwin Shin
 * @since 2.2.3
 * @version $Id: ValidationUtilityTest.java 7438 2008-07-08 06:41:33Z pangloss $
 *
 */
public class ValidationUtilityTest {
    private String tmpDir = System.getProperty("java.io.tmpdir");
    
	@Test
	public void testValidUrls() throws Exception {	    
		String[] urls = {"http://localhost", 
						 "http://localhost:8080",
						 "uploaded:///tmp/foo.xml"};

		for (String url : urls) {
			ValidationUtility.validateURL(url, false);
		}
	}

	@Test(expected=ValidationException.class)
	public void testInvalidUrls() throws Exception {
		String[] urls = {"", "a", 
						 "temp:///etc/passwd", 
						 "copy:///etc/passwd",
						 "temp://" + tmpDir + "/../etc/passwd",
						 "temp://" + tmpDir + "/../../etc/passwd",
                         "file:///etc/passwd",
                         "file:/etc/passwd",
                         "/etc/passwd",
                         "../../etc/passwd"};

		for (String url : urls) {
			ValidationUtility.validateURL(url, false);
		}
	}
	
	public static junit.framework.Test suite() {
        return new JUnit4TestAdapter(ValidationUtilityTest.class);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy