JdbcWrapper { void initServletContext(ServletContext context) { assert context != null; this.servletContext = context; final String serverInfo = servletContext.getServerInfo(); jboss = serverInfo.contains("JBoss") || serverInfo.contains("WildFly"); glassfish = serverInfo.contains("GlassFish") || serverInfo.contains("Sun Java System Application Server") || serverInfo.contains("Payara"); weblogic = serverInfo.contains("WebLogic"); connectionInformationsEnabled = Parameters.isSystemActionsEnabled() && !Parameters.isNoDatabase(); } private  JdbcWrapper(Counter sqlCounter); static int getUsedConnectionCount(); static int getActiveConnectionCount(); static long getTransactionCount(); static int getActiveThreadCount(); static int getRunningBuildCount(); static int getBuildQueueLength(); static long getBuildQueueWaitingDurationsSum(); static List<ConnectionInformations> getConnectionInformationsList(); Counter getSqlCounter(); static int getMaxConnectionCount(); static Map<String, Map<String, Object>> getBasicDataSourceProperties(); static Map<String, DataSource> getJndiAndSpringDataSources(); static void registerSpringDataSource(String name, DataSource dataSource); DataSource createDataSourceProxy(DataSource dataSource); DataSource createDataSourceProxy(String name, final DataSource dataSource); Connection createConnectionProxy(Connection connection); static final JdbcWrapper SINGLETON; }
@Test public void testInitServletContext() { final String[] servers = { "JBoss", "WildFly", "GlassFish", "Sun Java System Application Server", "WebLogic", }; for (final String serverName : servers) { final ServletContext servletContext = createNiceMock(ServletContext.class); expect(servletContext.getServerInfo()).andReturn(serverName).anyTimes(); replay(servletContext); jdbcWrapper.initServletContext(servletContext); verify(servletContext); } }