EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.gae]

COVERAGE SUMMARY FOR SOURCE FILE [GaeHttpCommandExecutorService.java]

nameclass, %method, %block, %line, %
GaeHttpCommandExecutorService.java100% (1/1)20%  (1/5)50%  (18/36)56%  (5/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GaeHttpCommandExecutorService100% (1/1)20%  (1/5)50%  (18/36)56%  (5/9)
cleanup (HTTPRequest): void 0%   (0/1)0%   (0/1)0%   (0/1)
convert (HTTPResponse): HttpResponse 0%   (0/1)0%   (0/5)0%   (0/1)
convert (HttpRequest): HTTPRequest 0%   (0/1)0%   (0/5)0%   (0/1)
invoke (HTTPRequest): HttpResponse 0%   (0/1)0%   (0/7)0%   (0/1)
GaeHttpCommandExecutorService (URLFetchService, HttpUtils, ExecutorService, I... 100% (1/1)100% (18/18)100% (5/5)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.gae;
20 
21import java.io.IOException;
22import java.util.concurrent.ExecutorService;
23 
24import javax.inject.Inject;
25import javax.inject.Named;
26import javax.inject.Singleton;
27 
28import org.jclouds.Constants;
29import org.jclouds.concurrent.SingleThreaded;
30import org.jclouds.http.HttpCommandExecutorService;
31import org.jclouds.http.HttpRequest;
32import org.jclouds.http.HttpResponse;
33import org.jclouds.http.HttpUtils;
34import org.jclouds.http.IOExceptionRetryHandler;
35import org.jclouds.http.handlers.DelegatingErrorHandler;
36import org.jclouds.http.handlers.DelegatingRetryHandler;
37import org.jclouds.http.internal.BaseHttpCommandExecutorService;
38import org.jclouds.http.internal.HttpWire;
39 
40import com.google.appengine.api.urlfetch.HTTPRequest;
41import com.google.appengine.api.urlfetch.HTTPResponse;
42import com.google.appengine.api.urlfetch.URLFetchService;
43import com.google.common.annotations.VisibleForTesting;
44 
45/**
46 * Google App Engine version of {@link HttpCommandExecutorService}
47 * 
48 * @author Adrian Cole
49 */
50@SingleThreaded
51@Singleton
52public class GaeHttpCommandExecutorService extends BaseHttpCommandExecutorService<HTTPRequest> {
53   public static final String USER_AGENT = "jclouds/1.0 urlfetch/1.3.5";
54 
55   private final URLFetchService urlFetchService;
56   private final ConvertToGaeRequest convertToGaeRequest;
57   private final ConvertToJcloudsResponse convertToJcloudsResponse;
58 
59   @Inject
60   public GaeHttpCommandExecutorService(URLFetchService urlFetchService, HttpUtils utils,
61            @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioExecutor,
62            IOExceptionRetryHandler ioRetryHandler, DelegatingRetryHandler retryHandler,
63            DelegatingErrorHandler errorHandler, HttpWire wire, ConvertToGaeRequest convertToGaeRequest,
64            ConvertToJcloudsResponse convertToJcloudsResponse) {
65      super(utils, ioExecutor, retryHandler, ioRetryHandler, errorHandler, wire);
66      this.urlFetchService = urlFetchService;
67      this.convertToGaeRequest = convertToGaeRequest;
68      this.convertToJcloudsResponse = convertToJcloudsResponse;
69   }
70 
71   @VisibleForTesting
72   protected HttpResponse convert(HTTPResponse gaeResponse) {
73      return convertToJcloudsResponse.apply(gaeResponse);
74   }
75 
76   @VisibleForTesting
77   protected HTTPRequest convert(HttpRequest request) throws IOException {
78      return convertToGaeRequest.apply(request);
79   }
80 
81   /**
82    * nothing to clean up.
83    */
84   @Override
85   protected void cleanup(HTTPRequest nativeRequest) {
86   }
87 
88   @Override
89   protected HttpResponse invoke(HTTPRequest request) throws IOException {
90      return convert(urlFetchService.fetch(request));
91   }
92}

[all classes][org.jclouds.gae]
EMMA 2.0.5312 (C) Vladimir Roubtsov