// Path: src/main/java/org/apache/commons/mail/DataSourceResolver.java
// public interface DataSourceResolver
// {
//     /**
//      * Resolves the given resource location to a {@code DataSource}.
//      *
//      * @param resourceLocation the location of the resource
//      * @return the {@code DataSource}
//      * @throws IOException the resource was not found
//      */
//     DataSource resolve(final String resourceLocation) throws IOException;
// 
//     /**
//      * Resolves the given resource location to a {@code DataSource}.
//      *
//      * @param resourceLocation the location of the resource
//      * @param isLenient shall we ignore resources not found or complain with an exception?
//      * @return the data source containing the resource or null if the resource was not found in lenient mode
//      * @throws IOException resolving the resource failed
//      */
//     DataSource resolve(final String resourceLocation, final boolean isLenient)
//         throws IOException;
// }


import static org.junit.Assert.*;
import org.apache.commons.mail.DataSourceResolver;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.net.URL;
        final DataSourceResolver dataSourceResolver = new DataSourceUrlResolver(new URL("http://www.apache.org"), true);
        assertTrue(toByteArray(dataSourceResolver.resolve("http://www.apache.org/images/feather-small.gif")).length > 1);
        assertTrue(toByteArray(dataSourceResolver.resolve("images/feather-small.gif")).length > 1);
        assertTrue(toByteArray(dataSourceResolver.resolve("./images/feather-small.gif")).length > 1);
        assertTrue(toByteArray(dataSourceResolver.resolve("/images/feather-small.gif")).length > 1);
    }

    /**
     * Tests resolving resources over HTTP.
     *
     * @throws Exception the test failed
     */
    @Test
    public void testResolvingHttpLenientHost() throws Exception
    {
        final DataSourceResolver dataSourceResolver = new DataSourceUrlResolver(new URL("http://does.not.exist"), true);
        assertNull(toByteArray(dataSourceResolver.resolve("/images/does-not-exist.gif")));
    }

    /**
     * Tests resolving resources over HTTP.
     *
     * @throws Exception the test failed
     */
    @Test(expected = IOException.class)
    public void testResolvingHttpNonLenient() throws Exception
    {
        final DataSourceResolver dataSourceResolver = new DataSourceUrlResolver(new URL("http://does.not.exist"), false);
        assertNotNull(dataSourceResolver.resolve("images/asf_logo_wide.gif"));

// Path: src/main/java/org/apache/commons/mail/DataSourceResolver.java
// public interface DataSourceResolver
// {
//     /**
//      * Resolves the given resource location to a {@code DataSource}.
//      *
//      * @param resourceLocation the location of the resource
//      * @return the {@code DataSource}
//      * @throws IOException the resource was not found
//      */
//     DataSource resolve(final String resourceLocation) throws IOException;
// 
//     /**
//      * Resolves the given resource location to a {@code DataSource}.
//      *
//      * @param resourceLocation the location of the resource
//      * @param isLenient shall we ignore resources not found or complain with an exception?
//      * @return the data source containing the resource or null if the resource was not found in lenient mode
//      * @throws IOException resolving the resource failed
//      */
//     DataSource resolve(final String resourceLocation, final boolean isLenient)
//         throws IOException;
// }


// Path: src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java
import static org.junit.Assert.*;
import org.apache.commons.mail.DataSourceResolver;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.net.URL;

        final DataSourceResolver dataSourceResolver = new DataSourceUrlResolver(new URL("http://www.apache.org"), true);
        assertTrue(toByteArray(dataSourceResolver.resolve("http://www.apache.org/images/feather-small.gif")).length > 1);
        assertTrue(toByteArray(dataSourceResolver.resolve("images/feather-small.gif")).length > 1);
        assertTrue(toByteArray(dataSourceResolver.resolve("./images/feather-small.gif")).length > 1);
        assertTrue(toByteArray(dataSourceResolver.resolve("/images/feather-small.gif")).length > 1);
    }

    /**
     * Tests resolving resources over HTTP.
     *
     * @throws Exception the test failed
     */
    @Test
    public void testResolvingHttpLenientHost() throws Exception
    {
        final DataSourceResolver dataSourceResolver = new DataSourceUrlResolver(new URL("http://does.not.exist"), true);
        assertNull(toByteArray(dataSourceResolver.resolve("/images/does-not-exist.gif")));
    }

    /**
     * Tests resolving resources over HTTP.
     *
     * @throws Exception the test failed
     */
    @Test(expected = IOException.class)
    public void testResolvingHttpNonLenient() throws Exception
    {
        final DataSourceResolver dataSourceResolver = new DataSourceUrlResolver(new URL("http://does.not.exist"), false);
        assertNotNull(dataSourceResolver.resolve("images/asf_logo_wide.gif"));

        dataSourceResolver.resolve("images/does-not-exist.gif");