### Question:
AmazonHttpClient { void setUserAgent(Request<?> request) { String userAgent = ClientConfiguration.DEFAULT_USER_AGENT; final AmazonWebServiceRequest awsreq = request.getOriginalRequest(); if (awsreq != null) { final RequestClientOptions opts = awsreq.getRequestClientOptions(); if (opts != null) { final String userAgentMarker = opts.getClientMarker(Marker.USER_AGENT); if (userAgentMarker != null) { userAgent = createUserAgentString(userAgent, userAgentMarker); } } } if (!ClientConfiguration.DEFAULT_USER_AGENT.equals(config.getUserAgent())) { userAgent = createUserAgentString(userAgent, config.getUserAgent()); } request.addHeader(HEADER_USER_AGENT, config.getUserAgentOverride() != null ? config.getUserAgentOverride() : userAgent); } AmazonHttpClient(ClientConfiguration config); @Deprecated  AmazonHttpClient(ClientConfiguration config,
            RequestMetricCollector requestMetricCollector);  AmazonHttpClient(ClientConfiguration config, HttpClient httpClient); @Deprecated  AmazonHttpClient(ClientConfiguration config, HttpClient httpClient,
            RequestMetricCollector requestMetricCollector); @Deprecated ResponseMetadata getResponseMetadataForRequest(AmazonWebServiceRequest request); Response<T> execute(Request<?> request,
            HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler,
            HttpResponseHandler<AmazonServiceException> errorResponseHandler,
            ExecutionContext executionContext); void shutdown(); RequestMetricCollector getRequestMetricCollector();  }### Answer:
@Test public void testSetUserAgentDefault() { ClientConfiguration config = new ClientConfiguration(); client = new AmazonHttpClient(config); final Request<?> request = new DefaultRequest<String>("ServiceName"); client.setUserAgent(request); String userAgent = request.getHeaders().get("User-Agent"); assertEquals("same user agent", ClientConfiguration.DEFAULT_USER_AGENT, userAgent); }
@Test public void testSetUserAgentCustom() { String versionInfoUserAgent = ClientConfiguration.DEFAULT_USER_AGENT; String customUserAgent = "custom_user_agent"; String requestUserAgent = "request_user_agent"; String targetUserAgent = versionInfoUserAgent + " " + requestUserAgent + " " + customUserAgent; AmazonWebServiceRequest originalRequest = new AmazonWebServiceRequest() { }; RequestClientOptions opts = originalRequest.getRequestClientOptions(); opts.appendUserAgent("request_user_agent"); ClientConfiguration config = new ClientConfiguration(); config.setUserAgent("custom_user_agent"); client = new AmazonHttpClient(config); final Request<?> request = new DefaultRequest<String>(originalRequest, "ServiceName"); client.setUserAgent(request); String userAgent = request.getHeaders().get("User-Agent"); assertEquals("same user agent", targetUserAgent, userAgent); }