use of org.apache.commons.httpclient.server.SimpleHttpServer in project ecf by eclipse.
the class TestBadContentLength method setUp.
// ----------------------------------------------------------- Test Methods
public void setUp() throws IOException {
client = new HttpClient();
// use arbitrary port
server = new SimpleHttpServer();
server.setTestname(getName());
server.setRequestHandler(new MyHttpRequestHandler());
}
use of org.apache.commons.httpclient.server.SimpleHttpServer in project ecf by eclipse.
the class RestServiceTest method testServerCreation.
public void testServerCreation() {
assertNotNull(service);
SimpleHttpServer server = service.getServer();
assertNotNull(server);
assertTrue(server.isRunning());
}
use of org.apache.commons.httpclient.server.SimpleHttpServer in project ecf by eclipse.
the class RestServiceTest method testStop.
public void testStop() {
SimpleHttpServer server = service.getServer();
assertNotNull(server);
service.shutdown();
server = service.getServer();
assertNull(server);
}
use of org.apache.commons.httpclient.server.SimpleHttpServer in project ecf by eclipse.
the class SimpleRestService method createServer.
private void createServer() {
try {
server = new SimpleHttpServer();
server.setRequestHandler(reqHandler);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.apache.commons.httpclient.server.SimpleHttpServer in project ecf by eclipse.
the class URLRetrieveTestCancelConnectJob method testReceiveFile_cancelConnectJob.
// TODO: add test that cancel without connect job, when server does not
// respond
public void testReceiveFile_cancelConnectJob() throws Exception {
if (!CANCEL_SUPPORTED_ON_CONNECT) {
trace("WARNING: Cancel not supported by this provider. testReceiveFile_cancelConnectJob cannot be used");
return;
}
final Object[] doCancel = new Object[1];
final IFileTransferListener listener = createFileTransferListener();
final FileTransferListenerWrapper lw = new FileTransferListenerWrapper(listener) {
protected void handleStartConnectEvent(final IFileTransferConnectStartEvent event) {
assertNotNull(event.getFileID());
assertNotNull(event.getFileID().getFilename());
FileTransferJob connectJob = event.prepareConnectJob(null);
connectJob.addJobChangeListener(new JobChangeTraceListener(startTime) {
public void running(IJobChangeEvent jobEvent) {
super.running(jobEvent);
spawnCancelThread(doCancel, new ICancelable() {
public void cancel() {
assertNotNull(socketInReadWrapper);
assertTrue(socketInReadWrapper.inRead);
event.cancel();
}
});
}
});
event.connectUsingJob(connectJob);
}
};
final SimpleServer server = new SimpleServer(getName());
SimpleHttpServer simple = server.getSimpleHttpServer();
simple.setRequestHandler(new HttpRequestHandler() {
public boolean processRequest(SimpleHttpServerConnection conn, SimpleRequest request) throws IOException {
trace("Not responding to request " + request.getRequestLine());
return stalledInRequestHandler(doCancel);
}
});
try {
// path does not matter as server does not respond.
testReceive(server.getServerURL() + "/foo", lw);
assertHasEvent(startConnectEvents, IFileTransferConnectStartEvent.class);
assertHasNoEvent(startEvents, IIncomingFileTransferReceiveStartEvent.class);
assertHasNoEvent(dataEvents, IIncomingFileTransferReceiveDataEvent.class);
IIncomingFileTransferReceiveDoneEvent doneEvent = getDoneEvent();
assertTrue(doneEvent.getException().toString(), doneEvent.getException() instanceof UserCancelledException);
assertTrue(doneEvent.getSource().isDone());
assertSame(doneEvent.getException(), doneEvent.getSource().getException());
assertNull(tmpFile);
assertFalse(socketInReadWrapper.inRead);
socketEvents.validateOneSocketCreatedAndClosed();
} finally {
server.shutdown();
}
}
Aggregations