Search in sources :

Example 1 with AbstractEndPoint

use of org.eclipse.jetty.io.AbstractEndPoint in project jetty.project by eclipse.

the class ResponseTest method init.

@Before
public void init() throws Exception {
    _server = new Server();
    Scheduler _scheduler = new TimerScheduler();
    HttpConfiguration config = new HttpConfiguration();
    LocalConnector connector = new LocalConnector(_server, null, _scheduler, null, 1, new HttpConnectionFactory(config));
    _server.addConnector(connector);
    _server.setHandler(new DumpHandler());
    _server.start();
    AbstractEndPoint endp = new ByteArrayEndPoint(_scheduler, 5000) {

        @Override
        public InetSocketAddress getLocalAddress() {
            return LOCALADDRESS;
        }
    };
    _channel = new HttpChannel(connector, new HttpConfiguration(), endp, new HttpTransport() {

        private Throwable _channelError;

        @Override
        public void send(MetaData.Response info, boolean head, ByteBuffer content, boolean lastContent, Callback callback) {
            if (_channelError == null)
                callback.succeeded();
            else
                callback.failed(_channelError);
        }

        @Override
        public boolean isPushSupported() {
            return false;
        }

        @Override
        public void push(org.eclipse.jetty.http.MetaData.Request request) {
        }

        @Override
        public void onCompleted() {
        }

        @Override
        public void abort(Throwable failure) {
            _channelError = failure;
        }

        @Override
        public boolean isOptimizedForDirectBuffers() {
            return false;
        }
    });
}
Also used : TimerScheduler(org.eclipse.jetty.util.thread.TimerScheduler) AbstractEndPoint(org.eclipse.jetty.io.AbstractEndPoint) Scheduler(org.eclipse.jetty.util.thread.Scheduler) TimerScheduler(org.eclipse.jetty.util.thread.TimerScheduler) HttpServletRequest(javax.servlet.http.HttpServletRequest) ByteArrayEndPoint(org.eclipse.jetty.io.ByteArrayEndPoint) ByteBuffer(java.nio.ByteBuffer) HttpServletResponse(javax.servlet.http.HttpServletResponse) Callback(org.eclipse.jetty.util.Callback) Before(org.junit.Before)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 AbstractEndPoint (org.eclipse.jetty.io.AbstractEndPoint)1 ByteArrayEndPoint (org.eclipse.jetty.io.ByteArrayEndPoint)1 Callback (org.eclipse.jetty.util.Callback)1 Scheduler (org.eclipse.jetty.util.thread.Scheduler)1 TimerScheduler (org.eclipse.jetty.util.thread.TimerScheduler)1 Before (org.junit.Before)1