private RequestQueue newVolleyRequestQueueForTest(final Context context) { File cacheDir = new File(context.getCacheDir(), "cache/volley"); Network network = new BasicNetwork(new HurlStack()); ResponseDelivery responseDelivery = new ExecutorDelivery(Executors.newSingleThreadExecutor()); RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network, 4, responseDelivery); queue.start(); return queue; }
@Test public void publicMethods() throws Exception { // Catch-all test to find API-breaking changes. assertNotNull(RequestQueue.class.getConstructor(Cache.class, Network.class, int.class, ResponseDelivery.class)); assertNotNull(RequestQueue.class.getConstructor(Cache.class, Network.class, int.class)); assertNotNull(RequestQueue.class.getConstructor(Cache.class, Network.class)); assertNotNull(RequestQueue.class.getMethod("start")); assertNotNull(RequestQueue.class.getMethod("stop")); assertNotNull(RequestQueue.class.getMethod("getSequenceNumber")); assertNotNull(RequestQueue.class.getMethod("getCache")); assertNotNull(RequestQueue.class.getMethod("cancelAll", RequestQueue.RequestFilter.class)); assertNotNull(RequestQueue.class.getMethod("cancelAll", Object.class)); assertNotNull(RequestQueue.class.getMethod("add", Request.class)); assertNotNull(RequestQueue.class.getDeclaredMethod("finish", Request.class)); }
public static void initializeInstance(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) { INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout); setUserAgent("Swagger-Codegen/1.0.0/android"); // Setup authentications (key: authentication name, value: authentication). INSTANCE.authentications = new HashMap<String, Authentication>(); // Prevent the authentications from being modified. INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications); }
public static void initializeInstance(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) { INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout); setUserAgent("Swagger-Codegen/1.0.0/android"); // Setup authentications (key: authentication name, value: authentication). INSTANCE.authentications = new HashMap<String, Authentication>(); INSTANCE.authentications.put("jenkins_auth", new HttpBasicAuth()); // Prevent the authentications from being modified. INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications); }
public static void initializeInstance(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) { INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout); setUserAgent("Swagger-Codegen/1.0.0/android"); // Setup authentications (key: authentication name, value: authentication). INSTANCE.authentications = new HashMap<String, Authentication>(); INSTANCE.authentications.put("Bearer", new ApiKeyAuth("header", "Authorization")); // Prevent the authentications from being modified. INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications); }
public WaspTest() throws Exception { File cacheDir = new File(context.getCacheDir(), "volley"); Network network = new BasicNetwork(new OkHttpStack(new OkHttpClient())); ResponseDelivery delivery = new ExecutorDelivery(executor); requestQueue = new RequestQueue(new DiskBasedCache(cacheDir), network, 4, delivery); requestQueue.start(); server.start(); }
/** * Creates the worker pool. Processing will not begin until {@link #start()} is called. * * @param cache A Cache to use for persisting responses to disk * @param network A Network interface for performing HTTP requests * @param threadPoolSize Number of network dispatcher threads to create * @param delivery A ResponseDelivery interface for posting responses and errors */ public SmartRequestQueue(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery) { super(cache, network, threadPoolSize, delivery); mCache = cache; mNetwork = network; mDispatchers = new NetworkDispatcher[threadPoolSize]; mDelivery = delivery; }
private void initConnectionRequest(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery) { mRequestQueue = new RequestQueue(cache, network, threadPoolSize, delivery); mRequestQueue.start(); }
public static RestClientManager initialize(Context context, ResponseDelivery responseDelivery) { sInstance = new RestClientManager(context, responseDelivery); return sInstance; }
public ContentResolverRequestQueue(@NonNull Cache cache, @NonNull ContentResolverNetwork network, int threadPoolSize, ResponseDelivery delivery) { super(cache, network, threadPoolSize, delivery); }
public static RequestQueue newRequestQueue(Context context, ResponseDelivery responseDelivery) { File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR); Network network = new BasicNetwork(new HurlStack()); RequestQueue requestQueue = new RequestQueue(new DiskBasedCache(cacheDir), network, DEFAULT_NETWORK_THREAD_POOL_SIZE, responseDelivery); requestQueue.start(); return requestQueue; }
/** * Method used to create a queue that uses a custom response delivery. * * @param context the context the manager will use to create de queue (Use application context in the application initialization) * @param responseDelivery this can be used to execute calls in a worker or a main thread. Be careful with it's usage since it can generate a blocking thread and this can lead to a poor performance of your app. * Consider using a SingleThreadExecutor to perform Async tests in your unit testing clases. * <p/> * Example: new ExecutorDelivery(Executors.newSingleThreadExecutor()) */ private RestClientManager(Context context, ResponseDelivery responseDelivery) { mContext = context; mRequestQueue = VolleyHelper.newRequestQueue(mContext, responseDelivery); }