ExceptionBasedClientTypeProvider implements IClientTypeProvider { @Override public String getClientType() { try { throw new Exception( "bogusError" ); } catch ( Exception e ) { StackTraceElement[] stackTrace = e.getStackTrace(); boolean environmentInitFound = false; for ( StackTraceElement stackTraceElement : stackTrace ) { String className = stackTraceElement.getClassName(); if ( environmentInitFound && disregardClassNames.contains( className ) ) { environmentInitFound = false; } if ( environmentInitFound && !targetClassNames.contains( className ) ) { className = className.substring( className.lastIndexOf( "." ) + 1 ).toLowerCase(); if ( className.contains( "$" ) ) { className = className.substring( 0, className.indexOf( "$" ) ); } return className; } if ( targetClassNames.contains( className ) ) { environmentInitFound = true; } } } return "default"; }  void setTargetClass( Class targetClass ); void setDisregardClass( Class disregardClass ); @Override String getClientType();  }
@Test public void testGetClientType() throws Exception { provider = new ExceptionBasedClientTypeProvider(); provider.setTargetClass( ExceptionBasedClientTypeProviderTest.class ); ExceptionBasedHelper helper = new ExceptionBasedHelper(); helper.callme( this ); }