}
@Test
public void testProxyPostRequest() 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> 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);
InputStream is = new ByteArrayInputStream("test".getBytes());
PowerMock.mockStatic(Response.class);
expect(getHttpHeaders().getRequestHeaders()).andReturn(headerParams);
expect(getHttpHeaders().getRequestHeader("AmbariProxy-User-Remote")).andReturn(userRemoteParams);
expect(getUriInfo().getRequestUri()).andReturn(uriMock);
expect(uriMock.getQuery()).andReturn("url=testurl");
expect(getHttpHeaders().getMediaType()).andReturn(APPLICATION_FORM_URLENCODED_TYPE);
expect(streamProviderMock.processURL("testurl", "POST", is, headerParamsToForward)).andReturn(urlConnectionMock);
expect(urlConnectionMock.getResponseCode()).andReturn(200);
expect(urlConnectionMock.getContentType()).andReturn("text/plain");
expect(urlConnectionMock.getInputStream()).andReturn(is);
PowerMock.expectNew(URLStreamProvider.class, 20000, 15000, null, null, null).andReturn(streamProviderMock);
expect(Response.status(200)).andReturn(responseBuilderMock);