logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carn...@apache.org
Subject svn commit: r368149 [4/4] - in /logging/sandbox/log4j/formatter: ./ src/ src/changes/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/log4j/ src/main/java/org/apache/log4j/formatter/ src/test/ src/test/jav...
Date Wed, 11 Jan 2006 22:20:05 GMT
Added: logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTest.java
URL: http://svn.apache.org/viewcvs/logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTest.java?rev=368149&view=auto
==============================================================================
--- logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTest.java
(added)
+++ logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTest.java
Wed Jan 11 14:19:48 2006
@@ -0,0 +1,874 @@
+/*
+ * Copyright 1999,2006 The Apache Software Foundation.
+ * 
+ * Licensed 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.log4j.formatter;
+
+import junit.framework.TestCase;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+
+/**
+ * Unit test for LogSF.
+ */
+public class LogSFTest extends TestCase {
+	/**
+	 * Logger.
+	 */
+	private final Logger logger = Logger
+			.getLogger("org.apache.log4j.formatter.LogSFTest");
+
+	/**
+	 * Create the test case
+	 *
+	 * @param testName name of the test case
+	 */
+	public LogSFTest(String testName) {
+		super(testName);
+	}
+
+	/**
+	 * Post test clean up.
+	 */
+	public void tearDown() {
+		LogManager.resetConfiguration();
+	}
+
+	/**
+	 * Test LogSF.debug with null pattern.
+	 */
+	public void testDebugNullPattern() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		LogSF.debug(logger, null);
+		assertNull(capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with no-field pattern.
+	 */
+	public void testDebugNoArg() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		LogSF.debug(logger, "Hello, World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with malformed pattern.
+	 */
+	public void testDebugBadPattern() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		LogSF.debug(logger, "Hello, {.");
+		assertEquals("Hello, {.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with missing argument.
+	 */
+	public void testDebugMissingArg() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		LogSF.debug(logger, "Hello, {}World");
+		assertEquals("Hello, {}World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with string argument.
+	 */
+	public void testDebugString() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		LogSF.debug(logger, "Hello, {}", "World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with null argument.
+	 */
+	public void testDebugNull() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		LogSF.debug(logger, "Hello, {}", (Object) null);
+		assertEquals("Hello, null", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with int argument.
+	 */
+	public void testDebugInt() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		int val = 42;
+		LogSF.debug(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with byte argument.
+	 */
+	public void testDebugByte() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		byte val = 42;
+		LogSF.debug(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with short argument.
+	 */
+	public void testDebugShort() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		short val = 42;
+		LogSF.debug(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with long argument.
+	 */
+	public void testDebugLong() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		long val = 42;
+		LogSF.debug(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with char argument.
+	 */
+	public void testDebugChar() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		char val = 'C';
+		LogSF.debug(logger, "Iteration {}", val);
+		assertEquals("Iteration C", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with boolean argument.
+	 */
+	public void testDebugBoolean() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		boolean val = true;
+		LogSF.debug(logger, "Iteration {}", val);
+		assertEquals("Iteration true", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with float argument.
+	 */
+	public void testDebugFloat() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		float val = 3.14f;
+		LogSF.debug(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with single field pattern with double argument.
+	 */
+	public void testDebugDouble() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		double val = 3.14;
+		LogSF.debug(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with two arguments.
+	 */
+	public void testDebugTwoArg() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		LogSF.debug(logger, "{}, {}.", "Hello", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+
+	}
+
+	/**
+	 * Test LogSF.debug with three arguments.
+	 */
+	public void testDebugThreeArg() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		LogSF.debug(logger, "{}{} {}.", "Hello", ",", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with Object[] argument.
+	 */
+	public void testDebugArrayArg() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		Object[] args = new Object[] { "Hello", ",", "World", "." };
+		LogSF.debug(logger, "{}{} {}{}", args);
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.debug with null Object[] argument.
+	 */
+	public void testDebugNullArrayArg() {
+		LogCapture capture = new LogCapture(Level.DEBUG);
+		Object[] args = null;
+		LogSF.debug(logger, "{}{} {}{}", args);
+		assertEquals("{}{} {}{}", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with null pattern.
+	 */
+	public void testInfoNullPattern() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		LogSF.info(logger, null);
+		assertNull(capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with no-field pattern.
+	 */
+	public void testInfoNoArg() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		LogSF.info(logger, "Hello, World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with malformed pattern.
+	 */
+	public void testInfoBadPattern() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		LogSF.info(logger, "Hello, {.");
+		assertEquals("Hello, {.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with missing argument.
+	 */
+	public void testInfoMissingArg() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		LogSF.info(logger, "Hello, {}World");
+		assertEquals("Hello, {}World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with string argument.
+	 */
+	public void testInfoString() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		LogSF.info(logger, "Hello, {}", "World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with null argument.
+	 */
+	public void testInfoNull() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		LogSF.info(logger, "Hello, {}", (Object) null);
+		assertEquals("Hello, null", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with int argument.
+	 */
+	public void testInfoInt() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		int val = 42;
+		LogSF.info(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with byte argument.
+	 */
+	public void testInfoByte() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		byte val = 42;
+		LogSF.info(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with short argument.
+	 */
+	public void testInfoShort() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		short val = 42;
+		LogSF.info(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with long argument.
+	 */
+	public void testInfoLong() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		long val = 42;
+		LogSF.info(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with char argument.
+	 */
+	public void testInfoChar() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		char val = 'C';
+		LogSF.info(logger, "Iteration {}", val);
+		assertEquals("Iteration C", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with boolean argument.
+	 */
+	public void testInfoBoolean() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		boolean val = true;
+		LogSF.info(logger, "Iteration {}", val);
+		assertEquals("Iteration true", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with float argument.
+	 */
+	public void testInfoFloat() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		float val = 3.14f;
+		LogSF.info(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with single field pattern with double argument.
+	 */
+	public void testInfoDouble() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		double val = 3.14;
+		LogSF.info(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with two arguments.
+	 */
+	public void testInfoTwoArg() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		LogSF.info(logger, "{}, {}.", "Hello", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+
+	}
+
+	/**
+	 * Test LogSF.info with three arguments.
+	 */
+	public void testInfoThreeArg() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		LogSF.info(logger, "{}{} {}.", "Hello", ",", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.info with Object[] argument.
+	 */
+	public void testInfoArrayArg() {
+		LogCapture capture = new LogCapture(Level.INFO);
+		Object[] args = new Object[] { "Hello", ",", "World", "." };
+		LogSF.info(logger, "{}{} {}{}", args);
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with null pattern.
+	 */
+	public void testWarnNullPattern() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		LogSF.warn(logger, null);
+		assertNull(capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with no-field pattern.
+	 */
+	public void testWarnNoArg() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		LogSF.warn(logger, "Hello, World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with malformed pattern.
+	 */
+	public void testWarnBadPattern() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		LogSF.warn(logger, "Hello, {.");
+		assertEquals("Hello, {.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with missing argument.
+	 */
+	public void testWarnMissingArg() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		LogSF.warn(logger, "Hello, {}World");
+		assertEquals("Hello, {}World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with string argument.
+	 */
+	public void testWarnString() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		LogSF.warn(logger, "Hello, {}", "World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with null argument.
+	 */
+	public void testWarnNull() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		LogSF.warn(logger, "Hello, {}", (Object) null);
+		assertEquals("Hello, null", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with int argument.
+	 */
+	public void testWarnInt() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		int val = 42;
+		LogSF.warn(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with byte argument.
+	 */
+	public void testWarnByte() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		byte val = 42;
+		LogSF.warn(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with short argument.
+	 */
+	public void testWarnShort() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		short val = 42;
+		LogSF.warn(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with long argument.
+	 */
+	public void testWarnLong() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		long val = 42;
+		LogSF.warn(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with char argument.
+	 */
+	public void testWarnChar() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		char val = 'C';
+		LogSF.warn(logger, "Iteration {}", val);
+		assertEquals("Iteration C", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with boolean argument.
+	 */
+	public void testWarnBoolean() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		boolean val = true;
+		LogSF.warn(logger, "Iteration {}", val);
+		assertEquals("Iteration true", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with float argument.
+	 */
+	public void testWarnFloat() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		float val = 3.14f;
+		LogSF.warn(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with single field pattern with double argument.
+	 */
+	public void testWarnDouble() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		double val = 3.14;
+		LogSF.warn(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with two arguments.
+	 */
+	public void testWarnTwoArg() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		LogSF.warn(logger, "{}, {}.", "Hello", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+
+	}
+
+	/**
+	 * Test LogSF.warn with three arguments.
+	 */
+	public void testWarnThreeArg() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		LogSF.warn(logger, "{}{} {}.", "Hello", ",", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.warn with Object[] argument.
+	 */
+	public void testWarnArrayArg() {
+		LogCapture capture = new LogCapture(Level.WARN);
+		Object[] args = new Object[] { "Hello", ",", "World", "." };
+		LogSF.warn(logger, "{}{} {}{}", args);
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with null pattern.
+	 */
+	public void testErrorNullPattern() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		LogSF.error(logger, null);
+		assertNull(capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with no-field pattern.
+	 */
+	public void testErrorNoArg() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		LogSF.error(logger, "Hello, World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with malformed pattern.
+	 */
+	public void testErrorBadPattern() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		LogSF.error(logger, "Hello, {.");
+		assertEquals("Hello, {.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with missing argument.
+	 */
+	public void testErrorMissingArg() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		LogSF.error(logger, "Hello, {}World");
+		assertEquals("Hello, {}World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with string argument.
+	 */
+	public void testErrorString() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		LogSF.error(logger, "Hello, {}", "World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with null argument.
+	 */
+	public void testErrorNull() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		LogSF.error(logger, "Hello, {}", (Object) null);
+		assertEquals("Hello, null", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with int argument.
+	 */
+	public void testErrorInt() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		int val = 42;
+		LogSF.error(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with byte argument.
+	 */
+	public void testErrorByte() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		byte val = 42;
+		LogSF.error(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with short argument.
+	 */
+	public void testErrorShort() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		short val = 42;
+		LogSF.error(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with long argument.
+	 */
+	public void testErrorLong() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		long val = 42;
+		LogSF.error(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with char argument.
+	 */
+	public void testErrorChar() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		char val = 'C';
+		LogSF.error(logger, "Iteration {}", val);
+		assertEquals("Iteration C", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with boolean argument.
+	 */
+	public void testErrorBoolean() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		boolean val = true;
+		LogSF.error(logger, "Iteration {}", val);
+		assertEquals("Iteration true", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with float argument.
+	 */
+	public void testErrorFloat() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		float val = 3.14f;
+		LogSF.error(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with single field pattern with double argument.
+	 */
+	public void testErrorDouble() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		double val = 3.14;
+		LogSF.error(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with two arguments.
+	 */
+	public void testErrorTwoArg() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		LogSF.error(logger, "{}, {}.", "Hello", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+
+	}
+
+	/**
+	 * Test LogSF.error with three arguments.
+	 */
+	public void testErrorThreeArg() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		LogSF.error(logger, "{}{} {}.", "Hello", ",", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.error with Object[] argument.
+	 */
+	public void testErrorArrayArg() {
+		LogCapture capture = new LogCapture(Level.ERROR);
+		Object[] args = new Object[] { "Hello", ",", "World", "." };
+		LogSF.error(logger, "{}{} {}{}", args);
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with null pattern.
+	 */
+	public void testFatalNullPattern() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		LogSF.fatal(logger, null);
+		assertNull(capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with no-field pattern.
+	 */
+	public void testFatalNoArg() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		LogSF.fatal(logger, "Hello, World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with malformed pattern.
+	 */
+	public void testFatalBadPattern() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		LogSF.fatal(logger, "Hello, {.");
+		assertEquals("Hello, {.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with missing argument.
+	 */
+	public void testFatalMissingArg() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		LogSF.fatal(logger, "Hello, {}World");
+		assertEquals("Hello, {}World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with string argument.
+	 */
+	public void testFatalString() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		LogSF.fatal(logger, "Hello, {}", "World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with null argument.
+	 */
+	public void testFatalNull() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		LogSF.fatal(logger, "Hello, {}", (Object) null);
+		assertEquals("Hello, null", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with int argument.
+	 */
+	public void testFatalInt() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		int val = 42;
+		LogSF.fatal(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with byte argument.
+	 */
+	public void testFatalByte() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		byte val = 42;
+		LogSF.fatal(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with short argument.
+	 */
+	public void testFatalShort() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		short val = 42;
+		LogSF.fatal(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with long argument.
+	 */
+	public void testFatalLong() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		long val = 42;
+		LogSF.fatal(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with char argument.
+	 */
+	public void testFatalChar() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		char val = 'C';
+		LogSF.fatal(logger, "Iteration {}", val);
+		assertEquals("Iteration C", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with boolean argument.
+	 */
+	public void testFatalBoolean() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		boolean val = true;
+		LogSF.fatal(logger, "Iteration {}", val);
+		assertEquals("Iteration true", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with float argument.
+	 */
+	public void testFatalFloat() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		float val = 3.14f;
+		LogSF.fatal(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with single field pattern with double argument.
+	 */
+	public void testFatalDouble() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		double val = 3.14;
+		LogSF.fatal(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with two arguments.
+	 */
+	public void testFatalTwoArg() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		LogSF.fatal(logger, "{}, {}.", "Hello", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+
+	}
+
+	/**
+	 * Test LogSF.fatal with three arguments.
+	 */
+	public void testFatalThreeArg() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		LogSF.fatal(logger, "{}{} {}.", "Hello", ",", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.fatal with Object[] argument.
+	 */
+	public void testFatalArrayArg() {
+		LogCapture capture = new LogCapture(Level.FATAL);
+		Object[] args = new Object[] { "Hello", ",", "World", "." };
+		LogSF.fatal(logger, "{}{} {}{}", args);
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+}

Propchange: logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTest.java
------------------------------------------------------------------------------
    svn:executable = 

Added: logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTraceTest.java
URL: http://svn.apache.org/viewcvs/logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTraceTest.java?rev=368149&view=auto
==============================================================================
--- logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTraceTest.java
(added)
+++ logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTraceTest.java
Wed Jan 11 14:19:48 2006
@@ -0,0 +1,240 @@
+/*
+ * Copyright 1999,2006 The Apache Software Foundation.
+ * 
+ * Licensed 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.log4j.formatter;
+
+import junit.framework.TestCase;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+
+/**
+ * Unit test for LogSF.
+ */
+public class LogSFTraceTest extends TestCase {
+	/**
+	 * Logger.
+	 */
+	private final Logger logger = Logger
+			.getLogger("org.apache.log4j.formatter.LogSFTest");
+
+	/**
+	 * Create the test case
+	 *
+	 * @param testName name of the test case
+	 */
+	public LogSFTraceTest(String testName) {
+		super(testName);
+	}
+
+	/**
+	 * Post test clean up.
+	 */
+	public void tearDown() {
+		LogManager.resetConfiguration();
+	}
+
+	/**
+	 * Test LogSF.trace with null pattern.
+	 */
+	public void testTraceNullPattern() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		LogSF.trace(logger, null);
+		assertNull(capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with no-field pattern.
+	 */
+	public void testTraceNoArg() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		LogSF.trace(logger, "Hello, World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with malformed pattern.
+	 */
+	public void testTraceBadPattern() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		LogSF.trace(logger, "Hello, {.");
+		assertEquals("Hello, {.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with missing argument.
+	 */
+	public void testTraceMissingArg() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		LogSF.trace(logger, "Hello, {}World");
+		assertEquals("Hello, {}World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with string argument.
+	 */
+	public void testTraceString() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		LogSF.trace(logger, "Hello, {}", "World");
+		assertEquals("Hello, World", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with null argument.
+	 */
+	public void testTraceNull() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		LogSF.trace(logger, "Hello, {}", (Object) null);
+		assertEquals("Hello, null", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with int argument.
+	 */
+	public void testTraceInt() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		int val = 42;
+		LogSF.trace(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with byte argument.
+	 */
+	public void testTraceByte() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		byte val = 42;
+		LogSF.trace(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with short argument.
+	 */
+	public void testTraceShort() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		short val = 42;
+		LogSF.trace(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with long argument.
+	 */
+	public void testTraceLong() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		long val = 42;
+		LogSF.trace(logger, "Iteration {}", val);
+		assertEquals("Iteration 42", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with char argument.
+	 */
+	public void testTraceChar() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		char val = 'C';
+		LogSF.trace(logger, "Iteration {}", val);
+		assertEquals("Iteration C", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with boolean argument.
+	 */
+	public void testTraceBoolean() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		boolean val = true;
+		LogSF.trace(logger, "Iteration {}", val);
+		assertEquals("Iteration true", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with float argument.
+	 */
+	public void testTraceFloat() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		float val = 3.14f;
+		LogSF.trace(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with single field pattern with double argument.
+	 */
+	public void testTraceDouble() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		double val = 3.14;
+		LogSF.trace(logger, "Iteration {}", val);
+		assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with two arguments.
+	 */
+	public void testTraceTwoArg() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		LogSF.trace(logger, "{}, {}.", "Hello", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+
+	}
+
+	/**
+	 * Test LogSF.trace with three arguments.
+	 */
+	public void testTraceThreeArg() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		LogSF.trace(logger, "{}{} {}.", "Hello", ",", "World");
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with Object[] argument.
+	 */
+	public void testTraceArrayArg() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		Object[] args = new Object[] { "Hello", ",", "World", "." };
+		LogSF.trace(logger, "{}{} {}{}", args);
+		assertEquals("Hello, World.", capture.getMessage());
+	}
+
+	/**
+	 * Test LogSF.trace with null Object[] argument.
+	 */
+	public void testTraceNullArrayArg() {
+		LogCapture capture = new LogCapture(Level.TRACE);
+		logger.setLevel(Level.TRACE);
+		Object[] args = null;
+		LogSF.trace(logger, "{}{} {}{}", args);
+		assertEquals("{}{} {}{}", capture.getMessage());
+	}
+
+}

Propchange: logging/sandbox/log4j/formatter/src/test/java/org/apache/log4j/formatter/LogSFTraceTest.java
------------------------------------------------------------------------------
    svn:executable = 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message