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);
}
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);
}
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 + ")");
}
}
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 + ")");
}
}
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();
}
Aggregations