EN · DE · RU · FR · ES

#1862: CardDavServerDebugWriterTest.kt

projectforge-carddav/src/test/kotlin/org/projectforge/carddav/CardDavServerDebugWriterTest.kt Unit test — org.projectforge.carddav package, projectforge-carddav/src/test/kotlin/org/projectforge/carddav/CardDavServerDebugWriterTest.kt 38 lines · 13 code · 22 comments · 3 blank
Focused unit test that validates CSV string escaping in CardDavServerDebugWriter.asCsvValue(). Ensures that embedded double-quote characters are properly escaped by doubling (RFC 4180 CSV convention) and that empty strings are wrapped in quotes. This is critical for debug logging of CardDAV traffic where fields may contain special characters.

Architecture

This test targets the CardDavServerDebugWriter utility class, which is responsible for writing CardDAV server debug output in CSV format. CSV escaping is essential for correctly logging HTTP request/response data that may contain embedded quotes, newlines, or other special characters.

Imports and Dependencies

CSV Escaping Rules Tested

InputExpected OutputRule
"" (empty string)"""" (two pairs of quotes)Empty strings are wrapped in quotes, producing an escaped empty quoted string: "" (outer quotes) containing "" (escaped empty). Actually the test expects """" which represents a quoted empty field — the outer quotes wrap the field, and the inner doubled quote is the escaped quote character per RFC 4180.
Test "user"\r\nHello world"Test ""user""\r\nHello world"Double quotes within the value are escaped by doubling them ("" becomes ""). CR+LF sequences are preserved as literal \r\n. The entire value is wrapped in outer quotes.

Design Context

The CardDavServerDebugWriter class produces CSV output for logging/debugging CardDAV server interactions. CSV was chosen because it's easily importable into spreadsheet applications for analysis. The escaping follows RFC 4180 conventions:

Note: The test uses \\r\\n (literal backslash-r-backslash-n) in the expected string, suggesting the asCsvValue method preserves actual CR+LF characters rather than converting them to escape sequences.

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
f86cfa20a WIP: CardDav server.