// Path: sdk/src/com/sharethis/loopy/sdk/util/ClassLoaderProvider.java
// public class ClassLoaderProvider {
//     public ClassLoader getClassLoader() {
//         return ClassLoaderProvider.class.getClassLoader();
//     }
// }
// 
// Path: sdk/src/com/sharethis/loopy/sdk/util/ResourceLocator.java
// public class ResourceLocator {
//     private ClassLoaderProvider classLoaderProvider = new ClassLoaderProvider();
// 
//     public InputStream locateInAssets(Context context, String name) throws IOException {
//         InputStream in = null;
// 
//         try {
//             if(Logger.isDebugEnabled()) {
//                 Logger.d("Looking for " +
//                         name +
//                         " in asset path...");
//             }
// 
//             in = context.getAssets().open(name);
// 
//             if(Logger.isDebugEnabled()) {
//                 Logger.d("Found " +
//                         name +
//                         " in asset path");
//             }
//         }
//         catch (IOException ignore) {
//             // Ignore this, just means no override.
//             if(Logger.isDebugEnabled()) {
//                 Logger.d("No file found in assets with name [" +
//                         name +
//                         "].");
//             }
//         }
// 
//         return in;
//     }
// 
//     public InputStream locateInClassPath(String name) throws IOException {
// 
//         InputStream in = null;
// 
//         if(classLoaderProvider != null) {
// 
//             if(Logger.isDebugEnabled()) {
//                 Logger.d("Looking for " +
//                         name +
//                         " in classpath...");
//             }
// 
//             in = classLoaderProvider.getClassLoader().getResourceAsStream(name);
// 
//             if(in != null) {
//                 if(Logger.isDebugEnabled()) {
//                     Logger.d("Found " +
//                             name +
//                             " in classpath");
//                 }
//             }
//         }
// 
//         return in;
//     }
// 
//     public InputStream locate(Context context, String name) throws IOException {
// 
//         InputStream in = locateInAssets(context, name);
// 
//         if(in == null) {
//             in = locateInClassPath(name);
//         }
// 
//         if(in == null) {
//             Logger.w("Could not locate [" +
//                     name +
//                     "] in any location");
//         }
// 
//         return in;
//     }
// 
//     public ClassLoaderProvider getClassLoaderProvider() {
//         return classLoaderProvider;
//     }
// 
//     public void setClassLoaderProvider(ClassLoaderProvider classLoaderProvider) {
//         this.classLoaderProvider = classLoaderProvider;
//     }
// }


import com.sharethis.loopy.sdk.util.ClassLoaderProvider;
import com.sharethis.loopy.sdk.util.ResourceLocator;
import org.mockito.Mockito;
import java.io.IOException;
import java.io.InputStream;
package com.sharethis.loopy.test;



/**
 * @author Jason Polites
 */
public class ResourceLocatorTest extends LoopyAndroidTestCase {

    public void testLocateInAssets() throws IOException {
        // We can't mock the AssetManager because it's final,
        // but this test project has assets so we'll just integration test
        ResourceLocator locator = new ResourceLocator();
        InputStream notNull = locator.locateInAssets(getLocalContext(), "loopy.properties");
        InputStream isNull = locator.locateInAssets(getLocalContext(), "does.not.exist");
        assertNotNull(notNull);
        assertNull(isNull);
    }

    public void testLocateInClassPath() throws IOException {
        String name = "foobar";
        ClassLoader classLoader = Mockito.mock(ClassLoader.class);
// Path: sdk/src/com/sharethis/loopy/sdk/util/ClassLoaderProvider.java
// public class ClassLoaderProvider {
//     public ClassLoader getClassLoader() {
//         return ClassLoaderProvider.class.getClassLoader();
//     }
// }
// 
// Path: sdk/src/com/sharethis/loopy/sdk/util/ResourceLocator.java
// public class ResourceLocator {
//     private ClassLoaderProvider classLoaderProvider = new ClassLoaderProvider();
// 
//     public InputStream locateInAssets(Context context, String name) throws IOException {
//         InputStream in = null;
// 
//         try {
//             if(Logger.isDebugEnabled()) {
//                 Logger.d("Looking for " +
//                         name +
//                         " in asset path...");
//             }
// 
//             in = context.getAssets().open(name);
// 
//             if(Logger.isDebugEnabled()) {
//                 Logger.d("Found " +
//                         name +
//                         " in asset path");
//             }
//         }
//         catch (IOException ignore) {
//             // Ignore this, just means no override.
//             if(Logger.isDebugEnabled()) {
//                 Logger.d("No file found in assets with name [" +
//                         name +
//                         "].");
//             }
//         }
// 
//         return in;
//     }
// 
//     public InputStream locateInClassPath(String name) throws IOException {
// 
//         InputStream in = null;
// 
//         if(classLoaderProvider != null) {
// 
//             if(Logger.isDebugEnabled()) {
//                 Logger.d("Looking for " +
//                         name +
//                         " in classpath...");
//             }
// 
//             in = classLoaderProvider.getClassLoader().getResourceAsStream(name);
// 
//             if(in != null) {
//                 if(Logger.isDebugEnabled()) {
//                     Logger.d("Found " +
//                             name +
//                             " in classpath");
//                 }
//             }
//         }
// 
//         return in;
//     }
// 
//     public InputStream locate(Context context, String name) throws IOException {
// 
//         InputStream in = locateInAssets(context, name);
// 
//         if(in == null) {
//             in = locateInClassPath(name);
//         }
// 
//         if(in == null) {
//             Logger.w("Could not locate [" +
//                     name +
//                     "] in any location");
//         }
// 
//         return in;
//     }
// 
//     public ClassLoaderProvider getClassLoaderProvider() {
//         return classLoaderProvider;
//     }
// 
//     public void setClassLoaderProvider(ClassLoaderProvider classLoaderProvider) {
//         this.classLoaderProvider = classLoaderProvider;
//     }
// }


// Path: test/src/com/sharethis/loopy/test/ResourceLocatorTest.java
import com.sharethis.loopy.sdk.util.ClassLoaderProvider;
import com.sharethis.loopy.sdk.util.ResourceLocator;
import org.mockito.Mockito;
import java.io.IOException;
import java.io.InputStream;

package com.sharethis.loopy.test;



/**
 * @author Jason Polites
 */
public class ResourceLocatorTest extends LoopyAndroidTestCase {

    public void testLocateInAssets() throws IOException {
        // We can't mock the AssetManager because it's final,
        // but this test project has assets so we'll just integration test
        ResourceLocator locator = new ResourceLocator();
        InputStream notNull = locator.locateInAssets(getLocalContext(), "loopy.properties");
        InputStream isNull = locator.locateInAssets(getLocalContext(), "does.not.exist");
        assertNotNull(notNull);
        assertNull(isNull);
    }

    public void testLocateInClassPath() throws IOException {
        String name = "foobar";
        ClassLoader classLoader = Mockito.mock(ClassLoader.class);
        ClassLoaderProvider classLoaderProvider = Mockito.mock(ClassLoaderProvider.class);