Question : WebSocket Test Client with CORS

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Question : WebSocket Test Client with CORS

Charles Moulliard

I'm looking to implement some tests cases to test Cross Origin Resource Sharing (CORS) with camel-websocket. Until now, we have used the lib Async HTTP of the ning project ( to design our client tests cases. Unfortunately, the existing code does not provide like this Jetty Class ( object + method to check response status and content

        FilterHolder filterHolder = new FilterHolder(new CrossOriginFilter());
        String origin = "http://localhost";
        filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, origin);
        tester.getContext().addFilter(filterHolder, "/*", FilterMapping.DEFAULT);

        CountDownLatch latch = new CountDownLatch(1);
        tester.getContext().addServlet(new ServletHolder(new ResourceServlet(latch)), "/*");

        String request = "" +
                "GET / HTTP/1.1\r\n" +
                "Host: localhost\r\n" +
                "Origin: " + origin + "\r\n" +
        String response = tester.getResponses(request);
        Assert.assertTrue(response.contains("HTTP/1.1 200"));

Question : Does anybody has an idea How to get HTTP Response with Async HTTP Client ?


Apache Committer / Sr. Pr. Consultant at
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog :