"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-core/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

NestedLoggerConfigTest.java  (apache-log4j-2.11.1-src):NestedLoggerConfigTest.java  (apache-log4j-2.11.2-src)
skipping to change at line 21 skipping to change at line 21
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the license for the specific language governing permissions and * See the license for the specific language governing permissions and
* limitations under the license. * limitations under the license.
*/ */
package org.apache.logging.log4j.core.config; package org.apache.logging.log4j.core.config;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.xml.XmlConfiguration; import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
import org.apache.logging.log4j.core.impl.Log4jLogEvent.Builder;
import org.apache.logging.log4j.core.impl.LogEventFactory;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.SimpleMessage;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
/** /**
* Tests for LoggerConfig hierarchies. * Tests for LoggerConfig hierarchies.
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class NestedLoggerConfigTest { public class NestedLoggerConfigTest {
@Parameterized.Parameters(name = "{0}") @Parameterized.Parameters(name = "{0}")
public static List<String> data() throws IOException { public static List<String> data() throws IOException {
return ImmutableList.of("logger-config/LoggerConfig/", "logger-config/As yncLoggerConfig/"); return ImmutableList.of("logger-config/LoggerConfig/", "logger-config/As yncLoggerConfig/");
} }
private final String prefix; private final String prefix;
public NestedLoggerConfigTest(String prefix) { public NestedLoggerConfigTest(final String prefix) {
this.prefix = prefix; this.prefix = prefix;
} }
@Test @Test
public void testInheritParentDefaultLevel() throws IOException { public void testInheritParentDefaultLevel() throws IOException {
Configuration configuration = loadConfiguration(prefix + "default-level. xml"); final Configuration configuration = loadConfiguration(prefix + "default- level.xml");
try { try {
assertEquals(Level.ERROR, configuration.getLoggerConfig("com.foo").g etLevel()); assertEquals(Level.ERROR, configuration.getLoggerConfig("com.foo").g etLevel());
} finally { } finally {
configuration.stop(); configuration.stop();
} }
} }
@Test @Test
public void testInheritParentLevel() throws IOException { public void testInheritParentLevel() throws IOException {
Configuration configuration = loadConfiguration(prefix + "inherit-level. xml"); final Configuration configuration = loadConfiguration(prefix + "inherit- level.xml");
try { try {
assertEquals(Level.TRACE, configuration.getLoggerConfig("com.foo").g etLevel()); assertEquals(Level.TRACE, configuration.getLoggerConfig("com.foo").g etLevel());
} finally { } finally {
configuration.stop(); configuration.stop();
} }
} }
private Configuration loadConfiguration(String resourcePath) throws IOExcept private Configuration loadConfiguration(final String resourcePath) throws IO
ion { Exception {
InputStream in = getClass().getClassLoader().getResourceAsStream(resourc final InputStream in = getClass().getClassLoader().getResourceAsStream(r
ePath); esourcePath);
try { try {
Configuration configuration = new XmlConfiguration(new LoggerContext ("test"), new ConfigurationSource(in)); final Configuration configuration = new XmlConfiguration(new LoggerC ontext("test"), new ConfigurationSource(in));
configuration.initialize(); configuration.initialize();
configuration.start(); configuration.start();
return configuration; return configuration;
} finally { } finally {
in.close(); in.close();
} }
} }
} }
 End of changes. 9 change blocks. 
19 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)