use of org.apache.commons.httpclient.HttpMethod in project cloudstack by apache.
the class BigSwitchApiTest method setUp.
@Before
public void setUp() {
HttpClientParams hmp = mock(HttpClientParams.class);
when(_client.getParams()).thenReturn(hmp);
_api = new BigSwitchBcfApi() {
@Override
protected HttpClient createHttpClient() {
return _client;
}
@Override
protected HttpMethod createMethod(String type, String uri, int port) {
return _method;
}
};
_api.setControllerAddress("10.10.0.10");
_api.setControllerUsername("myname");
_api.setControllerPassword("mypassword");
}
use of org.apache.commons.httpclient.HttpMethod in project sling by apache.
the class FiltersTest method testCounters.
public void testCounters() throws IOException {
HttpMethod get = assertHttpStatus(HTTP_BASE_URL + "/index.html", HttpServletResponse.SC_OK);
final String[] headers = { "FILTER_COUNTER_SLING", "FILTER_COUNTER_NOPROP" };
for (String header : headers) {
assertNotNull("Expecting header '" + header + "'", get.getResponseHeader(header));
assertEquals("Expecting value 1 for header '" + header + "'", "1", get.getResponseHeader(header).getValue());
}
assertNull(get.getResponseHeader("FILTER_COUNTER_SLING_WITH_PATTERN"));
}
use of org.apache.commons.httpclient.HttpMethod in project intellij-plugins by JetBrains.
the class CfmlUnitRemoteTestsRunner method executeScript.
public static void executeScript(final CfmlUnitRunnerParameters params, final ProcessHandler processHandler, /*final String webPath,
final String componentFilePath,
final String methodName,
final ProcessHandler processHandler*/
final Project project) throws ExecutionException {
final Ref<ExecutionException> ref = new Ref<>();
ApplicationManager.getApplication().assertIsDispatchThread();
ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
final VirtualFile componentFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(params.getPath());
if (componentFile == null) {
throw new ExecutionException("File " + params.getPath() + " not found");
}
// creating script files
final VirtualFile directory = componentFile.getParent();
//generateUniqueName("mxunit-launcher", project);
final String launcherFileName = "mxunit-launcher.cfc";
LOG.debug("Copying script file" + launcherFileName + " to component folder: " + directory);
createFile(project, directory, launcherFileName, getLauncherText("/scripts/mxunit-launcher.cfc"));
//generateUniqueName("mxunit-result-capture", project);
final String resultsFileName = "mxunit-result-capture.cfc";
LOG.debug("Copying results capture file " + resultsFileName + " to component folder: " + directory);
createFile(project, directory, resultsFileName, getLauncherText("/scripts/mxunit-result-capture.cfc"));
// retrieving data through URL
String webPath = params.getWebPath();
if (webPath.endsWith("/") || webPath.endsWith("\\")) {
webPath = webPath.substring(0, webPath.length() - 1);
}
String agentPath = webPath.substring(0, webPath.lastIndexOf('/')) + "/" + launcherFileName;
LOG.debug("Retrieving data from coldfusion server by " + agentPath + " URL");
BufferedReader reader = null;
String agentUrl;
if (params.getScope() == CfmlUnitRunnerParameters.Scope.Directory) {
agentUrl = agentPath + "?method=executeDirectory&directoryName=" + componentFile.getName();
} else {
agentUrl = agentPath + "?method=executeTestCase&componentName=" + componentFile.getNameWithoutExtension();
if (params.getScope() == CfmlUnitRunnerParameters.Scope.Method) {
agentUrl += "&methodName=" + params.getMethod();
}
}
HttpMethod method = null;
try {
LOG.debug("Retrieving test results from: " + agentUrl);
/*
final FileObject httpFile = getManager().resolveFile(agentUrl);
reader = new BufferedReader(new InputStreamReader(httpFile.getContent().getInputStream()));
*/
HttpClient client = new HttpClient();
method = new GetMethod(agentUrl);
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
LOG.debug("Http request failed: " + method.getStatusLine());
processHandler.notifyTextAvailable("Http request failed: " + method.getStatusLine(), ProcessOutputTypes.SYSTEM);
}
final InputStream responseStream = method.getResponseBodyAsStream();
reader = new BufferedReader(new InputStreamReader(responseStream));
String line;
while (!processHandler.isProcessTerminating() && !processHandler.isProcessTerminated() && (line = reader.readLine()) != null) {
if (!StringUtil.isEmptyOrSpaces(line)) {
LOG.debug("MXUnit: " + line);
processHandler.notifyTextAvailable(line + "\n", ProcessOutputTypes.SYSTEM);
}
}
} catch (IOException e) {
LOG.warn(e);
processHandler.notifyTextAvailable("Failed to retrieve test results from the server at " + agentUrl + "\n", ProcessOutputTypes.SYSTEM);
} finally {
if (method != null) {
method.releaseConnection();
}
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
// ignore
}
}
}
LOG.debug("Cleaning temporary files");
deleteFile(project, directory.findChild(launcherFileName));
deleteFile(project, directory.findChild(resultsFileName));
if (!processHandler.isProcessTerminated() && !processHandler.isProcessTerminating()) {
processHandler.destroyProcess();
}
} catch (ExecutionException e) {
ref.set(e);
}
});
if (!ref.isNull()) {
throw ref.get();
}
}
use of org.apache.commons.httpclient.HttpMethod in project sling by apache.
the class AuthenticationResponseCodeTest method testValidatingIncorrectCredentials.
@Test
public void testValidatingIncorrectCredentials() throws Exception {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_username", "garbage"));
params.add(new NameValuePair("j_password", "garbage"));
params.add(new NameValuePair("j_validate", "true"));
HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_FORBIDDEN, params, null);
assertNotNull(post.getResponseHeader("X-Reason"));
}
use of org.apache.commons.httpclient.HttpMethod in project sling by apache.
the class AuthenticationResponseCodeTest method testValidatingIncorrectCookie.
@Test
public void testValidatingIncorrectCookie() throws Exception {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new NameValuePair("j_validate", "true"));
List<Header> headers = new ArrayList<Header>();
headers.add(new Header("Cookie", "sling.formauth=garbage"));
HttpMethod post = assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_FORBIDDEN, params, headers, null);
assertXReason(post);
}
Aggregations