Search in sources :

Example 11 with Executor

use of org.apache.http.client.fluent.Executor in project substitution-schedule-parser by vertretungsplanme.

the class LoginHandlerTest method testPostAuthFail.

@Test
public void testPostAuthFail() throws JSONException, IOException, CredentialInvalidException {
    stubPostAuth();
    Executor exec = newExecutor();
    LoginHandler handler = new LoginHandler(dataPost, wrong, null);
    handler.handleLogin(exec, null);
    // loading page should fail
    String content = exec.execute(Request.Get(baseurl + "/index.html")).returnContent().asString();
    assertEquals("please login", content);
}
Also used : Executor(org.apache.http.client.fluent.Executor) Test(org.junit.Test)

Example 12 with Executor

use of org.apache.http.client.fluent.Executor in project substitution-schedule-parser by vertretungsplanme.

the class LoginHandlerTest method testPostAuthFailCheckText.

@Test(expected = CredentialInvalidException.class)
public void testPostAuthFailCheckText() throws JSONException, IOException, CredentialInvalidException {
    stubPostAuth();
    Executor exec = newExecutor();
    LoginHandler handler = new LoginHandler(dataPostCheckText, wrong, null);
    // should throw CredentialInvalidException
    handler.handleLogin(exec, null);
}
Also used : Executor(org.apache.http.client.fluent.Executor) Test(org.junit.Test)

Example 13 with Executor

use of org.apache.http.client.fluent.Executor in project gogs-webhook-plugin by jenkinsci.

the class GogsConfigHandler method removeHook.

/**
 * Removes a web hook from a GOGS project
 *
 * @param projectName Name of the Gogs project to remove the hook from
 * @param hookId      The ID of the hook to remove
 * @throws IOException something went wrong
 */
void removeHook(String projectName, int hookId) throws IOException {
    String gogsHooksConfigUrl = getGogsServer_apiUrl() + "repos/" + this.gogsServer_user + "/" + projectName + "/hooks/" + hookId;
    Executor executor = getExecutor();
    int result = executor.execute(Request.Delete(gogsHooksConfigUrl)).returnResponse().getStatusLine().getStatusCode();
    if (result != 204) {
        throw new IOException("Delete hook did not return the expected value (returned " + result + ")");
    }
}
Also used : Executor(org.apache.http.client.fluent.Executor) IOException(java.io.IOException)

Example 14 with Executor

use of org.apache.http.client.fluent.Executor in project gogs-webhook-plugin by jenkinsci.

the class GogsConfigHandler method createEmptyRepo.

/**
 * Creates an empty repository (under the configured user).
 * It is created as a public repository, un-initialized.
 *
 * @param projectName the project name (repository) to create
 * @throws IOException Something went wrong (example: the repo already exists)
 */
void createEmptyRepo(String projectName) throws IOException {
    Executor executor = getExecutor();
    String gogsHooksConfigUrl = getGogsServer_apiUrl() + "user/repos";
    int result = executor.execute(Request.Post(gogsHooksConfigUrl).bodyForm(Form.form().add("name", projectName).add("description", "API generated repository").add("private", "true").add("auto_init", "false").build())).returnResponse().getStatusLine().getStatusCode();
    if (result != 201) {
        throw new IOException("Repository creation call did not return the expected value (returned " + result + ")");
    }
}
Also used : Executor(org.apache.http.client.fluent.Executor) IOException(java.io.IOException)

Example 15 with Executor

use of org.apache.http.client.fluent.Executor in project redisson by redisson.

the class RedissonSessionManagerTest method testExpiration.

@Test
public void testExpiration() throws Exception {
    TomcatServer server1 = new TomcatServer("myapp", 8080, "src/test/");
    server1.start();
    Executor executor = Executor.newInstance();
    BasicCookieStore cookieStore = new BasicCookieStore();
    executor.use(cookieStore);
    write(8080, executor, "test", "1234");
    TomcatServer server2 = new TomcatServer("myapp", 8081, "src/test/");
    server2.start();
    Thread.sleep(30000);
    read(8081, executor, "test", "1234");
    Thread.sleep(40000);
    executor.use(cookieStore);
    read(8080, executor, "test", "1234");
    Executor.closeIdleConnections();
    server1.stop();
    server2.stop();
}
Also used : BasicCookieStore(org.apache.http.impl.client.BasicCookieStore) Executor(org.apache.http.client.fluent.Executor) Test(org.junit.Test)

Aggregations

Executor (org.apache.http.client.fluent.Executor)46 Test (org.junit.Test)26 Request (org.apache.http.client.fluent.Request)12 BasicCookieStore (org.apache.http.impl.client.BasicCookieStore)11 HttpResponse (org.apache.http.HttpResponse)6 Response (org.apache.http.client.fluent.Response)6 URI (java.net.URI)5 Cookie (org.apache.http.cookie.Cookie)5 Test (org.junit.jupiter.api.Test)5 JsonObject (com.google.gson.JsonObject)4 InputStream (java.io.InputStream)4 DistributionTransportSecret (org.apache.sling.distribution.transport.DistributionTransportSecret)4 StreamsConnection (com.ibm.streamsx.rest.StreamsConnection)3 HashMap (java.util.HashMap)3 DistributionRequest (org.apache.sling.distribution.DistributionRequest)3 JsonParser (com.google.gson.JsonParser)2 Instance (com.ibm.streamsx.rest.Instance)2 ICP4DAuthenticator (com.ibm.streamsx.rest.internal.ICP4DAuthenticator)2 StandaloneAuthenticator (com.ibm.streamsx.rest.internal.StandaloneAuthenticator)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2