Tests for ClassLoaderLogManager#replace()
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 9 Jun 2011 12:03:25 +0000 (12:03 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 9 Jun 2011 12:03:25 +0000 (12:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1133816 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/juli/TestClassLoaderLogManager.java [new file with mode: 0644]

diff --git a/test/org/apache/juli/TestClassLoaderLogManager.java b/test/org/apache/juli/TestClassLoaderLogManager.java
new file mode 100644 (file)
index 0000000..bb86953
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.juli;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for {@link ClassLoaderLogManager}.
+ */
+public class TestClassLoaderLogManager extends TestCase {
+
+    public void testReplace() {
+        ClassLoaderLogManager logManager = new ClassLoaderLogManager();
+        assertEquals("", logManager.replace(""));
+        assertEquals("${", logManager.replace("${"));
+        assertEquals("${undefinedsystemproperty}",
+                logManager.replace("${undefinedsystemproperty}"));
+        assertEquals(
+                System.getProperty("line.separator")
+                        + System.getProperty("path.separator")
+                        + System.getProperty("file.separator"),
+                logManager
+                        .replace("${line.separator}${path.separator}${file.separator}"));
+        assertEquals(
+                "foo" + System.getProperty("file.separator") + "bar"
+                        + System.getProperty("line.separator")
+                        + System.getProperty("path.separator") + "baz",
+                logManager
+                        .replace("foo${file.separator}bar${line.separator}${path.separator}baz"));
+        // BZ 51249
+        assertEquals(
+                "%{file.separator}" + System.getProperty("file.separator"),
+                logManager.replace("%{file.separator}${file.separator}"));
+    }
+
+}