예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public String call() throws java.io.IOException
            public override string call()
            {
                HttpPost request = new HttpPost(outerInstance.APP_BASE_PATH + FETCH_AND_LOCK_PATH);

                request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
                StringEntity stringEntity = new StringEntity("{ \"workerId\": \"aWorkerId\", \"asyncResponseTimeout\": 1000 }");

                request.Entity = stringEntity;

                CloseableHttpResponse response = httpClient.execute(request, HttpClientContext.create());
                string responseBody            = null;

                try
                {
                    HttpEntity entity = response.Entity;
                    responseBody = EntityUtils.ToString(entity);
                    request.releaseConnection();
                }
                finally
                {
                    response.close();
                }

                return(responseBody);
            }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParameteriseUrisInNodeRepresentationWithoutHostHeaderUsingRequestUri() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParameteriseUrisInNodeRepresentationWithoutHostHeaderUsingRequestUri()
        {
            using (CloseableHttpClient httpclient = HttpClientBuilder.create().build())
            {
                HttpGet httpget = new HttpGet(_nodeUri);

                httpget.setHeader("Accept", "application/json");
                HttpResponse response = httpclient.execute(httpget);
                HttpEntity   entity   = response.Entity;

                string entityBody = IOUtils.ToString(entity.Content, StandardCharsets.UTF_8);

                assertThat(entityBody, containsString(_nodeUri.ToString()));
            }
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void evaluatePostRequest(org.apache.http.HttpEntity reqBody, String reqContentType, int expectedStatusCode, boolean assertResponseBody) throws java.io.IOException
        private void evaluatePostRequest(HttpEntity reqBody, string reqContentType, int expectedStatusCode, bool assertResponseBody)
        {
            HttpPost post = new HttpPost(BASE_URL + START_PROCESS_INSTANCE_BY_KEY_URL);

            post.Config = reqConfig;

            if (!string.ReferenceEquals(reqContentType, null))
            {
                post.setHeader(HttpHeaders.CONTENT_TYPE, reqContentType);
            }

            post.Entity = reqBody;

            CloseableHttpResponse response = client.execute(post);

            assertEquals(expectedStatusCode, response.StatusLine.StatusCode);

            if (assertResponseBody)
            {
                assertThat(EntityUtils.ToString(response.Entity, "UTF-8"), containsString(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID));
            }

            response.close();
        }