### Question:
DatabaseUtil implements DataSourceProviderInterface { @Override public DataSource getNamedDataSource( String datasourceName ) throws DataSourceNamingException { ClassLoader original = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( getClass().getClassLoader() ); return DatabaseUtil.getDataSourceFromJndi( datasourceName, new InitialContext() ); } catch ( NamingException ex ) { throw new DataSourceNamingException( ex ); } finally { Thread.currentThread().setContextClassLoader( original ); } }  static void closeSilently( Connection[] connections ); static void closeSilently( Connection conn ); static void closeSilently( Statement[] statements ); static void closeSilently( Statement st ); @Override DataSource getNamedDataSource( String datasourceName ); @Override DataSource getNamedDataSource( String datasourceName, DatasourceType type );  }### Answer:
@Test public void testCl() throws NamingException { DataSource dataSource = mock( DataSource.class ); when( context.lookup( testName ) ).thenReturn( dataSource ); DatabaseUtil util = new DatabaseUtil(); ClassLoader orig = Thread.currentThread().getContextClassLoader(); ClassLoader cl = mock( ClassLoader.class ); try { Thread.currentThread().setContextClassLoader( cl ); util.getNamedDataSource( testName ); } catch ( Exception ex ) { } finally { try { verify( cl, never() ).loadClass( anyString() ); verify( cl, never() ).getResource( anyString() ); verify( cl, never() ).getResourceAsStream( anyString() ); } catch ( Exception ex ) { } Thread.currentThread().setContextClassLoader( orig ); } }