Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.koushikdutta.ion.mock;
 
 
Created by koush on 3/6/15.
public class MockLoader extends SimpleLoader {
    public static void install(Ion ionMockRequestHandler requestHandler) {
        MockLoader mockLoader = new MockLoader(requestHandler);
        for (Loader loaderion.configure().getLoaders()) {
            if (loader instanceof MockLoader)
                throw new RuntimeException("MockLoader already installed.");
        }
        ion.configure().addLoader(0, mockLoader);
    }
    private MockLoader(MockRequestHandler requestHandler) {
        this. = requestHandler;
    }
    @Override
    public <T> ResponseFuture<T> load(Ion ionAsyncHttpRequest requestType type) {
        T result = (T).request(request.getUri().toString());
        if (result != null) {
            MockResponseFuture<T> ret = new MockResponseFuture<T>(request);
            ret.setComplete(result);
            return ret;
        }
        return super.load(ionrequesttype);
    }
New to GrepCode? Check out our FAQ X