0

I have a Logger that is private static final which utilizes a server. I would like to suppress the Logger method debug, or suppress any and all interactions with the variable. I declare the logger in LoggingClass

private static final Logger LOGGER = LoggerFactory.getLogger("LoggingClass");

The javadoc for the debug is :

public abstract void debug(String s, Object aobj[]);

In the test class I have tried:

PowerMockito.suppress(PowerMockito.method(Logger.class, "debug", String.class, Object[].class));

Problem : Throws toomanyMethodsException

===========

 Logger nullLogger= null;
 LoggingClass lc= new LoggingClass(); //This is the class that uses the logger
 Whitebox.setInternalState(lc, "LOGGER",nullLogger);

Problem: Throws that Whitebox can not find the instance field LOGGER.

Any assistance would be appreicated

CoronA
  • 7,717
  • 2
  • 26
  • 53
mcha
  • 1
  • 1

1 Answers1

0

Try below

suppress(everythingDeclaredIn(LoggerFactory.class));

The import statements are

import static org.powermock.api.support.membermodification.MemberMatcher.everythingDeclaredIn;
import static org.powermock.api.support.membermodification.MemberModifier.suppress;
kswaughs
  • 2,967
  • 1
  • 17
  • 21