EN · DE · RU · FR · ES

#1868: CardDavControllerTest.kt

projectforge-carddav/src/test/kotlin/org/projectforge/carddav/config/CardDavControllerTest.kt Unit test — org.projectforge.web package, projectforge-carddav/src/test/kotlin/org/projectforge/carddav/config/CardDavControllerTest.kt 61 lines · 34 code · 24 comments · 3 blank
Tests XML response generation utilities for the CardDAV controller, specifically CardDavXmlUtils.appendMultiStatusStart() and appendMultiStatusEnd() — the XML envelope builders for WebDAV multistatus responses. Located in the org.projectforge.web package (web layer tests), referencing carddav utilities from the domain layer.

Architecture

This test resides in the org.projectforge.web package — the Wicket/web layer — and tests XML generation utilities imported from org.projectforge.carddav. This represents a cross-layer test: the web controller uses the CardDAV domain utilities to generate XML responses for HTTP clients.

Imports

Tested Methods

1. appendMultiStatusStart(sb, withXmlDeclaration=true)

Appends the opening of a WebDAV multistatus XML document to a StringBuilder. With withXmlDeclaration=true (default), produces:

<?xml version="1.0" encoding="UTF-8"?>
<d:multistatus xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav"
    xmlns:cs="http://calendarserver.org/ns/" xmlns:me="http://me.com/_namespace/">

Without declaration (false): omits the XML declaration line — useful when the multistatus is part of a larger XML document or when the declaration is handled elsewhere.

2. appendMultiStatusEnd(sb)

Appends the closing </d:multistatus> tag. Extremely simple but tested for completeness and API stability.

Namespace Declarations

PrefixURIStandard
dDAV:RFC 4918 (WebDAV core)
cardurn:ietf:params:xml:ns:carddavRFC 6352 (CardDAV)
cshttp://calendarserver.org/ns/Apple CalendarServer extensions
mehttp://me.com/_namespace/Custom Micromata namespace

Commented-Out Code

The test contains commented-out code that would test CardDavXmlWriter.appendPropfindContact() — a method for generating PROPFIND response entries for individual contacts. This suggests the contact PROPFIND response generation was still under development or pending when this test was written. The User("kai") and Contact(42L, "Kai", "Reinhard", Date(1234567890)) objects are constructed but the assertion is commented out.

The commented-out assertion //Assertions.assertEquals(response, sb.toString()) references an undefined variable response — this test is incomplete and represents a snapshot of work in progress, preserved for documentation value.

Cross-Layer Dependency

Location at projectforge-carddav/src/test/kotlin/org/projectforge/web/ with package org.projectforge.web is notable — it tests the web layer's use of domain-layer CardDAV utilities. The test directory mirrors the production package structure, indicating the web controller was being tested separately from the domain logic.

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
0d7a81f91 WIP: Carddav
744d238de WIP: Carddav
c4062ed97 WIP: Carddav
2ad0cfe66 WIP: Carddav
b5d8f83c1 WIP: Carddav
953455ae5 WIP: Carddav