/*
 * #%L
 * Common package for I/O and related utilities
 * %%
 * Copyright (C) 2016 Open Microscopy Environment:
 *   - Board of Regents of the University of Wisconsin-Madison
 *   - Glencoe Software, Inc.
 *   - University of Dundee
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * #L%
 */

package loci.common.utests;

import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;

import org.slf4j.LoggerFactory;

import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
import loci.common.DebugTools;

import org.testng.annotations.Test;

/**
 * Unit tests for {@link loci.common.DebugTools}.
 */
public class DebugToolsTest {

  // -- Tests --

  @Test
  public void testDefault() {
    assertTrue(DebugTools.isEnabled());
    boolean status = DebugTools.enableLogging();
    assertFalse(status);
  }

  @Test
  public void testResetContext() {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.getLoggerContext().reset();
    assertFalse(DebugTools.isEnabled());
    boolean status = DebugTools.enableLogging();
    assertTrue(status);
  }
}

@@ -1665,16 +1665,48 @@
 ntext;%0A%0A
+import loci.common.DebugTools;%0A%0A
 import o
@@ -1840,387 +1840,540 @@
 ort 
-loci.common.DebugTools;%0A%0Aimport org.testng.annotations.Test;%0A%0A/**%0A * Unit tests for %7B@link loci.common.DebugTools%7D.%0A */%0Apublic class DebugToolsTest %7B%0A%0A  // -- Tests --%0A%0A  @Test%0A  public void testDefault() %7B%0A    assertTrue(DebugTools.isEnabled());%0A    boolean status = DebugTools.enableLogging();%0A    assertFalse(status);%0A  %7D%0A%0A  @Test%0A  public void testResetContext() %7B%0A    Logger
+static org.testng.AssertJUnit.assertEquals;%0Aimport org.testng.annotations.BeforeMethod;%0Aimport org.testng.annotations.DataProvider;%0Aimport org.testng.annotations.Test;%0A%0A/**%0A * Unit tests for %7B@link loci.common.DebugTools%7D.%0A */%0Apublic class DebugToolsTest %7B%0A%0A  Logger root;%0A%0A  @DataProvider(name = %22levels%22)%0A  public Object%5B%5D%5B%5D createLevels() %7B%0A    return new Object%5B%5D%5B%5D %7B%0A        %7B%22INFO%22%7D, %7B%22WARN%22%7D, %7B%22ERROR%22%7D, %7B%22DEBUG%22%7D, %7B%22TRACE%22%7D, %7B%22ALL%22%7D%7D;%0A  %7D%0A%0A  @BeforeMethod%0A  public void setUp() %7B%0A    // Make sure logger context is reset%0A   
  roo
@@ -2513,16 +2513,82 @@
 led());%0A
+  %7D%0A%0A  // -- Tests --%0A  @Test%0A  public void testEnableLogging() %7B%0A
     bool
@@ -2655,11 +2655,223 @@
 us);%0A  %7D
+%0A%0A  @Test(dataProvider = %22levels%22)%0A  public void testEnableLoggingLevels(String level) %7B%0A    boolean status = DebugTools.enableLogging(level);%0A    assertTrue(status);%0A    assertEquals(root.getLevel(), level);%0A  %7D
 %0A%7D%0A

Migrate logger context reset to a setup method and test logging levels