DefaultKeyProvider implements KeyProvider { Method getKeyMethod(final Object keyObject) throws NoSuchMethodException { return methodStore.getKeyMethod(keyObject.getClass()); }  void setMethodStore(final CacheKeyMethodStore methodStore); CacheKeyMethodStore getMethodStore(); @Override String generateKey(final Object keyObject); @Override String[] generateKeys(final Object[] keyObjects);  }
@Test public void testKeyMethodArgs() throws Exception { try { cut.getKeyMethod(new KeyObject01()); fail("Expected exception."); } catch (InvalidAnnotationException ex) { assertTrue(ex.getMessage().indexOf("0 arguments") != -1); System.out.println(ex.getMessage()); } try { cut.getKeyMethod(new KeyObject02()); fail("Expected exception."); } catch (InvalidAnnotationException ex) { assertTrue(ex.getMessage().indexOf("String") != -1); System.out.println(ex.getMessage()); } try { cut.getKeyMethod(new KeyObject03()); fail("Expected exception."); } catch (InvalidAnnotationException ex) { assertTrue(ex.getMessage().indexOf("String") != -1); System.out.println(ex.getMessage()); } try { cut.getKeyMethod(new KeyObject04()); fail("Expected exception."); } catch (InvalidAnnotationException ex) { assertTrue(ex.getMessage().indexOf("only one method") != -1); System.out.println(ex.getMessage()); } assertEquals("doIt", cut.getKeyMethod(new KeyObject05()).getName()); assertEquals("toString", cut.getKeyMethod(new KeyObject06(null)).getName()); }