You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ca...@apache.org on 2007/04/27 06:27:10 UTC
svn commit: r532960 - in /logging/sandbox/log4j/logsf: ./
src/main/java/org/apache/log4j/ src/main/java/org/apache/log4j/formatter/
src/main/resources/META-INF/ src/test/java/org/apache/log4j/
src/test/resources/org/apache/log4j/
Author: carnold
Date: Thu Apr 26 21:27:09 2007
New Revision: 532960
URL: http://svn.apache.org/viewvc?view=rev&rev=532960
Log:
LogSF: log4j 1.3/SLF4J parameterized logging
Added:
logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogSF.java
- copied, changed from r532950, logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogMF.java
logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogSF.java
- copied, changed from r532950, logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogMF.java
logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogSFPatterns.properties
- copied, changed from r532950, logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogMFPatterns.properties
Removed:
logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogMF.java
logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/formatter/
logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogMF.java
logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogMFPatterns.properties
Modified:
logging/sandbox/log4j/logsf/NOTICE
logging/sandbox/log4j/logsf/build.xml
logging/sandbox/log4j/logsf/pom.xml
logging/sandbox/log4j/logsf/src/main/resources/META-INF/NOTICE
Modified: logging/sandbox/log4j/logsf/NOTICE
URL: http://svn.apache.org/viewvc/logging/sandbox/log4j/logsf/NOTICE?view=diff&rev=532960&r1=532959&r2=532960
==============================================================================
--- logging/sandbox/log4j/logsf/NOTICE (original)
+++ logging/sandbox/log4j/logsf/NOTICE Thu Apr 26 21:27:09 2007
@@ -1,4 +1,4 @@
-Apache LogMF Companion for log4j 1.2
+Apache LogSF Companion for log4j 1.2
Copyright 2007 The Apache Software Foundation
This product includes software developed at
Modified: logging/sandbox/log4j/logsf/build.xml
URL: http://svn.apache.org/viewvc/logging/sandbox/log4j/logsf/build.xml?view=diff&rev=532960&r1=532959&r2=532960
==============================================================================
--- logging/sandbox/log4j/logsf/build.xml (original)
+++ logging/sandbox/log4j/logsf/build.xml Thu Apr 26 21:27:09 2007
@@ -27,7 +27,7 @@
<property file="build.properties"/>
<!-- project details -->
- <property name="project.name" value="apache-log4j-logmf"/>
+ <property name="project.name" value="apache-log4j-logsf"/>
<property name="project.title" value="Apache LogMF Companion for log4j 1.2."/>
<property name="project.version" value="0.1-SNAPSHOT"/>
<property name="project.jar" value="${project.name}-${project.version}.jar"/>
@@ -36,7 +36,7 @@
<property name="m2_repo" location="${user.home}/.m2/repository"/>
<!-- Versions for dependencies -->
- <property name="log4j.version" value="1.2.14"/>
+ <property name="log4j.version" value="1.2.8"/>
<property name="junit.version" value="3.8.1"/>
<!-- Dependency locations - assumed to be in Maven 2 repository -->
Modified: logging/sandbox/log4j/logsf/pom.xml
URL: http://svn.apache.org/viewvc/logging/sandbox/log4j/logsf/pom.xml?view=diff&rev=532960&r1=532959&r2=532960
==============================================================================
--- logging/sandbox/log4j/logsf/pom.xml (original)
+++ logging/sandbox/log4j/logsf/pom.xml Thu Apr 26 21:27:09 2007
@@ -19,19 +19,20 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>log4j</groupId>
- <artifactId>apache-log4j-logmf</artifactId>
+ <artifactId>apache-log4j-logsf</artifactId>
<packaging>jar</packaging>
<version>0.1-SNAPSHOT</version>
- <name>Apache LogMF Companion for log4j 1.2.</name>
- <description>This companion provides parameterized logging using the java.text.MessageFormat.</description>
- <url>http://logging.apache.org/log4j/companions/logmf</url>
+ <name>Apache LogSF Companion for log4j 1.2.</name>
+ <description>This companion provides parameterized logging using a log4j 1.3 style message formatter
+ to simplify porting of code that used the parameterized logging facility in log4j 1.3 or SLF4J.</description>
+ <url>http://logging.apache.org/log4j/companions/logsf</url>
<issueManagement>
<system>Bugzilla</system>
<url>http://issues.apache.org/bugzilla/</url>
</issueManagement>
<ciManagement>
<system>Gump</system>
- <url>http://vmgump.apache.org/gump/public/logging-log4j-logmf/logging-log4j-logmf/index.html</url>
+ <url>http://vmgump.apache.org/gump/public/logging-log4j-logsf/logging-log4j-logsf/index.html</url>
</ciManagement>
<mailingLists>
<mailingList>
@@ -73,8 +74,8 @@
</license>
</licenses>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/logging/sandbox/log4j/logmf</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/logging/sandbox/log4j/logmf</developerConnection>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/logging/sandbox/log4j/logsf</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/logging/sandbox/log4j/logsf</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/logging/sandbox/log4j/logmf</url>
</scm>
<organization>
@@ -179,7 +180,7 @@
<distributionManagement>
<site>
<id>apache.website</id>
- <url>scp://people.apache.org/home/carnold/public_html/log4j/companions/logmf</url>
+ <url>scp://people.apache.org/home/carnold/public_html/log4j/companions/logsf</url>
</site>
</distributionManagement>
Copied: logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogSF.java (from r532950, logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogMF.java)
URL: http://svn.apache.org/viewvc/logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogSF.java?view=diff&rev=532960&p1=logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogMF.java&r1=532950&p2=logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogSF.java&r2=532960
==============================================================================
--- logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogMF.java (original)
+++ logging/sandbox/log4j/logsf/src/main/java/org/apache/log4j/LogSF.java Thu Apr 26 21:27:09 2007
@@ -18,10 +18,6 @@
import org.apache.log4j.spi.LoggingEvent;
-import java.text.DateFormat;
-import java.text.MessageFormat;
-import java.text.NumberFormat;
-import java.util.Date;
import java.util.ResourceBundle;
@@ -30,7 +26,7 @@
* format log messages using java.text.MessageFormat.
*
*/
-public final class LogMF {
+public final class LogSF {
/**
* Trace level.
*/
@@ -39,7 +35,7 @@
* private constructor.
*
*/
- private LogMF() {
+ private LogSF() {
}
@@ -198,79 +194,31 @@
};
}
- /**
- * Formats arguments using a minimal subset
- * of MessageFormat syntax.
- * @param pattern pattern, may not be null.
- * @param arg0 argument, may be null.
- * @return Message string or null if pattern
- * is not supported.
- */
- private static String subsetFormat(final String pattern,
- final Object arg0) {
- if (pattern != null) {
- //
- // find position of first brace
- // if none then format is a literal
- int bracePos = pattern.indexOf("{");
-
- //
- // if the first format is {0}
- // and there are no other format specifiers
- // and no quotes then substitute for {0}
- if (bracePos != -1) {
- if ((pattern.indexOf("{0}", bracePos) == bracePos)
- && (pattern.indexOf("{", bracePos + 1) == -1)
- && (pattern.indexOf("'") == -1)) {
- String replacement;
-
- if (arg0 instanceof String) {
- replacement = arg0.toString();
- } else if (arg0 instanceof Number) {
- replacement = NumberFormat.getInstance().format(arg0);
- } else if (arg0 instanceof Date) {
- replacement = DateFormat.getDateTimeInstance(
- DateFormat.SHORT,
- DateFormat.SHORT).format(arg0);
- } else {
- replacement = String.valueOf(arg0);
- }
-
- final StringBuffer buf = new StringBuffer(pattern);
- buf.replace(bracePos,
- bracePos + "{0}".length(), replacement);
-
- return buf.toString();
- }
- } else {
- //
- // pattern is a literal with no braces
- // and not quotes, return pattern.
- if (pattern.indexOf("'") == -1) {
- return pattern;
- }
- }
- }
-
- return null;
- }
/**
- * Formats arguments using MessageFormat.
- * @param pattern pattern, may be malformed or null.
- * @param arguments arguments, may be null or mismatched.
- * @return Message string or null
+ * Formats arguments using SLF4J-like formatter.
+ * @param pattern pattern, may be malformed.
+ * @param arguments arguments.
+ * @return Message string
*/
private static String format(final String pattern,
final Object[] arguments) {
- if (pattern == null) {
- return null;
- }
- try {
- return MessageFormat.format(pattern, arguments);
- } catch (IllegalArgumentException ex) {
+ if (arguments == null || pattern == null) {
return pattern;
}
+ StringBuffer buf = new StringBuffer(pattern);
+ int index = 0;
+ int pos = buf.indexOf("{");
+ while (pos >= 0 && pos < buf.length() - 1 && index < arguments.length) {
+ if (buf.charAt(pos + 1) == '}') {
+ String subst = String.valueOf(arguments[index++]);
+ buf.replace(pos, pos + 2, subst);
+ pos += subst.length();
+ } else {
+ pos = buf.indexOf("{", pos + 1);
+ }
+ }
+ return buf.toString();
}
/**
@@ -280,13 +228,7 @@
* @return Message string
*/
private static String format(final String pattern, final Object arg0) {
- String msg = subsetFormat(pattern, arg0);
-
- if (msg == null) {
- msg = format(pattern, toArray(arg0));
- }
-
- return msg;
+ return format(pattern, toArray(arg0));
}
/**
@@ -320,7 +262,7 @@
/**
* Fully Qualified Class Name of this class.
*/
- private static final String FQCN = LogMF.class.getName();
+ private static final String FQCN = LogSF.class.getName();
/**
* Equivalent of Logger.forcedLog.
Modified: logging/sandbox/log4j/logsf/src/main/resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/logging/sandbox/log4j/logsf/src/main/resources/META-INF/NOTICE?view=diff&rev=532960&r1=532959&r2=532960
==============================================================================
--- logging/sandbox/log4j/logsf/src/main/resources/META-INF/NOTICE (original)
+++ logging/sandbox/log4j/logsf/src/main/resources/META-INF/NOTICE Thu Apr 26 21:27:09 2007
@@ -1,4 +1,4 @@
-Apache LogMF Companion for log4j 1.2
+Apache LogSF Companion for log4j 1.2
Copyright 2007 The Apache Software Foundation
This product includes software developed at
Copied: logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogSF.java (from r532950, logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogMF.java)
URL: http://svn.apache.org/viewvc/logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogSF.java?view=diff&rev=532960&p1=logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogMF.java&r1=532950&p2=logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogSF.java&r2=532960
==============================================================================
--- logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogMF.java (original)
+++ logging/sandbox/log4j/logsf/src/test/java/org/apache/log4j/TestLogSF.java Thu Apr 26 21:27:09 2007
@@ -26,7 +26,7 @@
/**
* Unit test for LogMF.
*/
-public class TestLogMF extends TestCase {
+public class TestLogSF extends TestCase {
/**
* Trace level.
*/
@@ -56,7 +56,7 @@
*
* @param testName name of the test case
*/
- public TestLogMF(String testName) {
+ public TestLogSF(String testName) {
super(testName);
}
@@ -69,7 +69,7 @@
}
/**
- * Test class name when logging through LogMF.
+ * Test class name when logging through LogSF.
*/
public void testClassName() {
CharArrayWriter writer = new CharArrayWriter();
@@ -77,965 +77,904 @@
WriterAppender appender = new WriterAppender(layout, writer);
appender.activateOptions();
Logger.getRootLogger().addAppender(appender);
- LogMF.debug(logger, null, Math.PI);
- assertEquals(TestLogMF.class.getName(), writer.toString());
+ LogSF.debug(logger, null, Math.PI);
+ assertEquals(TestLogSF.class.getName(), writer.toString());
}
+
+
/**
- * Test LogMF.trace with null pattern.
+ * Test LogSF.trace with null pattern.
*/
public void testTraceNullPattern() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
- LogMF.trace(logger, null, Math.PI);
+ LogSF.trace(logger, null, Math.PI);
assertNull(capture.getMessage());
}
/**
- * Test LogMF.trace with no-field pattern.
+ * Test LogSF.trace with no-field pattern.
*/
public void testTraceNoArg() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
- LogMF.trace(logger, "Hello, World", Math.PI);
+ LogSF.trace(logger, "Hello, World", Math.PI);
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.trace with malformed pattern.
+ * Test LogSF.trace with malformed pattern.
*/
public void testTraceBadPattern() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
- LogMF.trace(logger, "Hello, {.", Math.PI);
+ LogSF.trace(logger, "Hello, {.", Math.PI);
assertEquals("Hello, {.", capture.getMessage());
}
/**
- * Test LogMF.trace with missing argument.
+ * Test LogSF.trace with missing argument.
*/
public void testTraceMissingArg() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
- LogMF.trace(logger, "Hello, {0}World", new Object[0]);
- assertEquals("Hello, {0}World", capture.getMessage());
+ LogSF.trace(logger, "Hello, {}World", new Object[0]);
+ assertEquals("Hello, {}World", capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with string argument.
+ * Test LogSF.trace with single field pattern with string argument.
*/
public void testTraceString() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
- LogMF.trace(logger, "Hello, {0}", "World");
+ LogSF.trace(logger, "Hello, {}", "World");
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with null argument.
+ * Test LogSF.trace with single field pattern with null argument.
*/
public void testTraceNull() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
- LogMF.trace(logger, "Hello, {0}", (Object) null);
+ LogSF.trace(logger, "Hello, {}", (Object) null);
assertEquals("Hello, null", capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with int argument.
+ * Test LogSF.trace with single field pattern with int argument.
*/
public void testTraceInt() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
int val = 42;
- LogMF.trace(logger, "Iteration {0}", val);
+ LogSF.trace(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with byte argument.
+ * Test LogSF.trace with single field pattern with byte argument.
*/
public void testTraceByte() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
byte val = 42;
- LogMF.trace(logger, "Iteration {0}", val);
+ LogSF.trace(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with short argument.
+ * Test LogSF.trace with single field pattern with short argument.
*/
public void testTraceShort() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
short val = 42;
- LogMF.trace(logger, "Iteration {0}", val);
+ LogSF.trace(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with long argument.
+ * Test LogSF.trace with single field pattern with long argument.
*/
public void testTraceLong() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
long val = 42;
- LogMF.trace(logger, "Iteration {0}", val);
+ LogSF.trace(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with char argument.
+ * Test LogSF.trace with single field pattern with char argument.
*/
public void testTraceChar() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
char val = 'C';
- LogMF.trace(logger, "Iteration {0}", val);
+ LogSF.trace(logger, "Iteration {}", val);
assertEquals("Iteration C", capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with boolean argument.
+ * Test LogSF.trace with single field pattern with boolean argument.
*/
public void testTraceBoolean() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
boolean val = true;
- LogMF.trace(logger, "Iteration {0}", val);
+ LogSF.trace(logger, "Iteration {}", val);
assertEquals("Iteration true", capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with float argument.
+ * Test LogSF.trace with single field pattern with float argument.
*/
public void testTraceFloat() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
float val = 3.14f;
- LogMF.trace(logger, "Iteration {0}", val);
- assertEquals("Iteration 3.14", capture.getMessage());
+ LogSF.trace(logger, "Iteration {}", val);
+ assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
}
/**
- * Test LogMF.trace with single field pattern with double argument.
+ * Test LogSF.trace with single field pattern with double argument.
*/
public void testTraceDouble() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
double val = 3.14;
- LogMF.trace(logger, "Iteration {0}", val);
- assertEquals("Iteration 3.14", capture.getMessage());
+ LogSF.trace(logger, "Iteration {}", val);
+ assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
}
/**
- * Test LogMF.trace with two arguments.
+ * Test LogSF.trace with two arguments.
*/
public void testTraceTwoArg() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
- LogMF.trace(logger, "{1}, {0}.", "World", "Hello");
+ LogSF.trace(logger, "{}, {}.", "Hello", "World");
assertEquals("Hello, World.", capture.getMessage());
+
}
/**
- * Test LogMF.trace with three arguments.
+ * Test LogSF.trace with three arguments.
*/
public void testTraceThreeArg() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
- LogMF.trace(logger, "{1}{2} {0}.", "World", "Hello", ",");
+ LogSF.trace(logger, "{}{} {}.", "Hello", ",", "World");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.trace with four arguments.
+ * Test LogSF.trace with Object[] argument.
*/
public void testTraceFourArg() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
- LogMF.trace(logger, "{1}{2} {0}{3}", "World", "Hello", ",", ".");
+ LogSF.trace(logger, "{}{} {}{}", "Hello", ",", "World", ".");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.trace with Object[] argument.
+ * Test LogSF.trace with Object[] argument.
*/
public void testTraceArrayArg() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
- Object[] args = new Object[] { "World", "Hello", ",", "." };
- LogMF.trace(logger, "{1}{2} {0}{3}", args);
+ Object[] args = new Object[] { "Hello", ",", "World", "." };
+ LogSF.trace(logger, "{}{} {}{}", args);
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.trace with null Object[] argument.
+ * Test LogSF.trace with null Object[] argument.
*/
public void testTraceNullArrayArg() {
LogCapture capture = new LogCapture(TRACE);
logger.setLevel(TRACE);
-
Object[] args = null;
- LogMF.trace(logger, "{1}{2} {0}{3}", args);
- assertEquals("{1}{2} {0}{3}", capture.getMessage());
+ LogSF.trace(logger, "{}{} {}{}", args);
+ assertEquals("{}{} {}{}", capture.getMessage());
}
+
/**
- * Test LogMF.debug with null pattern.
+ * Test LogSF.debug with null pattern.
*/
public void testDebugNullPattern() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, null, Math.PI);
- assertEquals(null, capture.getMessage());
+ LogSF.debug(logger, null, Math.PI);
+ assertNull(capture.getMessage());
}
/**
- * Test LogMF.debug with no-field pattern.
+ * Test LogSF.debug with no-field pattern.
*/
public void testDebugNoArg() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "Hello, World", Math.PI);
+ LogSF.debug(logger, "Hello, World", Math.PI);
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.debug with malformed pattern.
+ * Test LogSF.debug with malformed pattern.
*/
public void testDebugBadPattern() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "Hello, {.", Math.PI);
+ LogSF.debug(logger, "Hello, {.", Math.PI);
assertEquals("Hello, {.", capture.getMessage());
}
/**
- * Test LogMF.debug with missing argument.
+ * Test LogSF.debug with missing argument.
*/
public void testDebugMissingArg() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "Hello, {0}World", new Object[0]);
- assertEquals("Hello, {0}World", capture.getMessage());
+ LogSF.debug(logger, "Hello, {}World", new Object[0]);
+ assertEquals("Hello, {}World", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with string argument.
+ * Test LogSF.debug with single field pattern with string argument.
*/
public void testDebugString() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "Hello, {0}", "World");
+ LogSF.debug(logger, "Hello, {}", "World");
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with null argument.
+ * Test LogSF.debug with single field pattern with null argument.
*/
public void testDebugNull() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "Hello, {0}", (Object) null);
+ LogSF.debug(logger, "Hello, {}", (Object) null);
assertEquals("Hello, null", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with int argument.
+ * Test LogSF.debug with single field pattern with int argument.
*/
public void testDebugInt() {
LogCapture capture = new LogCapture(Level.DEBUG);
int val = 42;
- LogMF.debug(logger, "Iteration {0}", val);
+ LogSF.debug(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with byte argument.
+ * Test LogSF.debug with single field pattern with byte argument.
*/
public void testDebugByte() {
LogCapture capture = new LogCapture(Level.DEBUG);
byte val = 42;
- LogMF.debug(logger, "Iteration {0}", val);
+ LogSF.debug(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with short argument.
+ * Test LogSF.debug with single field pattern with short argument.
*/
public void testDebugShort() {
LogCapture capture = new LogCapture(Level.DEBUG);
short val = 42;
- LogMF.debug(logger, "Iteration {0}", val);
+ LogSF.debug(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with long argument.
+ * Test LogSF.debug with single field pattern with long argument.
*/
public void testDebugLong() {
LogCapture capture = new LogCapture(Level.DEBUG);
long val = 42;
- LogMF.debug(logger, "Iteration {0}", val);
+ LogSF.debug(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with char argument.
+ * Test LogSF.debug with single field pattern with char argument.
*/
public void testDebugChar() {
LogCapture capture = new LogCapture(Level.DEBUG);
char val = 'C';
- LogMF.debug(logger, "Iteration {0}", val);
+ LogSF.debug(logger, "Iteration {}", val);
assertEquals("Iteration C", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with boolean argument.
+ * Test LogSF.debug with single field pattern with boolean argument.
*/
public void testDebugBoolean() {
LogCapture capture = new LogCapture(Level.DEBUG);
boolean val = true;
- LogMF.debug(logger, "Iteration {0}", val);
+ LogSF.debug(logger, "Iteration {}", val);
assertEquals("Iteration true", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with float argument.
+ * Test LogSF.debug with single field pattern with float argument.
*/
public void testDebugFloat() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "Iteration {0}", (float) Math.PI);
-
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Float(Math.PI) });
- assertEquals(expected, capture.getMessage());
+ float val = 3.14f;
+ LogSF.debug(logger, "Iteration {}", val);
+ assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with double argument.
+ * Test LogSF.debug with single field pattern with double argument.
*/
public void testDebugDouble() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "Iteration {0}", Math.PI);
-
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Double(Math.PI) });
- assertEquals(expected, capture.getMessage());
+ double val = 3.14;
+ LogSF.debug(logger, "Iteration {}", val);
+ assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
}
/**
- * Test LogMF.debug with two arguments.
+ * Test LogSF.debug with two arguments.
*/
public void testDebugTwoArg() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "{1}, {0}.", "World", "Hello");
+ LogSF.debug(logger, "{}, {}.", "Hello", "World");
assertEquals("Hello, World.", capture.getMessage());
+
}
/**
- * Test LogMF.debug with three arguments.
+ * Test LogSF.debug with three arguments.
*/
public void testDebugThreeArg() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "{1}{2} {0}.", "World", "Hello", ",");
+ LogSF.debug(logger, "{}{} {}.", "Hello", ",", "World");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.debug with four arguments.
+ * Test LogSF.debug with four arguments.
*/
public void testDebugFourArg() {
LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "{1}{2} {0}{3}", "World", "Hello", ",", ".");
+ LogSF.debug(logger, "{}{} {}{}", "Hello", ",", "World", ".");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.debug with Object[] argument.
+ * Test LogSF.debug with Object[] argument.
*/
public void testDebugArrayArg() {
LogCapture capture = new LogCapture(Level.DEBUG);
- Object[] args = new Object[] { "World", "Hello", ",", "." };
- LogMF.debug(logger, "{1}{2} {0}{3}", args);
+ Object[] args = new Object[] { "Hello", ",", "World", "." };
+ LogSF.debug(logger, "{}{} {}{}", args);
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with double argument.
- */
- public void testDebugDate() {
- LogCapture capture = new LogCapture(Level.DEBUG);
- Date epoch = new Date(0);
- LogMF.debug(logger, "Iteration {0}", epoch);
-
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { epoch });
- assertEquals(expected, capture.getMessage());
- }
-
- /**
- * Test LogMF.debug with null Object[] argument.
+ * Test LogSF.debug with null Object[] argument.
*/
public void testDebugNullArrayArg() {
LogCapture capture = new LogCapture(Level.DEBUG);
Object[] args = null;
- LogMF.debug(logger, "{1}{2} {0}{3}", args);
- assertEquals("{1}{2} {0}{3}", capture.getMessage());
- }
-
- public void testDebugPercent() {
- LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "{0, number, percent}", Math.PI);
-
- String expected = java.text.MessageFormat.format("{0, number, percent}",
- new Object[] { new Double(Math.PI) });
- assertEquals(expected, capture.getMessage());
- }
-
- public void testDebugFullPrecisionAndPercent() {
- LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "{0}{0, number, percent}", Math.PI);
-
- String expected = java.text.MessageFormat.format("{0}{0, number, percent}",
- new Object[] { new Double(Math.PI) });
- assertEquals(expected, capture.getMessage());
- }
-
- public void testDebugQuoted() {
- LogCapture capture = new LogCapture(Level.DEBUG);
- LogMF.debug(logger, "'{0}'", "World");
- assertEquals("{0}", capture.getMessage());
+ LogSF.debug(logger, "{}{} {}{}", args);
+ assertEquals("{}{} {}{}", capture.getMessage());
}
/**
- * Test LogMF.info with null pattern.
+ * Test LogSF.info with null pattern.
*/
public void testInfoNullPattern() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, null, Math.PI);
+ LogSF.info(logger, null, Math.PI);
assertNull(capture.getMessage());
}
/**
- * Test LogMF.info with no-field pattern.
+ * Test LogSF.info with no-field pattern.
*/
public void testInfoNoArg() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "Hello, World", Math.PI);
+ LogSF.info(logger, "Hello, World", Math.PI);
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.info with malformed pattern.
+ * Test LogSF.info with malformed pattern.
*/
public void testInfoBadPattern() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "Hello, {.", Math.PI);
+ LogSF.info(logger, "Hello, {.", Math.PI);
assertEquals("Hello, {.", capture.getMessage());
}
/**
- * Test LogMF.info with missing argument.
+ * Test LogSF.info with missing argument.
*/
public void testInfoMissingArg() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "Hello, {0}World", new Object[0]);
- assertEquals("Hello, {0}World", capture.getMessage());
+ LogSF.info(logger, "Hello, {}World", new Object[0]);
+ assertEquals("Hello, {}World", capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with string argument.
+ * Test LogSF.info with single field pattern with string argument.
*/
public void testInfoString() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "Hello, {0}", "World");
+ LogSF.info(logger, "Hello, {}", "World");
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with null argument.
+ * Test LogSF.info with single field pattern with null argument.
*/
public void testInfoNull() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "Hello, {0}", (Object) null);
+ LogSF.info(logger, "Hello, {}", (Object) null);
assertEquals("Hello, null", capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with int argument.
+ * Test LogSF.info with single field pattern with int argument.
*/
public void testInfoInt() {
LogCapture capture = new LogCapture(Level.INFO);
int val = 42;
- LogMF.info(logger, "Iteration {0}", val);
+ LogSF.info(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with byte argument.
+ * Test LogSF.info with single field pattern with byte argument.
*/
public void testInfoByte() {
LogCapture capture = new LogCapture(Level.INFO);
byte val = 42;
- LogMF.info(logger, "Iteration {0}", val);
+ LogSF.info(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with short argument.
+ * Test LogSF.info with single field pattern with short argument.
*/
public void testInfoShort() {
LogCapture capture = new LogCapture(Level.INFO);
short val = 42;
- LogMF.info(logger, "Iteration {0}", val);
+ LogSF.info(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with long argument.
+ * Test LogSF.info with single field pattern with long argument.
*/
public void testInfoLong() {
LogCapture capture = new LogCapture(Level.INFO);
long val = 42;
- LogMF.info(logger, "Iteration {0}", val);
+ LogSF.info(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with char argument.
+ * Test LogSF.info with single field pattern with char argument.
*/
public void testInfoChar() {
LogCapture capture = new LogCapture(Level.INFO);
char val = 'C';
- LogMF.info(logger, "Iteration {0}", val);
+ LogSF.info(logger, "Iteration {}", val);
assertEquals("Iteration C", capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with boolean argument.
+ * Test LogSF.info with single field pattern with boolean argument.
*/
public void testInfoBoolean() {
LogCapture capture = new LogCapture(Level.INFO);
boolean val = true;
- LogMF.info(logger, "Iteration {0}", val);
+ LogSF.info(logger, "Iteration {}", val);
assertEquals("Iteration true", capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with float argument.
+ * Test LogSF.info with single field pattern with float argument.
*/
public void testInfoFloat() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "Iteration {0}", (float) Math.PI);
-
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Float(Math.PI) });
- assertEquals(expected, capture.getMessage());
+ float val = 3.14f;
+ LogSF.info(logger, "Iteration {}", val);
+ assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
}
/**
- * Test LogMF.info with single field pattern with double argument.
+ * Test LogSF.info with single field pattern with double argument.
*/
public void testInfoDouble() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "Iteration {0}", Math.PI);
-
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Double(Math.PI) });
- assertEquals(expected, capture.getMessage());
+ double val = 3.14;
+ LogSF.info(logger, "Iteration {}", val);
+ assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
}
/**
- * Test LogMF.info with two arguments.
+ * Test LogSF.info with two arguments.
*/
public void testInfoTwoArg() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "{1}, {0}.", "World", "Hello");
+ LogSF.info(logger, "{}, {}.", "Hello", "World");
assertEquals("Hello, World.", capture.getMessage());
- }
- /**
- * Test LogMF.info with three arguments.
- */
- public void testInfoThreeArg() {
- LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "{1}{2} {0}.", "World", "Hello", ",");
- assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.info with four arguments.
+ * Test LogSF.info with three arguments.
*/
- public void testInfoFourArg() {
+ public void testInfoThreeArg() {
LogCapture capture = new LogCapture(Level.INFO);
- LogMF.info(logger, "{1}{2} {0}{3}", "World", "Hello", ",", ".");
+ LogSF.info(logger, "{}{} {}.", "Hello", ",", "World");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.info with Object[] argument.
+ * Test LogSF.info with Object[] argument.
*/
public void testInfoArrayArg() {
LogCapture capture = new LogCapture(Level.INFO);
- Object[] args = new Object[] { "World", "Hello", ",", "." };
- LogMF.info(logger, "{1}{2} {0}{3}", args);
+ Object[] args = new Object[] { "Hello", ",", "World", "." };
+ LogSF.info(logger, "{}{} {}{}", args);
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.warn with null pattern.
+ * Test LogSF.warn with null pattern.
*/
public void testWarnNullPattern() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, null, Math.PI);
+ LogSF.warn(logger, null, Math.PI);
assertNull(capture.getMessage());
}
/**
- * Test LogMF.warn with no-field pattern.
+ * Test LogSF.warn with no-field pattern.
*/
public void testWarnNoArg() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "Hello, World", Math.PI);
+ LogSF.warn(logger, "Hello, World", Math.PI);
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.warn with malformed pattern.
+ * Test LogSF.warn with malformed pattern.
*/
public void testWarnBadPattern() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "Hello, {.", Math.PI);
+ LogSF.warn(logger, "Hello, {.", Math.PI);
assertEquals("Hello, {.", capture.getMessage());
}
/**
- * Test LogMF.warn with missing argument.
+ * Test LogSF.warn with missing argument.
*/
public void testWarnMissingArg() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "Hello, {0}World", new Object[0]);
- assertEquals("Hello, {0}World", capture.getMessage());
+ LogSF.warn(logger, "Hello, {}World", new Object[0]);
+ assertEquals("Hello, {}World", capture.getMessage());
}
/**
- * Test LogMF.warn with single field pattern with string argument.
+ * Test LogSF.warn with single field pattern with string argument.
*/
public void testWarnString() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "Hello, {0}", "World");
+ LogSF.warn(logger, "Hello, {}", "World");
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.warn with single field pattern with null argument.
+ * Test LogSF.warn with single field pattern with null argument.
*/
public void testWarnNull() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "Hello, {0}", (Object) null);
+ LogSF.warn(logger, "Hello, {}", (Object) null);
assertEquals("Hello, null", capture.getMessage());
}
/**
- * Test LogMF.warn with single field pattern with int argument.
+ * Test LogSF.warn with single field pattern with int argument.
*/
public void testWarnInt() {
LogCapture capture = new LogCapture(Level.WARN);
int val = 42;
- LogMF.warn(logger, "Iteration {0}", val);
+ LogSF.warn(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.warn with single field pattern with byte argument.
+ * Test LogSF.warn with single field pattern with byte argument.
*/
public void testWarnByte() {
LogCapture capture = new LogCapture(Level.WARN);
byte val = 42;
- LogMF.warn(logger, "Iteration {0}", val);
+ LogSF.warn(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.warn with single field pattern with short argument.
+ * Test LogSF.warn with single field pattern with short argument.
*/
public void testWarnShort() {
LogCapture capture = new LogCapture(Level.WARN);
short val = 42;
- LogMF.warn(logger, "Iteration {0}", val);
+ LogSF.warn(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.warn with single field pattern with long argument.
+ * Test LogSF.warn with single field pattern with long argument.
*/
public void testWarnLong() {
LogCapture capture = new LogCapture(Level.WARN);
long val = 42;
- LogMF.warn(logger, "Iteration {0}", val);
+ LogSF.warn(logger, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.warn with single field pattern with char argument.
+ * Test LogSF.warn with single field pattern with char argument.
*/
public void testWarnChar() {
LogCapture capture = new LogCapture(Level.WARN);
char val = 'C';
- LogMF.warn(logger, "Iteration {0}", val);
+ LogSF.warn(logger, "Iteration {}", val);
assertEquals("Iteration C", capture.getMessage());
}
/**
- * Test LogMF.warn with single field pattern with boolean argument.
+ * Test LogSF.warn with single field pattern with boolean argument.
*/
public void testWarnBoolean() {
LogCapture capture = new LogCapture(Level.WARN);
boolean val = true;
- LogMF.warn(logger, "Iteration {0}", val);
+ LogSF.warn(logger, "Iteration {}", val);
assertEquals("Iteration true", capture.getMessage());
}
/**
- * Test LogMF.warn with single field pattern with float argument.
+ * Test LogSF.warn with single field pattern with float argument.
*/
public void testWarnFloat() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "Iteration {0}", (float) Math.PI);
-
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Float(Math.PI) });
- assertEquals(expected, capture.getMessage());
+ float val = 3.14f;
+ LogSF.warn(logger, "Iteration {}", val);
+ assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
}
/**
- * Test LogMF.debug with single field pattern with double argument.
+ * Test LogSF.warn with single field pattern with double argument.
*/
public void testWarnDouble() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "Iteration {0}", Math.PI);
-
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Double(Math.PI) });
- assertEquals(expected, capture.getMessage());
+ double val = 3.14;
+ LogSF.warn(logger, "Iteration {}", val);
+ assertEquals("Iteration " + String.valueOf(val), capture.getMessage());
}
/**
- * Test LogMF.warn with two arguments.
+ * Test LogSF.warn with two arguments.
*/
public void testWarnTwoArg() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "{1}, {0}.", "World", "Hello");
+ LogSF.warn(logger, "{}, {}.", "Hello", "World");
assertEquals("Hello, World.", capture.getMessage());
+
}
/**
- * Test LogMF.warn with three arguments.
+ * Test LogSF.warn with three arguments.
*/
public void testWarnThreeArg() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "{1}{2} {0}.", "World", "Hello", ",");
+ LogSF.warn(logger, "{}{} {}.", "Hello", ",", "World");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.debug with four arguments.
+ * Test LogSF.warn with Object[] argument.
*/
public void testWarnFourArg() {
LogCapture capture = new LogCapture(Level.WARN);
- LogMF.warn(logger, "{1}{2} {0}{3}", "World", "Hello", ",", ".");
+ LogSF.warn(logger, "{}{} {}{}",
+ "Hello", ",", "World", "." );
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.warn with Object[] argument.
+ * Test LogSF.warn with Object[] argument.
*/
public void testWarnArrayArg() {
LogCapture capture = new LogCapture(Level.WARN);
- Object[] args = new Object[] { "World", "Hello", ",", "." };
- LogMF.warn(logger, "{1}{2} {0}{3}", args);
+ Object[] args = new Object[] { "Hello", ",", "World", "." };
+ LogSF.warn(logger, "{}{} {}{}", args);
assertEquals("Hello, World.", capture.getMessage());
}
+
/**
- * Test LogMF.log with null pattern.
+ * Test LogSF.log with null pattern.
*/
public void testLogNullPattern() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, null, Math.PI);
+ LogSF.log(logger, Level.ERROR, null, Math.PI);
assertNull(capture.getMessage());
}
/**
- * Test LogMF.log with no-field pattern.
+ * Test LogSF.log with no-field pattern.
*/
public void testLogNoArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "Hello, World", Math.PI);
+ LogSF.log(logger, Level.ERROR, "Hello, World", Math.PI);
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.log with malformed pattern.
+ * Test LogSF.log with malformed pattern.
*/
public void testLogBadPattern() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "Hello, {.", Math.PI);
+ LogSF.log(logger, Level.ERROR, "Hello, {.", Math.PI);
assertEquals("Hello, {.", capture.getMessage());
}
/**
- * Test LogMF.log with missing argument.
+ * Test LogSF.log with missing argument.
*/
public void testLogMissingArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "Hello, {0}World", new Object[0]);
- assertEquals("Hello, {0}World", capture.getMessage());
+ LogSF.log(logger, Level.ERROR, "Hello, {}World", new Object[0]);
+ assertEquals("Hello, {}World", capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with string argument.
+ * Test LogSF.log with single field pattern with string argument.
*/
public void testLogString() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "Hello, {0}", "World");
+ LogSF.log(logger, Level.ERROR, "Hello, {}", "World");
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with null argument.
+ * Test LogSF.log with single field pattern with null argument.
*/
public void testLogNull() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "Hello, {0}", (Object) null);
+ LogSF.log(logger, Level.ERROR, "Hello, {}", (Object) null);
assertEquals("Hello, null", capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with int argument.
+ * Test LogSF.log with single field pattern with int argument.
*/
public void testLogInt() {
LogCapture capture = new LogCapture(Level.ERROR);
int val = 42;
- LogMF.log(logger, Level.ERROR, "Iteration {0}", val);
+ LogSF.log(logger, Level.ERROR, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with byte argument.
+ * Test LogSF.log with single field pattern with byte argument.
*/
public void testLogByte() {
LogCapture capture = new LogCapture(Level.ERROR);
byte val = 42;
- LogMF.log(logger, Level.ERROR, "Iteration {0}", val);
+ LogSF.log(logger, Level.ERROR, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with short argument.
+ * Test LogSF.log with single field pattern with short argument.
*/
public void testLogShort() {
LogCapture capture = new LogCapture(Level.ERROR);
short val = 42;
- LogMF.log(logger, Level.ERROR, "Iteration {0}", val);
+ LogSF.log(logger, Level.ERROR, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with long argument.
+ * Test LogSF.log with single field pattern with long argument.
*/
public void testLogLong() {
LogCapture capture = new LogCapture(Level.ERROR);
long val = 42;
- LogMF.log(logger, Level.ERROR, "Iteration {0}", val);
+ LogSF.log(logger, Level.ERROR, "Iteration {}", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with char argument.
+ * Test LogSF.log with single field pattern with char argument.
*/
public void testLogChar() {
LogCapture capture = new LogCapture(Level.ERROR);
char val = 'C';
- LogMF.log(logger, Level.ERROR, "Iteration {0}", val);
+ LogSF.log(logger, Level.ERROR, "Iteration {}", val);
assertEquals("Iteration C", capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with boolean argument.
+ * Test LogSF.log with single field pattern with boolean argument.
*/
public void testLogBoolean() {
LogCapture capture = new LogCapture(Level.ERROR);
boolean val = true;
- LogMF.log(logger, Level.ERROR, "Iteration {0}", val);
+ LogSF.log(logger, Level.ERROR, "Iteration {}", val);
assertEquals("Iteration true", capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with float argument.
+ * Test LogSF.log with single field pattern with float argument.
*/
public void testLogFloat() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "Iteration {0}", (float) Math.PI);
+ LogSF.log(logger, Level.ERROR, "Iteration {}", (float) Math.PI);
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Float(Math.PI) });
+ String expected = "Iteration " + String.valueOf(new Float(Math.PI));
assertEquals(expected, capture.getMessage());
}
/**
- * Test LogMF.log with single field pattern with double argument.
+ * Test LogSF.log with single field pattern with double argument.
*/
public void testLogDouble() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "Iteration {0}", Math.PI);
+ LogSF.log(logger, Level.ERROR, "Iteration {}", Math.PI);
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Double(Math.PI) });
+ String expected = "Iteration " + String.valueOf(new Double(Math.PI));
assertEquals(expected, capture.getMessage());
}
/**
- * Test LogMF.log with two arguments.
+ * Test LogSF.log with two arguments.
*/
public void testLogTwoArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "{1}, {0}.", "World", "Hello");
+ LogSF.log(logger, Level.ERROR, "{}, {}.", "Hello", "World");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.log with three arguments.
+ * Test LogSF.log with three arguments.
*/
public void testLogThreeArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "{1}{2} {0}.", "World", "Hello", ",");
+ LogSF.log(logger, Level.ERROR, "{}{} {}.", "Hello", ",", "World");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.log with four arguments.
+ * Test LogSF.log with four arguments.
*/
public void testLogFourArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.log(logger, Level.ERROR, "{1}{2} {0}{3}", "World", "Hello", ",", ".");
+ LogSF.log(logger, Level.ERROR, "{}{} {}{}", "Hello", ",", "World", ".");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.log with Object[] argument.
+ * Test LogSF.log with Object[] argument.
*/
public void testLogArrayArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- Object[] args = new Object[] { "World", "Hello", ",", "." };
- LogMF.log(logger, Level.ERROR, "{1}{2} {0}{3}", args);
+ Object[] args = new Object[] { "Hello", ",", "World", "." };
+ LogSF.log(logger, Level.ERROR, "{}{} {}{}", args);
assertEquals("Hello, World.", capture.getMessage());
}
@@ -1043,192 +982,191 @@
* Bundle name for resource bundle tests.
*/
private static final String BUNDLE_NAME =
- "org.apache.log4j.TestLogMFPatterns";
+ "org.apache.log4j.TestLogSFPatterns";
/**
- * Test LogMF.logrb with null bundle name.
+ * Test LogSF.logrb with null bundle name.
*/
public void testLogrbNullBundle() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR, null, "Iteration0", Math.PI);
+ LogSF.logrb(logger, Level.ERROR, null, "Iteration0", Math.PI);
assertEquals("Iteration0", capture.getMessage());
}
/**
- * Test LogMF.logrb with null key.
+ * Test LogSF.logrb with null key.
*/
public void testLogrbNullKey() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, null, Math.PI);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, null, Math.PI);
assertNull(capture.getMessage());
}
/**
- * Test LogMF.logrb with no-field pattern.
+ * Test LogSF.logrb with no-field pattern.
*/
public void testLogrbNoArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Hello1", Math.PI);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Hello1", Math.PI);
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.logrb with malformed pattern.
+ * Test LogSF.logrb with malformed pattern.
*/
public void testLogrbBadPattern() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Malformed", Math.PI);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Malformed", Math.PI);
assertEquals("Hello, {.", capture.getMessage());
}
/**
- * Test LogMF.logrb with missing argument.
+ * Test LogSF.logrb with missing argument.
*/
public void testLogrbMissingArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Hello2", new Object[0]);
- assertEquals("Hello, {0}World", capture.getMessage());
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Hello2", new Object[0]);
+ assertEquals("Hello, {}World", capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with string argument.
+ * Test LogSF.logrb with single field pattern with string argument.
*/
public void testLogrbString() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Hello3", "World");
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Hello3", "World");
assertEquals("Hello, World", capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with null argument.
+ * Test LogSF.logrb with single field pattern with null argument.
*/
public void testLogrbNull() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Hello3", (Object) null);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Hello3", (Object) null);
assertEquals("Hello, null", capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with int argument.
+ * Test LogSF.logrb with single field pattern with int argument.
*/
public void testLogrbInt() {
LogCapture capture = new LogCapture(Level.ERROR);
int val = 42;
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with byte argument.
+ * Test LogSF.logrb with single field pattern with byte argument.
*/
public void testLogrbByte() {
LogCapture capture = new LogCapture(Level.ERROR);
byte val = 42;
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with short argument.
+ * Test LogSF.logrb with single field pattern with short argument.
*/
public void testLogrbShort() {
LogCapture capture = new LogCapture(Level.ERROR);
short val = 42;
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with long argument.
+ * Test LogSF.logrb with single field pattern with long argument.
*/
public void testLogrbLong() {
LogCapture capture = new LogCapture(Level.ERROR);
long val = 42;
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
assertEquals("Iteration 42", capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with char argument.
+ * Test LogSF.logrb with single field pattern with char argument.
*/
public void testLogrbChar() {
LogCapture capture = new LogCapture(Level.ERROR);
char val = 'C';
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
assertEquals("Iteration C", capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with boolean argument.
+ * Test LogSF.logrb with single field pattern with boolean argument.
*/
public void testLogrbBoolean() {
LogCapture capture = new LogCapture(Level.ERROR);
boolean val = true;
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", val);
assertEquals("Iteration true", capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with float argument.
+ * Test LogSF.logrb with single field pattern with float argument.
*/
public void testLogrbFloat() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", (float) Math.PI);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME,
+ "Iteration0", (float) Math.PI);
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Float(Math.PI) });
+ String expected = "Iteration " + String.valueOf(new Float(Math.PI));
assertEquals(expected, capture.getMessage());
}
/**
- * Test LogMF.logrb with single field pattern with double argument.
+ * Test LogSF.logrb with single field pattern with double argument.
*/
public void testLogrbDouble() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", Math.PI);
+ LogSF.logrb(logger, Level.ERROR, BUNDLE_NAME, "Iteration0", Math.PI);
- String expected = MessageFormat.format("Iteration {0}",
- new Object[] { new Double(Math.PI) });
+ String expected = "Iteration " + String.valueOf(new Double(Math.PI));
assertEquals(expected, capture.getMessage());
}
/**
- * Test LogMF.logrb with two arguments.
+ * Test LogSF.logrb with two arguments.
*/
public void testLogrbTwoArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR,
- BUNDLE_NAME, "Hello4", "World", "Hello");
+ LogSF.logrb(logger, Level.ERROR,
+ BUNDLE_NAME, "Hello4", "Hello", "World");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.logrb with three arguments.
+ * Test LogSF.logrb with three arguments.
*/
public void testLogrbThreeArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR,
- BUNDLE_NAME, "Hello5", "World", "Hello", ",");
+ LogSF.logrb(logger, Level.ERROR,
+ BUNDLE_NAME, "Hello5", "Hello", ",", "World");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.logrb with four arguments.
+ * Test LogSF.logrb with four arguments.
*/
public void testLogrbFourArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- LogMF.logrb(logger, Level.ERROR,
- BUNDLE_NAME, "Hello6", "World", "Hello", ",", ".");
+ LogSF.logrb(logger, Level.ERROR,
+ BUNDLE_NAME, "Hello6", "Hello", ",", "World", ".");
assertEquals("Hello, World.", capture.getMessage());
}
/**
- * Test LogMF.logrb with Object[] argument.
+ * Test LogSF.logrb with Object[] argument.
*/
public void testLogrbArrayArg() {
LogCapture capture = new LogCapture(Level.ERROR);
- Object[] args = new Object[] { "World", "Hello", ",", "." };
- LogMF.logrb(logger, Level.ERROR,
+ Object[] args = new Object[] { "Hello", ",", "World", "." };
+ LogSF.logrb(logger, Level.ERROR,
BUNDLE_NAME, "Hello6", args);
assertEquals("Hello, World.", capture.getMessage());
}
Copied: logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogSFPatterns.properties (from r532950, logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogMFPatterns.properties)
URL: http://svn.apache.org/viewvc/logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogSFPatterns.properties?view=diff&rev=532960&p1=logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogMFPatterns.properties&r1=532950&p2=logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogSFPatterns.properties&r2=532960
==============================================================================
--- logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogMFPatterns.properties (original)
+++ logging/sandbox/log4j/logsf/src/test/resources/org/apache/log4j/TestLogSFPatterns.properties Thu Apr 26 21:27:09 2007
@@ -14,11 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-Iteration0=Iteration {0}
+Iteration0=Iteration {}
Hello1=Hello, World
Malformed=Hello, {.
-Hello2=Hello, {0}World
-Hello3=Hello, {0}
-Hello4={1}, {0}.
-Hello5={1}{2} {0}.
-Hello6={1}{2} {0}{3}
+Hello2=Hello, {}World
+Hello3=Hello, {}
+Hello4={}, {}.
+Hello5={}{} {}.
+Hello6={}{} {}{}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org