### Question:
JndiJdbcReportDataSourceServiceFactory extends JdbcReportDataSourceServiceFactory { public ReportDataSourceService createService(ReportDataSource dataSource) { String jndiName; DataSource ds; JndiJdbcReportDataSource jndiDataSource = (JndiJdbcReportDataSource) dataSource; if (getProfileAttributesResolver() != null) jndiDataSource = getProfileAttributesResolver().mergeResource(jndiDataSource); TimeZone timeZone = getTimeZoneByDataSourceTimeZone(jndiDataSource.getTimezone()); jndiName = jndiDataSource.getJndiName(); if (disableJndi || ctx == null) { return createServiceFromFallbackProperties(jndiName, timeZone); } try { ds = (DataSource) ctx.lookup("java:comp/env/" + jndiName); return new JdbcDataSourceService(ds, timeZone); } catch (NoInitialContextException e) { ctx = null; return createService(dataSource); } catch (NamingException e) { try { ds = (DataSource) ctx.lookup(jndiName); return new JdbcDataSourceService(ds, timeZone); } catch (NamingException ex) { if (log.isDebugEnabled()) log.debug(e, e); throw new JSDataSourceConnectionFailedException(e); } } } JndiJdbcReportDataSourceServiceFactory(); ReportDataSourceService createService(ReportDataSource dataSource); void setDisableJndi(boolean disableJndi); boolean isDisableJndi(); void setJndiFallbackResolver(JndiFallbackResolver jndiFallbackResolver); static Map<String, String> getJndiAppServerConnectionFunctionMap(); static void setJndiAppServerConnectionFunctionMap(Map<String, String> jndiAppServerConnectionFunctionMap);  }### Answer:
@Test public void ensureDataSourceTimeZoneIsAppliedToDataSourceService() { final String dsTimeZone = "GMT+5"; setUp(); JdbcDataSourceService rds = (JdbcDataSourceService) jndiJdbcReportDataSourceServiceFactory.createService(getDataSourceService(dsTimeZone)); Map<String, ?> paramsMap = new HashMap<>(); rds.setReportParameterValues(paramsMap); assertEquals(TimeZone.getTimeZone(dsTimeZone), paramsMap.get(JRTimezoneJdbcQueryExecuterFactory.PARAMETER_TIMEZONE)); }
@Test public void ensureDefaultTimeZoneIsAppliedToDataSourceServiceIfTZFromDataSourceIsEmptyOrNull() { final String emptyTZ = ""; final String nullTZ = null; setUp(); JdbcDataSourceService emptyTZService = (JdbcDataSourceService) jndiJdbcReportDataSourceServiceFactory.createService(getDataSourceService(emptyTZ)); JdbcDataSourceService nullTZService = (JdbcDataSourceService) jndiJdbcReportDataSourceServiceFactory.createService(getDataSourceService(nullTZ)); Map<String, ?> paramsMap = new HashMap<>(); emptyTZService.setReportParameterValues(paramsMap); assertEquals(TimeZone.getDefault(), paramsMap.get(JRTimezoneJdbcQueryExecuterFactory.PARAMETER_TIMEZONE)); nullTZService.setReportParameterValues(paramsMap); assertEquals(TimeZone.getDefault(), paramsMap.get(JRTimezoneJdbcQueryExecuterFactory.PARAMETER_TIMEZONE)); }