SpringSecurityHibernateConfig { public PasswordEncoder getPasswordEncoder() { try { String pentahoEncoderClassName = document.selectSingleNode( PASSWORD_ENCODER_CLASS_XPATH ).getText(); Class passwordEncoderClass = Class.forName( pentahoEncoderClassName ); return (PasswordEncoder) passwordEncoderClass.newInstance(); } catch ( ClassNotFoundException e ) { return null; } catch ( InstantiationException e ) { return null; } catch ( IllegalAccessException e ) { return null; } } SpringSecurityHibernateConfig( File xmlFile );  SpringSecurityHibernateConfig( String xml );  SpringSecurityHibernateConfig( Document doc );  SpringSecurityHibernateConfig(); PasswordEncoder getPasswordEncoder(); Document getDocument();  }
@Test public void testGetPasswordEncoder() throws Exception { config = new SpringSecurityHibernateConfig( document ); Node node = mock( Node.class ); when( node.getText() ).thenReturn( DefaultPentahoPasswordEncoder.class.getName() ); when( document.selectSingleNode( anyString() ) ).thenReturn( node ); PasswordEncoder passwordEncoder = config.getPasswordEncoder(); assertTrue( passwordEncoder instanceof DefaultPentahoPasswordEncoder ); }
@Test public void testGetPasswordEncoder_ClassNotFound() throws Exception { config = new SpringSecurityHibernateConfig( document ); Node node = mock( Node.class ); when( node.getText() ).thenReturn( "org.pentaho.ClassNotFoundEncoder" ); when( document.selectSingleNode( anyString() ) ).thenReturn( node ); PasswordEncoder passwordEncoder = config.getPasswordEncoder(); assertNull( passwordEncoder ); }