// Path: jdcallgraph/src/test/java/com/dkarv/jdcallgraph/helper/Console.java
// public class Console {
//   private final PrintStream err;
//   private final PrintStream out;
//   private final ByteArrayOutputStream outContent;
//   private final ByteArrayOutputStream errContent;
// 
//   public Console() {
//     err = System.err;
//     out = System.out;
//     outContent = new ByteArrayOutputStream();
//     errContent = new ByteArrayOutputStream();
//   }
// 
//   public void startCapture() throws UnsupportedEncodingException {
//     System.setOut(new PrintStream(outContent, true, "UTF-8"));
//     System.setErr(new PrintStream(errContent, true, "UTF-8"));
//   }
// 
//   public void clear() {
//     outContent.reset();
//     errContent.reset();
//   }
// 
//   public void reset() {
//     System.setOut(out);
//     System.setErr(err);
//   }
// 
//   public String getOut() throws UnsupportedEncodingException {
//     return outContent.toString("UTF-8");
//   }
// 
//   public String getErr() throws UnsupportedEncodingException {
//     return errContent.toString("UTF-8");
//   }
// }
// 
// Path: jdcallgraph/src/test/java/com/dkarv/jdcallgraph/util/config/ConfigUtils.java
// public class ConfigUtils {
// 
//   public static void replace(boolean addDefaults, String... options) throws IOException {
//     if (addDefaults) {
//       new ConfigReader(
//           ConfigUtils.class.getResourceAsStream("/com/dkarv/jdcallgraph/defaults.ini"),
//           write(options)).read();
//     } else {
//       new ConfigReader(
//           write(options)).read();
//     }
//   }
// 
//   public static InputStream write(String... options) throws IOException {
//     StringBuilder str = new StringBuilder();
//     for (String opt : options) {
//       str.append(opt);
//       str.append('\n');
//     }
//     return TestUtils.writeInputStream(str.toString());
//   }
// 
//   public static void inject(Config config) {
//     Config.instance = config;
//   }
// }


import com.dkarv.jdcallgraph.helper.Console;
import com.dkarv.jdcallgraph.util.config.ConfigUtils;
import org.hamcrest.text.MatchesPattern;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.Mockito;
import java.io.IOException;
import java.util.regex.Pattern;
import static org.junit.Assert.*;
    arg = null;
    logger.debug("test {}", arg);
    Mockito.verify(target).print(Mockito.matches("\\[.*] \\[DEBUG] \\[LoggerTest] test null\n"),
        Mockito.eq(5));
  }

  @Test
  public void testWrongArgumentCount() {
    Logger logger = init(6, false);
    try {
      logger.debug("test {}", "123", "456");
      fail("Should notice too less {}");
    } catch (IllegalArgumentException e) {
    }

    try {
      logger.debug("test {} {}");
      fail("Should notice missing arguments");
    } catch (IllegalArgumentException e) {
    }
  }

  @Test
  public void testTargetError() throws IOException {
    Logger logger = init(6, false);
    Logger.TARGETS.clear();
    LogTarget target = Mockito.mock(LogTarget.class);
    Mockito.doThrow(new IOException("error")).when(target).print(Mockito.anyString(), Mockito.anyInt());
    Logger.TARGETS.add(target);

// Path: jdcallgraph/src/test/java/com/dkarv/jdcallgraph/helper/Console.java
// public class Console {
//   private final PrintStream err;
//   private final PrintStream out;
//   private final ByteArrayOutputStream outContent;
//   private final ByteArrayOutputStream errContent;
// 
//   public Console() {
//     err = System.err;
//     out = System.out;
//     outContent = new ByteArrayOutputStream();
//     errContent = new ByteArrayOutputStream();
//   }
// 
//   public void startCapture() throws UnsupportedEncodingException {
//     System.setOut(new PrintStream(outContent, true, "UTF-8"));
//     System.setErr(new PrintStream(errContent, true, "UTF-8"));
//   }
// 
//   public void clear() {
//     outContent.reset();
//     errContent.reset();
//   }
// 
//   public void reset() {
//     System.setOut(out);
//     System.setErr(err);
//   }
// 
//   public String getOut() throws UnsupportedEncodingException {
//     return outContent.toString("UTF-8");
//   }
// 
//   public String getErr() throws UnsupportedEncodingException {
//     return errContent.toString("UTF-8");
//   }
// }
// 
// Path: jdcallgraph/src/test/java/com/dkarv/jdcallgraph/util/config/ConfigUtils.java
// public class ConfigUtils {
// 
//   public static void replace(boolean addDefaults, String... options) throws IOException {
//     if (addDefaults) {
//       new ConfigReader(
//           ConfigUtils.class.getResourceAsStream("/com/dkarv/jdcallgraph/defaults.ini"),
//           write(options)).read();
//     } else {
//       new ConfigReader(
//           write(options)).read();
//     }
//   }
// 
//   public static InputStream write(String... options) throws IOException {
//     StringBuilder str = new StringBuilder();
//     for (String opt : options) {
//       str.append(opt);
//       str.append('\n');
//     }
//     return TestUtils.writeInputStream(str.toString());
//   }
// 
//   public static void inject(Config config) {
//     Config.instance = config;
//   }
// }


// Path: jdcallgraph/src/test/java/com/dkarv/jdcallgraph/util/log/LoggerTest.java
import com.dkarv.jdcallgraph.helper.Console;
import com.dkarv.jdcallgraph.util.config.ConfigUtils;
import org.hamcrest.text.MatchesPattern;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.Mockito;
import java.io.IOException;
import java.util.regex.Pattern;
import static org.junit.Assert.*;

    arg = null;
    logger.debug("test {}", arg);
    Mockito.verify(target).print(Mockito.matches("\\[.*] \\[DEBUG] \\[LoggerTest] test null\n"),
        Mockito.eq(5));
  }

  @Test
  public void testWrongArgumentCount() {
    Logger logger = init(6, false);
    try {
      logger.debug("test {}", "123", "456");
      fail("Should notice too less {}");
    } catch (IllegalArgumentException e) {
    }

    try {
      logger.debug("test {} {}");
      fail("Should notice missing arguments");
    } catch (IllegalArgumentException e) {
    }
  }

  @Test
  public void testTargetError() throws IOException {
    Logger logger = init(6, false);
    Logger.TARGETS.clear();
    LogTarget target = Mockito.mock(LogTarget.class);
    Mockito.doThrow(new IOException("error")).when(target).print(Mockito.anyString(), Mockito.anyInt());
    Logger.TARGETS.add(target);

    Console console = new Console();