LoggerProducer { @Produces @OcelotLogger public Logger getLogger(InjectionPoint injectionPoint) { Annotated annotated = injectionPoint.getAnnotated(); OcelotLogger annotation = annotated.getAnnotation(OcelotLogger.class); String loggerName = annotation.name(); if(loggerName.isEmpty()) { loggerName = injectionPoint.getMember().getDeclaringClass().getName(); } return LoggerFactory.getLogger(loggerName); }  @Produces @OcelotLogger Logger getLogger(InjectionPoint injectionPoint);  }
@Test public void testGetLogger() { System.out.println("getLogger"); String expResult = LoggerProducerTest.class.getName(); Member member = mock(Member.class); Annotated annotated = mock(Annotated.class); Class cls = LoggerProducerTest.class; OcelotLogger ol = mock(OcelotLogger.class); when(member.getDeclaringClass()).thenReturn(cls); when(injectionPoint.getMember()).thenReturn(member); when(injectionPoint.getAnnotated()).thenReturn(annotated); when(annotated.getAnnotation(eq(OcelotLogger.class))).thenReturn(ol); when(ol.name()).thenReturn("").thenReturn("SECURITY"); Logger result = instance.getLogger(injectionPoint); assertThat(result.getName()).isEqualTo(expResult); result = instance.getLogger(injectionPoint); assertThat(result.getName()).isEqualTo("SECURITY"); }