use of org.apache.http.NameValuePair in project cas by apereo.
the class WSFederationAuthenticationServiceSelectionStrategy method getRealmAsParameter.
private static Optional<NameValuePair> getRealmAsParameter(final Service service) {
try {
final URIBuilder builder = new URIBuilder(service.getId());
final Optional param = builder.getQueryParams().stream().filter(p -> p.getName().equals(WSFederationConstants.WTREALM)).findFirst();
return param;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return Optional.empty();
}
use of org.apache.http.NameValuePair in project cas by apereo.
the class WSFederationAuthenticationServiceSelectionStrategy method getReplyAsParameter.
private static Optional<NameValuePair> getReplyAsParameter(final Service service) {
try {
final URIBuilder builder = new URIBuilder(service.getId());
final Optional param = builder.getQueryParams().stream().filter(p -> p.getName().equals(WSFederationConstants.WREPLY)).findFirst();
return param;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return Optional.empty();
}
use of org.apache.http.NameValuePair in project felix by apache.
the class ITScriptConsolePlugin method execute2.
private void execute2(String code) throws Exception {
RequestBuilder rb = new RequestBuilder(ServerConfiguration.getServerUrl());
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("lang", "groovy"));
params.add(new BasicNameValuePair("code", code));
final HttpEntity entity = new UrlEncodedFormEntity(params);
// Add Sling POST options
executor.execute(rb.buildPostRequest("/system/console/sc").withEntity(entity).withCredentials("admin", "admin")).assertStatus(200);
}
use of org.apache.http.NameValuePair in project sling by apache.
the class FormTest method testForm.
@Test
public void testForm() throws ClientException, URISyntaxException {
MicrodataHtmlClient client = new MicrodataHtmlClient(httpServer.getURI().toString());
Document doc = client.enter(GET_URL);
Items items = doc.items();
Assert.assertThat(items.length(), equalTo(1));
Items form = doc.form("test");
Assert.assertThat(form.length(), equalTo(2));
List<NameValuePair> data = new ArrayList<NameValuePair>();
data.add(new BasicNameValuePair("f1", "val1"));
// url encode enctype
Document doc2 = form.at(0).submit(data);
Assert.assertThat(doc2.items().length(), equalTo(1));
// the multipart enctype
Document doc3 = form.at(1).submit(data);
Assert.assertThat(doc3.items().length(), equalTo(1));
}
use of org.apache.http.NameValuePair in project sling by apache.
the class RemoteTestHttpClient method runTests.
public RequestExecutor runTests(String testClassesSelector, String testMethodSelector, String extension, Map<String, String> requestOptions) throws ClientProtocolException, IOException {
final RequestBuilder builder = new RequestBuilder(junitServletUrl);
// Optionally let the client to consume the response entity
final RequestExecutor executor = new RequestExecutor(new DefaultHttpClient()) {
@Override
protected void consumeEntity() throws ParseException, IOException {
if (consumeContent) {
super.consumeEntity();
}
}
};
// Build path for POST request to execute the tests
// Test classes selector
subpath = new StringBuilder();
if (!junitServletUrl.endsWith(SLASH)) {
subpath.append(SLASH);
}
subpath.append(testClassesSelector);
// Test method selector
if (testMethodSelector != null && testMethodSelector.length() > 0) {
subpath.append("/");
subpath.append(testMethodSelector);
}
// Extension
if (!extension.startsWith(DOT)) {
subpath.append(DOT);
}
subpath.append(extension);
// Request options if any
final List<NameValuePair> opt = new ArrayList<NameValuePair>();
if (requestOptions != null) {
for (Map.Entry<String, String> e : requestOptions.entrySet()) {
opt.add(new BasicNameValuePair(e.getKey(), e.getValue()));
}
}
log.info("Executing test remotely, path={} JUnit servlet URL={}", subpath, junitServletUrl);
final Request r = builder.buildPostRequest(subpath.toString()).withCredentials(username, password).withCustomizer(requestCustomizer).withEntity(new UrlEncodedFormEntity(opt));
executor.execute(r).assertStatus(200);
return executor;
}
Aggregations