I have a generic database access class, which i\'m binding using the TypeLiteral construct. Now in a test i want to mock that class and i have therefor created a Provider, t
Use Guice's Key facility, which is made for exactly this kind of problem. In your case
Key
injector.getInstance(Key.get(new TypeLiteral<GenericDbClass<Integer>>(){});
will do the trick.