EasyMock.expect(req.getParameter("tqx")).andReturn("out:csv;");
EasyMock.expect(req.getParameter("tq")).andReturn(null);
EasyMock.replay(req);
dataSourceRequest = DataSourceRequest.getDefaultDataSourceRequest(req);
EasyMock.verify(req);
assertEquals(new ULocale("fr"), dataSourceRequest.getUserLocale());
assertTrue(dataSourceRequest.isSameOrigin());
assertEquals(OutputType.CSV, dataSourceRequest.getDataSourceParameters().getOutputType());
// Test with empty request (only locale).
dataSourceRequest = null;
req = EasyMock.createMock(HttpServletRequest.class);
EasyMock.expect(req.getParameter("hl")).andReturn(null);
EasyMock.expect(req.getLocale()).andReturn(new Locale("qq"));
EasyMock.expect(req.getHeader("X-DataSource-Auth")).andReturn(null);
EasyMock.expect(req.getParameter("tqx")).andReturn(null);
EasyMock.expect(req.getParameter("tq")).andReturn(null);
EasyMock.replay(req);
dataSourceRequest = DataSourceRequest.getDefaultDataSourceRequest(req);
EasyMock.verify(req);
assertEquals(new ULocale("qq"), dataSourceRequest.getUserLocale());
assertFalse(dataSourceRequest.isSameOrigin());
assertEquals(OutputType.JSONP, dataSourceRequest.getDataSourceParameters().getOutputType());
// Test with hl == it, not same-domain.
dataSourceRequest = null;
req = EasyMock.createMock(HttpServletRequest.class);
EasyMock.expect(req.getParameter("hl")).andReturn("it");
EasyMock.expect(req.getHeader("X-DataSource-Auth")).andReturn(null);
EasyMock.expect(req.getParameter("tqx")).andReturn(null);
EasyMock.expect(req.getParameter("tq")).andReturn(null);
EasyMock.replay(req);
dataSourceRequest = DataSourceRequest.getDefaultDataSourceRequest(req);
EasyMock.verify(req);
assertEquals(new ULocale("it"), dataSourceRequest.getUserLocale());
assertFalse(dataSourceRequest.isSameOrigin());
assertEquals(OutputType.JSONP, dataSourceRequest.getDataSourceParameters().getOutputType());
}