Code example for Locale

Methods: toString

0
        HttpConnection connection = new HttpConnection(connector,connector._endp,connector._server);
        Request request = connection.getRequest();
        Response response = connection.getResponse();
        ContextHandler context = new ContextHandler();
        context.addLocaleEncoding(Locale.ENGLISH.toString(),"ISO-8859-1");
        context.addLocaleEncoding(Locale.ITALIAN.toString(),"ISO-8859-2");
        request.setContext(context.getServletContext());
 
        response.setLocale(java.util.Locale.ITALIAN);
        assertEquals(null,response.getContentType());
        response.setContentType("text/plain");
        assertEquals("text/plain; charset=ISO-8859-2",response.getContentType());
 
        response.recycle();
        response.setContentType("text/plain");
        response.setCharacterEncoding("utf-8");
        response.setLocale(java.util.Locale.ITALIAN);
        assertEquals("text/plain; charset=utf-8",response.getContentType());
        assertTrue(response.toString().indexOf("charset=utf-8")>0);
    } 
     
    public void testContentTypeCharacterEncoding()