Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUpHttpClientAndRuntimeData()
        public virtual void setUpHttpClientAndRuntimeData()
        {
            client    = HttpClients.createDefault();
            reqConfig = RequestConfig.custom().setConnectTimeout(3 * 60 * 1000).setSocketTimeout(10 * 60 * 1000).build();

            ProcessDefinition mockDefinition = MockProvider.createMockDefinition();

            runtimeServiceMock = mock(typeof(RuntimeService));
            when(processEngine.RuntimeService).thenReturn(runtimeServiceMock);

            mockInstantiationBuilder = mock(typeof(ProcessInstantiationBuilder));
            when(mockInstantiationBuilder.setVariables(any(typeof(System.Collections.IDictionary)))).thenReturn(mockInstantiationBuilder);
            when(mockInstantiationBuilder.businessKey(anyString())).thenReturn(mockInstantiationBuilder);
            when(mockInstantiationBuilder.caseInstanceId(anyString())).thenReturn(mockInstantiationBuilder);
            when(runtimeServiceMock.createProcessInstanceById(anyString())).thenReturn(mockInstantiationBuilder);

            ProcessInstanceWithVariables resultInstanceWithVariables = MockProvider.createMockInstanceWithVariables();

            when(mockInstantiationBuilder.executeWithVariablesInReturn(anyBoolean(), anyBoolean())).thenReturn(resultInstanceWithVariables);

            ProcessDefinitionQuery processDefinitionQueryMock = mock(typeof(ProcessDefinitionQuery));

            when(processDefinitionQueryMock.processDefinitionKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY)).thenReturn(processDefinitionQueryMock);
            when(processDefinitionQueryMock.withoutTenantId()).thenReturn(processDefinitionQueryMock);
            when(processDefinitionQueryMock.latestVersion()).thenReturn(processDefinitionQueryMock);
            when(processDefinitionQueryMock.singleResult()).thenReturn(mockDefinition);

            RepositoryService repositoryServiceMock = mock(typeof(RepositoryService));

            when(processEngine.RepositoryService).thenReturn(repositoryServiceMock);
            when(repositoryServiceMock.createProcessDefinitionQuery()).thenReturn(processDefinitionQueryMock);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPerform500ConcurrentRequests() throws InterruptedException, java.util.concurrent.ExecutionException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void shouldPerform500ConcurrentRequests()
        {
            PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.http.impl.client.CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.custom().setConnectionManager(cm).build();
            CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build();

            Callable <string> performRequest = new CallableAnonymousInnerClass(this, httpClient);

            int             requestsCount = 500;
            ExecutorService service       = Executors.newFixedThreadPool(requestsCount);

            IList <Callable <string> > requests = new List <Callable <string> >();

            for (int i = 0; i < requestsCount; i++)
            {
                requests.Add(performRequest);
            }

            IList <Future <string> > futures = service.invokeAll(requests);

            service.shutdown();
            service.awaitTermination(1, TimeUnit.HOURS);

            foreach (Future <string> future in futures)
            {
                assertEquals(future.get(), "[]");
            }
        }
Ejemplo n.º 3
0
 /// <param name="client"> The http client instance used. </param>
 /// <param name="context"> The http context instance used. </param>
 /// <param name="ownedClient"> True if the client should be closed when this instance is closed. </param>
 public HttpInterface(CloseableHttpClient client, HttpClientContext context, bool ownedClient)
 {
     this.client      = client;
     this.context     = context;
     this.ownedClient = ownedClient;
     this.available   = true;
 }
Ejemplo n.º 4
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()));
            }
        }
Ejemplo n.º 5
0
 public CallableAnonymousInnerClass(RestJaxRs2IT outerInstance, CloseableHttpClient httpClient)
 {
     this.outerInstance = outerInstance;
     this.httpClient    = httpClient;
 }