@Test
public void testProxyWithJSONResponse() throws Exception {

  ProxyService ps = new ProxyService();
  URLStreamProvider streamProviderMock = PowerMock.createNiceMock(URLStreamProvider.class);
  HttpURLConnection urlConnectionMock = createMock(HttpURLConnection.class);
  URI uriMock = PowerMock.createMock(URI.class);
  MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
  MultivaluedMap<String, String> headerParams = new MultivaluedMapImpl();
  Map<String, List<String>> headerParamsToForward = new HashMap<String, List<String>>();
  Response.ResponseBuilder responseBuilderMock = PowerMock.createMock(ResponseBuilderImpl.class);
  Response responseMock = createMock(ResponseImpl.class);
  headerParams.add("AmbariProxy-User-Remote","testuser");
  headerParams.add("Content-Type","testtype");
  List<String> userRemoteParams = new LinkedList<String>();
  userRemoteParams.add("testuser");
  headerParamsToForward.put("User-Remote", userRemoteParams);
  Map map = new Gson().fromJson(new InputStreamReader(new ByteArrayInputStream("{ \"test\":\"test\" }".getBytes())), Map.class);
  PowerMock.mockStatic(Response.class);
  expect(getHttpHeaders().getRequestHeaders()).andReturn(headerParams);
  expect(getHttpHeaders().getRequestHeader("AmbariProxy-User-Remote")).andReturn(userRemoteParams);
  expect(getUriInfo().getRequestUri()).andReturn(uriMock);
  expect(getUriInfo().getQueryParameters()).andReturn(queryParams);
  expect(uriMock.getQuery()).andReturn("url=testurl");
  expect(streamProviderMock.processURL("testurl", "GET", (InputStream) null, headerParamsToForward)).andReturn(urlConnectionMock);
  expect(urlConnectionMock.getResponseCode()).andReturn(200);
  expect(urlConnectionMock.getContentType()).andReturn("application/json");
  expect(urlConnectionMock.getInputStream()).andReturn(new ByteArrayInputStream("{ \"test\":\"test\" }".getBytes()));
  PowerMock.expectNew(URLStreamProvider.class, 20000, 15000, null, null, null).andReturn(streamProviderMock);
  expect(Response.status(200)).andReturn(responseBuilderMock);
  expect(responseBuilderMock.entity(map)).andReturn(responseBuilderMock);
  expect(responseBuilderMock.type("application/json")).andReturn(responseBuilderMock);
  expect(responseBuilderMock.build()).andReturn(responseMock);
  PowerMock.replay(streamProviderMock, URLStreamProvider.class, Response.class, responseBuilderMock, uriMock, URI.class);
  replay(getUriInfo(), urlConnectionMock, getHttpHeaders());
  Response resultForGetRequest = ps.processGetRequestForwarding(getHttpHeaders(),getUriInfo());
  assertSame(resultForGetRequest, responseMock);
}