Author: rgoers
Date: Fri Feb  3 07:25:46 2012
New Revision: 1240019

URL: http://svn.apache.org/viewvc?rev=1240019&view=rev
Log:
Fix LOG4J2-56

Added:
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LevelTest.java
Modified:
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Level.java
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/changes/changes.xml

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Level.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Level.java?rev=1240019&r1=1240018&r2=1240019&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Level.java
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/Level.java
 Fri Feb  3 07:25:46 2012
@@ -96,9 +96,12 @@ public enum Level {
         if (sArg == null) {
             return defaultLevel;
         }
-
-        Level level = valueOf(sArg);
-        return (level == null) ? defaultLevel : level;
+        for (Level level : values()) {
+            if (level.name().equals(sArg)) {
+                return level;
+            }
+        }
+        return defaultLevel;
     }
 
     /**

Added: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LevelTest.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LevelTest.java?rev=1240019&view=auto
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LevelTest.java
 (added)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/test/java/org/apache/logging/log4j/LevelTest.java
 Fri Feb  3 07:25:46 2012
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ *
+ */
+public class LevelTest {
+
+    @Test
+    public void testGoodLevels() {
+        Level level = Level.toLevel("INFO");
+        assertNotNull(level);
+        assertEquals(Level.INFO, level);
+    }
+
+    @Test
+    public void testDefault() {
+        Level level = Level.toLevel("Information", Level.ERROR);
+        assertNotNull(level);
+        assertEquals(Level.ERROR, level);
+    }
+}

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/changes/changes.xml?rev=1240019&r1=1240018&r2=1240019&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/changes/changes.xml 
(original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/src/changes/changes.xml 
Fri Feb  3 07:25:46 2012
@@ -23,11 +23,14 @@
 
   <body>
     <release version="2.0" date="TBD" description="Rewrite of Log4j">
-      <action issue="VFS-51" dev="rgoers" type="fix" due-to="John Vasileff">
+      <action issue="LOG4J2-56" dev="rgoers" type="fix" due-to="John Owen 
Atala">
+        Level.toLevel would throw an IllegalArgumentException instead of 
returning the default value.
+      </action>
+      <action issue="LOG4J2-51" dev="rgoers" type="fix" due-to="John Vasileff">
         Remove LoggerContext support for custom logger factories. All Loggers 
returned
         by LoggerContext should be compatibile and of the same type.
       </action>
-      <action issue="VFS-50" dev="rgoers" type="fix" due-to="John Vasileff">
+      <action issue="LOG4J2-50" dev="rgoers" type="fix" due-to="John Vasileff">
         Make sure all application facing log methods use their own FQCN. This 
patch
         resolves a unit test failure for the %C pattern when using the 
Category logger.
       </action>


Reply via email to