### Question:
TargetResponse { public int read(NHttpClientConnection conn, ContentDecoder decoder) throws IOException { int bytes=0; if(pipe != null){ bytes = pipe.produce(decoder); } if (decoder.isCompleted()) { conn.getContext().setAttribute(PassThroughConstants.RES_FROM_BACKEND_READ_END_TIME,System.currentTimeMillis()); conn.getContext().setAttribute(PassThroughConstants.RES_ARRIVAL_TIME,System.currentTimeMillis()); TargetContext.updateState(conn, ProtocolState.RESPONSE_DONE); targetConfiguration.getMetrics().notifyReceivedMessageSize( conn.getMetrics().getReceivedBytesCount()); if (!this.connStrategy.keepAlive(response, conn.getContext()) || forceShutdownConnectionOnComplete) { TargetContext.updateState(conn, ProtocolState.CLOSED); targetConfiguration.getConnections().shutdownConnection(conn); } else { if (conn instanceof LoggingNHttpClientConnection) { ((LoggingNHttpClientConnection) conn).setReleaseConn(true); } } } return bytes; } TargetResponse(TargetConfiguration targetConfiguration,
                          HttpResponse response,
                          NHttpClientConnection conn,
                          boolean expectResponseBody,
                          boolean forceShutdownConnectionOnComplete); void start(NHttpClientConnection conn); int read(NHttpClientConnection conn, ContentDecoder decoder); String getHeader(String name); Map<String, String> getHeaders(); Map getExcessHeaders(); void addExcessHeader(Header h); Pipe getPipe(); int getStatus(); String getStatusLine(); boolean isExpectResponseBody(); NHttpClientConnection getConnection(); ProtocolVersion getVersion();  }### Answer:
@Test public void testRead() throws Exception { ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration()); WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id"); PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme"); TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool, metrics, null); targetConfiguration.build(); HttpResponse response = PowerMockito.mock(HttpResponse.class, Mockito.RETURNS_DEEP_STUBS); NHttpClientConnection conn = PowerMockito.mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS); ContentDecoder decoder = PowerMockito.mock(ContentDecoder.class); TargetConnections connections = PowerMockito.mock(TargetConnections.class); targetConfiguration.setConnections(connections); PowerMockito.mockStatic(TargetContext.class); TargetContext cntxt = new TargetContext(targetConfiguration); PowerMockito.when(TargetContext.get(any(NHttpClientConnection.class))).thenReturn(cntxt); PowerMockito.when(decoder.read(any(ByteBuffer.class))).thenReturn(12); PowerMockito.when(decoder.isCompleted()).thenReturn(true); TargetResponse targetResponse = new TargetResponse(targetConfiguration, response, conn, true, false); targetResponse.start(conn); int result = targetResponse.read(conn, decoder); Assert.assertEquals(12, result); }