You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2016/02/20 05:29:09 UTC
logging-log4j2 git commit: Use parameterized unit tests.
Repository: logging-log4j2
Updated Branches:
refs/heads/master a8c8fa727 -> efaa8fd92
Use parameterized unit tests.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/efaa8fd9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/efaa8fd9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/efaa8fd9
Branch: refs/heads/master
Commit: efaa8fd92f8853fe3a8c3d2b246b071f93a3d824
Parents: a8c8fa7
Author: Matt Sicker <bo...@gmail.com>
Authored: Fri Feb 19 22:29:29 2016 -0600
Committer: Matt Sicker <bo...@gmail.com>
Committed: Fri Feb 19 22:29:29 2016 -0600
----------------------------------------------------------------------
.../logging/log4j/taglib/TagUtilsLevelTest.java | 61 ++++++++++
.../logging/log4j/taglib/TagUtilsScopeTest.java | 56 +++++++++
.../logging/log4j/taglib/TagUtilsTest.java | 114 -------------------
3 files changed, 117 insertions(+), 114 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/efaa8fd9/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsLevelTest.java
----------------------------------------------------------------------
diff --git a/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsLevelTest.java b/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsLevelTest.java
new file mode 100644
index 0000000..4effcc3
--- /dev/null
+++ b/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsLevelTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.taglib;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.junit.Assert.*;
+
+@RunWith(Parameterized.class)
+public class TagUtilsLevelTest {
+
+ private final Level level;
+ private final String levelName;
+
+ public TagUtilsLevelTest(final Level level, final String levelName) {
+ this.level = level;
+ this.levelName = levelName;
+ }
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> data() {
+ final Collection<Object[]> params = new ArrayList<>();
+ // this is perhaps the laziest way to test all the known levels
+ for (final Level level : Level.values()) {
+ params.add(new Object[]{level, level.name().toLowerCase()});
+ }
+ return params;
+ }
+
+ @Test
+ public void testResolveLevelName() throws Exception {
+ assertEquals(level, TagUtils.resolveLevel(levelName));
+ }
+
+ @Test
+ public void testResolveLevelEnum() throws Exception {
+ assertEquals(level, TagUtils.resolveLevel(level));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/efaa8fd9/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsScopeTest.java
----------------------------------------------------------------------
diff --git a/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsScopeTest.java b/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsScopeTest.java
new file mode 100644
index 0000000..f152c9c
--- /dev/null
+++ b/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsScopeTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.taglib;
+
+import java.util.Arrays;
+import java.util.Collection;
+import javax.servlet.jsp.PageContext;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.junit.Assert.*;
+
+@RunWith(Parameterized.class)
+public class TagUtilsScopeTest {
+
+ private final int scope;
+ private final String scopeName;
+
+ public TagUtilsScopeTest(final int scope, final String scopeName) {
+ this.scope = scope;
+ this.scopeName = scopeName;
+ }
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {PageContext.APPLICATION_SCOPE, "application"},
+ {PageContext.PAGE_SCOPE, "page"},
+ {PageContext.REQUEST_SCOPE, "request"},
+ {PageContext.SESSION_SCOPE, "session"},
+ {PageContext.PAGE_SCOPE, "insert random garbage here"}
+ });
+ }
+
+ @Test
+ public void testGetScope() throws Exception {
+ assertEquals("The scope is not correct.", scope, TagUtils.getScope(scopeName));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/efaa8fd9/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsTest.java
----------------------------------------------------------------------
diff --git a/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsTest.java b/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsTest.java
deleted file mode 100644
index 4f072dc..0000000
--- a/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/TagUtilsTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.taglib;
-
-import javax.servlet.jsp.PageContext;
-
-import org.apache.logging.log4j.Level;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public class TagUtilsTest {
- @Test
- public void testGetScopeApplication() {
- assertEquals("The scope is not correct.", PageContext.APPLICATION_SCOPE, TagUtils.getScope("application"));
- }
-
- @Test
- public void testGetScopePage() {
- assertEquals("The scope is not correct.", PageContext.PAGE_SCOPE, TagUtils.getScope("page"));
- }
-
- @Test
- public void testGetScopeRequest() {
- assertEquals("The scope is not correct.", PageContext.REQUEST_SCOPE, TagUtils.getScope("request"));
- }
-
- @Test
- public void testGetScopeSession() {
- assertEquals("The scope is not correct.", PageContext.SESSION_SCOPE, TagUtils.getScope("session"));
- }
-
- @Test
- public void testGetScopeUnknown() {
- assertEquals("The scope is not correct.", PageContext.PAGE_SCOPE, TagUtils.getScope("oeu1209"));
- }
-
- @Test
- public void testResolveLevelDebug01() {
- assertEquals("The value is not correct.", Level.DEBUG, TagUtils.resolveLevel("debug"));
- }
-
- @Test
- public void testResolveLevelDebug02() {
- assertEquals("The value is not correct.", Level.DEBUG, TagUtils.resolveLevel(Level.DEBUG));
- }
-
- @Test
- public void testResolveLevelError01() {
- assertEquals("The value is not correct.", Level.ERROR, TagUtils.resolveLevel("error"));
- }
-
- @Test
- public void testResolveLevelError02() {
- assertEquals("The value is not correct.", Level.ERROR, TagUtils.resolveLevel(Level.ERROR));
- }
-
- @Test
- public void testResolveLevelFatal01() {
- assertEquals("The value is not correct.", Level.FATAL, TagUtils.resolveLevel("fatal"));
- }
-
- @Test
- public void testResolveLevelFatal02() {
- assertEquals("The value is not correct.", Level.FATAL, TagUtils.resolveLevel(Level.FATAL));
- }
-
- @Test
- public void testResolveLevelInfo01() {
- assertEquals("The value is not correct.", Level.INFO, TagUtils.resolveLevel("info"));
- }
-
- @Test
- public void testResolveLevelInfo02() {
- assertEquals("The value is not correct.", Level.INFO, TagUtils.resolveLevel(Level.INFO));
- }
-
- @Test
- public void testResolveLevelTrace01() {
- assertEquals("The value is not correct.", Level.TRACE, TagUtils.resolveLevel("trace"));
- }
-
- @Test
- public void testResolveLevelTrace02() {
- assertEquals("The value is not correct.", Level.TRACE, TagUtils.resolveLevel(Level.TRACE));
- }
-
- @Test
- public void testResolveLevelWarn01() {
- assertEquals("The value is not correct.", Level.WARN, TagUtils.resolveLevel("warn"));
- }
-
- @Test
- public void testResolveLevelWarn02() {
- assertEquals("The value is not correct.", Level.WARN, TagUtils.resolveLevel(Level.WARN));
- }
-}