Package org.geoserver.ows

Examples of org.geoserver.ows.Request


            IOUtils.closeQuietly(outWriter);
        }
    }

    private String getCallbackFunction() {
        Request request = Dispatcher.REQUEST.get();
        if (request == null) {
            return JSONType.CALLBACK_FUNCTION;
        }
        return JSONType.getCallbackFunction(request.getKvp());
    }
View Full Code Here


    public void testCookieRateControl() {
        RateFlowController controller = new RateFlowController(new OWSRequestMatcher(), 2,
                Long.MAX_VALUE, 1000, new CookieKeyGenerator());

        // run the first request
        Request firstRequest = buildCookieRequest(null);
        assertTrue(controller.requestIncoming(firstRequest, Integer.MAX_VALUE));
        checkHeaders(firstRequest, "Any OGC request", 2, 1);

        // grab the cookie
        Cookie cookie = (Cookie) ((MockHttpServletResponse) firstRequest.getHttpResponse())
                .getCookies().get(0);
        String cookieValue = cookie.getValue();

        // second request
        Request request = buildCookieRequest(cookieValue);
        assertTrue(controller.requestIncoming(request, Integer.MAX_VALUE));
        checkHeaders(request, "Any OGC request", 2, 0);

        // third one, this one will have to wait
        long start = System.currentTimeMillis();
View Full Code Here

    public void testCookie429() {
        RateFlowController controller = new RateFlowController(new OWSRequestMatcher(), 2,
                Long.MAX_VALUE, 0, new CookieKeyGenerator());

        // run the first request
        Request firstRequest = buildCookieRequest(null);
        assertTrue(controller.requestIncoming(firstRequest, Integer.MAX_VALUE));

        // grab the cookie
        Cookie cookie = (Cookie) ((MockHttpServletResponse) firstRequest.getHttpResponse())
                .getCookies().get(0);
        String cookieValue = cookie.getValue();

        // second request
        Request request = buildCookieRequest(cookieValue);
        assertTrue(controller.requestIncoming(request, Integer.MAX_VALUE));

        // this one should fail with a 429
        try {
            assertTrue(controller.requestIncoming(request, Integer.MAX_VALUE));
View Full Code Here

    public void testIpRateControl() {
        RateFlowController controller = new RateFlowController(new OWSRequestMatcher(), 2,
                Long.MAX_VALUE, 1000, new IpKeyGenerator());

        // run two requests
        Request request = buildIpRequest("127.0.0.1", "");
        assertTrue(controller.requestIncoming(request, Integer.MAX_VALUE));
        assertTrue(controller.requestIncoming(request, Integer.MAX_VALUE));

        // third one, this one will have to wait
        long start = System.currentTimeMillis();
View Full Code Here

    public void testIp429() {
        RateFlowController controller = new RateFlowController(new OWSRequestMatcher(), 2,
                Long.MAX_VALUE, 0, new IpKeyGenerator());

        // run two requests
        Request request = buildIpRequest("127.0.0.1", "");
        assertTrue(controller.requestIncoming(request, Integer.MAX_VALUE));
        assertTrue(controller.requestIncoming(request, Integer.MAX_VALUE));

        // this one should fail with a 429
        try {
View Full Code Here

            fail("Sometime interrupeted our wait: " + e);
        }
    }

    protected Request buildCookieRequest(String gsCookieValue) {
        Request request = new Request();
        MockHttpServletRequest httpRequest = new MockHttpServletRequest();
        request.setHttpRequest(httpRequest);
        request.setHttpResponse(new MockHttpServletResponse());
       
        if(gsCookieValue != null) {
            httpRequest.addCookie(new Cookie(CookieKeyGenerator.COOKIE_NAME, gsCookieValue));
        }
        return request;
View Full Code Here

        }
        return request;
    }

    Request buildIpRequest(String ipAddress, String proxyIp) {
        Request request = new Request();
        MockHttpServletRequest httpRequest = new MockHttpServletRequest();
        request.setHttpRequest(httpRequest);
        request.setHttpResponse(new MockHttpServletResponse());

        if (ipAddress != null && !ipAddress.equals("")) {
            httpRequest.setRemoteAddr(ipAddress);
        } else {
            httpRequest.setRemoteAddr("127.0.0.1");
View Full Code Here

        boolean featureBounding = wfs.isFeatureBounding();
       
        // include fid?
        String id_option = null; // null - default, "" - none, or "property"
        //GetFeatureRequest request = GetFeatureRequest.adapt(describeFeatureType.getParameters()[0]);
        Request request = Dispatcher.REQUEST.get();
        if (request != null) {
            id_option = JSONType.getIdPolicy( request.getKvp() );
        }
        // prepare to write out
        OutputStreamWriter osw = null;
        Writer outWriter = null;
        boolean hasGeom = false;
View Full Code Here

    public void testSingleDelay() throws Exception {
        // create a single item flow controller
        GlobalFlowController controller = new GlobalFlowController(1);

        // make three testing threads that will "process" forever, until we interrupt them
        FlowControllerTestingThread t1 = new FlowControllerTestingThread(new Request(), 0,
                Long.MAX_VALUE, controller);
        FlowControllerTestingThread t2 = new FlowControllerTestingThread(new Request(), 0,
                Long.MAX_VALUE, controller);
        FlowControllerTestingThread t3 = new FlowControllerTestingThread(new Request(), 0,
                Long.MAX_VALUE, controller);
        try {
            // start threads making sure every one of them managed to block somewhere before
            // starting the next one
            t1.start();
View Full Code Here

        // create a single item flow controller
        GlobalFlowController controller = new GlobalFlowController(1);

        // make two testing threads that will "process" for 400ms, but with a timeout of 200 on the
        // flow controller
        FlowControllerTestingThread t1 = new FlowControllerTestingThread(new Request(), 100,
                400, controller);
        FlowControllerTestingThread t2 = new FlowControllerTestingThread(new Request(), 100,
                400, controller);
       
        // start t1 first, let go t2 after
        try {
            t1.start();
View Full Code Here

TOP

Related Classes of org.geoserver.ows.Request

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.